/**
 * Nanban ERP — Enterprise Settings (Operation: Deep Clean)
 * Loaded after index inline styles; scoped to #settingsSection.
 */

#settingsSection {
  --set-bg: transparent;
  --set-surface: #ffffff;
  --set-input: #ffffff;
  --set-border: rgba(15, 23, 42, 0.1);
  --set-text: #0c0a09;
  --set-muted: #475569;
  --set-accent: #dc2626;
  --set-accent-glow: rgba(220, 38, 38, 0.25);
  --set-toggle-on: #059669;
  --set-toggle-off: #cbd5e1;
  background: var(--set-bg) !important;
  color: var(--set-text) !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 0 32px !important;
  font-family: "Inter", "Noto Sans Tamil", system-ui, sans-serif;
}

#settingsSection .nb-set-cat-btn:hover {
  background: #f8fafc !important;
  color: var(--set-text) !important;
}

#settingsSection .nb-set-cat-btn--active {
  background: rgba(220, 38, 38, 0.08) !important;
  color: #b91c1c !important;
  box-shadow: inset 3px 0 0 #dc2626 !important;
}

#settingsSection .settings-nav-item:hover {
  background: #f8fafc !important;
  color: var(--set-text) !important;
}

#settingsSection .settings-nav-item--active {
  background: rgba(220, 38, 38, 0.1) !important;
  color: #b91c1c !important;
}

#settingsSection input:focus,
#settingsSection select:focus,
#settingsSection textarea:focus {
  box-shadow:
    0 0 0 2px #ffffff,
    0 0 0 4px rgba(220, 38, 38, 0.3) !important;
}

#settingsSection input:not([type="checkbox"]):not([type="radio"]):not(.nb-set-toggle-input),
#settingsSection select,
#settingsSection textarea {
  border: 1px solid rgba(15, 23, 42, 0.14) !important;
}

#settingsSection .nb-set-hint code {
  background: #f1f5f9 !important;
  color: #334155 !important;
}

#settingsSection .nb-set-card-head,
#settingsSection .nb-set-row {
  border-bottom-color: rgba(15, 23, 42, 0.08) !important;
}

#settingsSection .nb-set-actions {
  border-top-color: rgba(15, 23, 42, 0.08) !important;
}

#settingsSection a {
  color: #dc2626 !important;
}

#settingsSection .btn-nanban,
#settingsSection .btn-s {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
}

#settingsSection .btn-secondary,
#settingsSection .btn-w {
  background: #ffffff !important;
  color: #334155 !important;
  border: 1px solid rgba(15, 23, 42, 0.12) !important;
}

#settingsSection #settingsRtoChecklistSection {
  background: #f0fdf4 !important;
  border-color: rgba(5, 150, 105, 0.25) !important;
}

#settingsSection * {
  box-sizing: border-box;
}

/* Annihilate legacy inline decoration inside settings */
#settingsSection .glass-card,
#settingsSection .settings-pane-panel,
#settingsSection [class*="glass-card"] {
  background: var(--set-surface) !important;
  border: 1px solid var(--set-border) !important;
  border-radius: 16px !important;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06) !important;
  color: var(--set-text) !important;
}

#settingsSection .settings-page-hero {
  padding: 24px 24px 16px;
  margin: 0;
  border-bottom: 1px solid var(--set-border);
  background: transparent !important;
}

#settingsSection .settings-page-hero h2 {
  font-size: clamp(1.5rem, 3vw, 2rem) !important;
  font-weight: 800 !important;
  letter-spacing: -0.035em !important;
  color: var(--set-text) !important;
  margin: 0 !important;
}

#settingsSection .settings-page-hero p {
  font-size: 1rem !important;
  font-weight: 400 !important;
  color: var(--set-muted) !important;
  margin: 8px 0 0 !important;
  max-width: 52ch;
  line-height: 1.5 !important;
}

#settingsSection .nb-set-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

/* Master–detail layout */
#settingsSection .settings-layout {
  display: grid !important;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr) !important;
  gap: 24px !important;
  padding: 20px 24px 0 !important;
  align-items: start !important;
}

#settingsSection .settings-sidenav {
  position: sticky !important;
  top: 80px !important;
  background: var(--set-surface) !important;
  border: 1px solid var(--set-border) !important;
  border-radius: 16px !important;
  padding: 12px !important;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06) !important;
}

#settingsSection .settings-sidenav-title {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--set-muted);
  margin: 8px 10px 6px;
}

#settingsSection .settings-nav-group {
  display: none !important;
}

/* Primary category nav */
#settingsSection .nb-set-cat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 4px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--set-muted);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

#settingsSection .nb-set-cat-btn:hover {
  background: #f8fafc;
  color: var(--set-text);
}

#settingsSection .nb-set-cat-btn--active {
  background: rgba(59, 130, 246, 0.12) !important;
  color: var(--set-text) !important;
  box-shadow: inset 3px 0 0 var(--set-accent) !important;
}

#settingsSection .nb-set-cat-ico {
  width: 22px;
  text-align: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

