// ════════════════════════════════════════════════════════════════════
//  flssurveysection.component.scss
//  Modal-only component (add/edit a single section) hosted in a MatDialog
//  from surveybuilder. Follows the same token-driven conventions as
//  flssurveyquestion (sq-*), namespaced ssn- to avoid collisions.
// ════════════════════════════════════════════════════════════════════

:host {
  display: flex;
  flex-direction: column;
  width: min(610px, 92vw);
  max-height: 90vh;
  overflow: hidden;
}

.ssn-root {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg-surface);
  font-family: var(--font-family-primary), sans-serif;
  border-radius: 10px;
  overflow: hidden;
}

// ── Header ────────────────────────────────────────────────────────
.ssn-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 4px;
  flex-shrink: 0;
}

.ssn-header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ssn-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.ssn-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin: 0;
}

.ssn-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;

  &:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }
}

// ── Body ──────────────────────────────────────────────────────────
.ssn-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
}

.ssn-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ssn-field-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ssn-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.ssn-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;

  @media (max-width: 480px) {
    grid-template-columns: 1fr;
  }
}

// ── Loading state ─────────────────────────────────────────────────
.ssn-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.ssn-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-default);
  border-top-color: var(--action-primary-default);
  border-radius: 50%;
  animation: ssn-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes ssn-spin {
  to {
    transform: rotate(360deg);
  }
}

// ── Footer ────────────────────────────────────────────────────────
.ssn-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border-default);
  flex-shrink: 0;
}

.ssn-btn-cancel {
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;

  &:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }
}

.ssn-btn-save {
  padding: 9px 24px;
  font-size: 13px;
  font-weight: 600;
  background: var(--action-primary-default);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;

  &:hover {
    filter: brightness(90%);
  }

  &:active {
    transform: scale(0.98);
  }
}

// ── RTL support ───────────────────────────────────────────────────
[dir='rtl'] {
  .ssn-footer {
    flex-direction: row-reverse;
    justify-content: flex-start;
  }
}

// ── Responsive ────────────────────────────────────────────────────
@media (max-width: 480px) {
  :host {
    width: 94vw;
  }

  .ssn-header {
    padding: 16px 18px 4px;
  }

  .ssn-body {
    padding: 16px 18px;
  }

  .ssn-footer {
    flex-direction: column-reverse;
    align-items: stretch;
    padding: 14px 18px 18px;
  }

  .ssn-btn-cancel,
  .ssn-btn-save {
    width: 100%;
    text-align: center;
  }
}