#settingsSection .nb-set-subnav {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0 12px 8px;
  padding-left: 8px;
  border-left: 1px solid var(--set-border);
}

#settingsSection.nb-set-subnav-visible .nb-set-subnav {
  display: flex;
}

#settingsSection .settings-nav-item {
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  text-align: left !important;
  padding: 8px 12px !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 8px !important;
  background: transparent !important;
  color: var(--set-muted) !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  box-shadow: none !important;
}

#settingsSection .settings-nav-item:hover {
  background: #f8fafc !important;
  color: var(--set-text) !important;
}

#settingsSection .settings-nav-item--active {
  background: rgba(59, 130, 246, 0.15) !important;
  color: var(--set-text) !important;
}

/* Right pane: bento grid per category */
#settingsSection .settings-main-col {
  min-width: 0 !important;
  display: block !important;
}

#settingsSection #nanbanSettingsBento {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 768px) {
  #settingsSection #nanbanSettingsBento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #settingsSection #nanbanSettingsBento .nb-set-span-2 {
    grid-column: 1 / -1;
  }
}

#settingsSection .settings-pane-panel {
  display: none !important;
  margin: 0 !important;
  padding: 20px !important;
}

#settingsSection .settings-pane-panel.nb-set-pane--visible {
  display: none !important;
}

#settingsSection .settings-pane-panel.nb-set-pane--visible.is-active {
  display: block !important;
}

#settingsSection .settings-pane-panel.is-active {
  display: none !important;
}

#settingsSection .settings-pane-panel.nb-set-pane--visible.is-active {
  display: block !important;
}

/* Legacy single-pane mode fallback */
#settingsSection.nb-set-legacy-pane-mode .settings-pane-panel {
  display: none !important;
}
#settingsSection.nb-set-legacy-pane-mode .settings-pane-panel.is-active {
  display: block !important;
}
#settingsSection.nb-set-legacy-pane-mode .settings-pane-panel.nb-set-pane--visible {
  display: none !important;
}

/* Typography */
#settingsSection h3,
#settingsSection h4 {
  font-size: 1.25rem !important;
  font-weight: 800 !important;
  color: var(--set-text) !important;
  margin: 0 0 12px !important;
  line-height: 1.25 !important;
  letter-spacing: -0.025em !important;
}

#settingsSection h4 {
  font-size: 1.0625rem !important;
  margin-top: 16px !important;
}

#settingsSection label,
#settingsSection .nb-set-label {
  display: block;
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  color: #334155 !important;
  margin: 0 0 6px !important;
}

#settingsSection .nb-set-hint {
  font-size: 0.875rem !important;
  font-weight: 400 !important;
  color: var(--set-muted) !important;
  margin: 4px 0 14px !important;
  line-height: 1.5 !important;
}

#settingsSection .nb-set-hint code {
  font-size: 0.8125rem;
  background: var(--set-input);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--set-muted);
}

/* Inputs */
#settingsSection input:not([type="checkbox"]):not([type="radio"]):not(.nb-set-toggle-input),
#settingsSection select,
#settingsSection textarea {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 44px !important;
  padding: 10px 14px !important;
  background: var(--set-input) !important;
  border: 1px solid rgba(15, 23, 42, 0.14) !important;
  border-radius: 10px !important;
  color: #0c0a09 !important;
  font-size: 0.9375rem !important;
  font-weight: 500 !important;
  margin: 0 0 12px !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

#settingsSection textarea {
  min-height: 88px !important;
  resize: vertical;
}

#settingsSection input:focus,
#settingsSection select:focus,
#settingsSection textarea:focus {
  outline: none !important;
  box-shadow:
    0 0 0 2px var(--set-bg),
    0 0 0 4px var(--set-accent) !important;
}

/* iOS toggles */
#settingsSection .nb-set-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  cursor: pointer;
}

#settingsSection .nb-set-toggle-track {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
  background: var(--set-toggle-off);
  border-radius: 999px;
  transition: background 0.25s ease;
}

#settingsSection .nb-set-toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

#settingsSection .nb-set-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

#settingsSection .nb-set-toggle-input:checked + .nb-set-toggle-track {
  background: var(--set-toggle-on);
}

#settingsSection .nb-set-toggle-input:checked + .nb-set-toggle-track::after {
  transform: translateX(20px);
}

#settingsSection .nb-set-toggle-input:focus-visible + .nb-set-toggle-track {
  box-shadow: 0 0 0 2px var(--set-accent);
}

/* Buttons */
#settingsSection .btn,
#settingsSection button.btn {
  width: fit-content !important;
  min-width: 140px;
  max-width: 100%;
  padding: 10px 20px !important;
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  border-radius: 10px !important;
  margin: 0 !important;
}

#settingsSection .nb-set-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--set-border);
}

#settingsSection .nb-set-actions .btn {
  margin: 0 !important;
}

#settingsSection .btn-nanban,
#settingsSection .btn-s {
  background: var(--set-accent) !important;
  color: #fff !important;
  border: none !important;
}

#settingsSection .btn-secondary,
#settingsSection .btn-w {
  background: var(--set-input) !important;
  color: var(--set-text) !important;
  border: 1px solid var(--set-border) !important;
}

#settingsSection .btn-d {
  background: #dc2626 !important;
  color: #fff !important;
}

/* Preserve semantic colored panels (do NOT flatten) */

#settingsSection .flex-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

#settingsSection .flex-row > div {
  flex: 1 1 140px;
  min-width: 0;
}

#settingsSection .tag-list {
  margin-bottom: 12px;
}

#settingsSection .service-grid {
  margin-bottom: 16px !important;
}

#settingsSection table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

#settingsSection table th,
#settingsSection table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--set-border);
  color: var(--set-text);
  text-align: left;
}

#settingsSection table thead tr {
  background: var(--set-input) !important;
}

#settingsSection a {
  color: #60a5fa;
}

#settingsSection details summary {
  cursor: pointer;
  color: var(--set-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

#settingsSection .nb-settings-advanced {
  display: none !important;
}

#settingsSection.nb-settings-show-advanced .nb-settings-advanced {
  display: flex !important;
}

#settingsSection .nb-set-advanced-chip {
  font-size: 0.75rem;
  color: var(--set-muted);
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--set-input);
  border: 1px solid var(--set-border);
  cursor: pointer;
}

@media (max-width: 960px) {
  #settingsSection .settings-layout {
    grid-template-columns: 1fr !important;
  }
  #settingsSection .settings-sidenav {
    position: relative !important;
    top: 0 !important;
  }
}

/* —— Business profile card (Stripe / Calendly tier) —— */
#settingsSection .nb-set-profile-card {
  padding: 24px !important;
  border-radius: 16px !important;
}

#settingsSection .nb-set-card-head {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

#settingsSection .nb-set-card-sub {
  font-size: 0.875rem !important;
  font-weight: 400 !important;
  color: var(--set-muted) !important;
  margin: 8px 0 0 !important;
  line-height: 1.5 !important;
}

#settingsSection .nb-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  margin: 0 !important;
}

#settingsSection .nb-set-row--section {
  align-items: flex-start;
}

#settingsSection .nb-set-row-label {
  flex: 1 1 40%;
  min-width: 0;
}

#settingsSection .nb-set-label-sub {
  display: block;
  font-size: 0.75rem !important;
  font-weight: 400 !important;
  color: var(--set-muted) !important;
  margin-top: 4px !important;
}

#settingsSection .nb-set-row-control {
  flex: 1 1 56%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

#settingsSection .nb-set-row-control--stack {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

#settingsSection .nb-set-row-control--toggle {
  justify-content: flex-end;
}

#settingsSection .nb-set-row-control--actions {
  justify-content: flex-end;
}

#settingsSection .nb-set-field-input {
  width: 100% !important;
  max-width: 300px !important;
  margin: 0 !important;
}

#settingsSection .nb-set-row-control--stack .nb-set-field-input {
  max-width: 100% !important;
}

#settingsSection .nb-set-field-input--narrow {
  max-width: 120px !important;
}

#settingsSection .nb-set-field-textarea {
  min-height: 72px !important;
  max-width: 100% !important;
}

#settingsSection .nb-set-field-textarea--mono {
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem !important;
}

#settingsSection .nb-set-weekly-hours {
  width: 100%;
  max-width: 420px;
  margin-left: auto;
}

#settingsSection .nb-set-hours-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  min-height: 40px;
}

#settingsSection .nb-set-hours-day {
  flex: 0 0 auto;
  min-width: 108px;
}

#settingsSection .nb-set-hours-times {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 1 1 auto;
}

#settingsSection .nb-set-hours-times.is-closed {
  justify-content: flex-end;
}

#settingsSection .nb-set-hours-times input[type="time"] {
  width: auto !important;
  max-width: 112px !important;
  min-height: 36px !important;
  padding: 6px 10px !important;
  margin: 0 !important;
}

#settingsSection .nb-set-hours-sep {
  color: var(--set-muted);
  font-size: 0.875rem;
}

#settingsSection .nb-set-hours-closed-label {
  font-size: 0.875rem;
  color: var(--set-muted);
  font-weight: 500;
}

#settingsSection .nb-set-toggle--compact {
  margin: 0 !important;
  flex-direction: row-reverse;
  justify-content: flex-start;
  gap: 10px;
}

#settingsSection .nb-set-toggle--compact .nb-set-toggle-text {
  font-size: 0.9375rem;
  font-weight: 500;
}

#settingsSection .nb-set-actions--profile {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

#settingsSection .nb-set-btn-inline {
  padding: 10px 16px !important;
  font-size: 0.875rem !important;
}

@media (max-width: 640px) {
  #settingsSection .nb-set-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  #settingsSection .nb-set-row-control {
    justify-content: stretch;
  }
  #settingsSection .nb-set-field-input {
    max-width: 100% !important;
  }
  #settingsSection .nb-set-weekly-hours {
    margin-left: 0;
    max-width: 100%;
  }
}
