/* ==========================================================================
   ANISHIFT - UNIVERSAL SETTINGS MODAL STYLES (settings.css)
   Mobile Relative, Unified Theme Sync, Background Scroll Lock
   ========================================================================== */

/* 1. Bulletproof Body & Background Scroll Lock when Modal is open */
html.settings-modal-open,
body.settings-modal-open {
  overflow: hidden !important;
  height: 100% !important;
  overscroll-behavior: none !important;
  touch-action: none;
}

/* 2. Modal Overlay Backdrop */
.anishift-settings-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
  padding: 16px;
}

.anishift-settings-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 3. Modal Container (Desktop Default) */
.anishift-settings-modal {
  width: 760px;
  max-width: 95vw;
  height: 540px;
  max-height: 88vh;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  display: flex;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.anishift-settings-overlay.open .anishift-settings-modal {
  transform: scale(1) translateY(0);
}

/* Mobile Header is hidden on Desktop */
.settings-mobile-header {
  display: none;
}

/* 4. Left Sidebar (Desktop) */
.settings-sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-hover);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}

.settings-sidebar-header {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  padding: 4px 10px 14px 10px;
  letter-spacing: -0.2px;
}

.settings-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
}

.settings-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 14px 10px 6px 10px;
}

.settings-nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  user-select: none;
}

.settings-nav-btn i {
  font-size: 13px;
  width: 16px;
  text-align: center;
  color: var(--text-dim);
  transition: color 0.15s ease;
}

.settings-nav-btn:hover {
  background: var(--border-light);
  color: var(--text-main);
}

.settings-nav-btn:hover i {
  color: var(--text-main);
}

.settings-nav-btn.active {
  background: var(--border-color);
  color: var(--text-main);
  font-weight: 600;
}

.settings-nav-btn.active i {
  color: var(--accent-primary);
}

.settings-sidebar-footer {
  padding: 10px 10px 2px 10px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: inherit;
}

/* 5. Right Content Panel (Desktop) */
.settings-content-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
}

.settings-content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.settings-content-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.settings-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.settings-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.settings-content-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Scrollbar */
.settings-content-body::-webkit-scrollbar,
.settings-sidebar-nav::-webkit-scrollbar {
  width: 6px;
}
.settings-content-body::-webkit-scrollbar-thumb,
.settings-sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

/* 6. Setting Item Styles */
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
}

.setting-desc {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.45;
  max-width: 85%;
}

/* 7. Modern Theme Segmented Toolbar (Settings Modal - 100% Matches Drawer & Footer UI) */
.theme-segmented-group {
  display: flex;
  align-items: stretch;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
  width: 100%;
  max-width: 490px;
  margin-top: 10px;
  box-sizing: border-box;
  user-select: none;
}

.theme-segmented-btn {
  flex: 1;
  min-width: 0;
  height: 35px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.theme-segmented-btn i {
  font-size: 13px;
  transition: transform 0.15s ease, color 0.15s ease;
}

.theme-segmented-btn:hover:not(.active) {
  background: var(--border-light);
  color: var(--text-main);
}

.theme-segmented-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  font-weight: 600;
  border-color: var(--border-color);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Individual preview accent colors for active icons */
.theme-segmented-btn.active[data-val="system"] i {
  color: var(--accent-primary);
}
.theme-segmented-btn.active[data-val="light"] i {
  color: #f59e0b;
}
.theme-segmented-btn.active[data-val="dark"] i {
  color: #818cf8;
}
.theme-segmented-btn.active[data-val="oled"] i {
  color: #00e5ff;
}
.theme-segmented-btn.active[data-val="navy"] i {
  color: #38bdf8;
}

.theme-segmented-btn.active i {
  transform: scale(1.08);
}

@media (max-width: 560px) {
  .theme-segmented-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    height: auto;
    gap: 4px;
    padding: 4px;
  }
  .theme-segmented-btn {
    height: 32px;
    font-size: 11.5px;
    padding: 0 6px;
    gap: 5px;
  }
}

/* 8. Modern iOS / AniShift Toggle Switch */
.modern-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
}

.modern-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.modern-switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-color);
  border-radius: 24px;
  transition: all 0.25s ease;
}

.modern-switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.modern-switch input:checked + .modern-switch-slider {
  background-color: var(--accent-primary);
}

.modern-switch input:checked + .modern-switch-slider:before {
  transform: translateX(20px);
}

/* 9. Shortcuts List Rows (Desktop Only) */
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-label {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
}

.shortcut-keys {
  display: flex;
  align-items: center;
  gap: 6px;
}

.shortcut-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  background: var(--bg-hover);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.shortcut-or {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
}

/* 10. Accent Colors Preset Support in CSS Variables */
:root[data-accent="iris"] {
  --accent-primary: #8b5cf6;
  --accent-primary-hover: #7c3aed;
  --accent-primary-light: rgba(139, 92, 246, 0.15);
}

:root[data-accent="jade"] {
  --accent-primary: #10b981;
  --accent-primary-hover: #059669;
  --accent-primary-light: rgba(16, 185, 129, 0.15);
}

:root[data-accent="cobalt"],
:root:not([data-accent]) {
  --accent-primary: #1e90ff;
  --accent-primary-hover: #1c86ee;
  --accent-primary-light: rgba(30, 144, 255, 0.12);
}

/* ==========================================================================
   11. MOBILE RESPONSIVENESS (Native Bottom Sheet matching AniShift UI)
   ========================================================================== */
@media (max-width: 768px) {
  .anishift-settings-overlay {
    padding: 0;
    align-items: flex-end;
  }

  /* Bottom sheet modal container */
  .anishift-settings-modal {
    flex-direction: column;
    width: 100%;
    max-width: 100vw;
    height: 75vh;
    max-height: 85vh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    border-left: none;
    border-right: none;
    background: var(--bg-surface);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .anishift-settings-overlay.open .anishift-settings-modal {
    transform: translateY(0);
  }

  /* Mobile Header with Drag Handle */
  .settings-mobile-header {
    display: flex;
    flex-direction: column;
    padding: 8px 16px 0;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-surface);
    flex-shrink: 0;
  }

  .settings-mobile-drag-handle {
    width: 36px;
    height: 4px;
    background: var(--border-color);
    border-radius: 9999px;
    margin: 0 auto 10px;
  }

  .settings-mobile-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 10px;
  }

  .settings-mobile-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.2px;
  }

  .settings-mobile-title i {
    font-size: 14px;
    color: var(--accent-primary);
  }

  .settings-mobile-close-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s ease;
  }

  .settings-mobile-close-btn:active {
    background: var(--border-color);
    color: var(--text-main);
  }

  /* Segmented Nav Bar for General / Watch */
  .settings-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    padding: 8px 16px;
    background: var(--bg-surface);
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  /* Completely hide shortcuts and desktop sidebar elements on mobile */
  .settings-sidebar-header,
  .settings-sidebar-footer,
  .settings-section-title,
  .settings-section-shortcuts,
  .settings-shortcut-tab,
  .settings-nav-btn[data-tab^="shortcuts-"] {
    display: none !important;
  }

  .settings-sidebar-nav {
    display: flex;
    flex-direction: row;
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    padding: 3px;
    border-radius: var(--radius-sm);
    gap: 4px;
    width: 100%;
    overflow-x: hidden;
  }

  .settings-nav-btn {
    flex: 1;
    height: 34px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
    width: auto;
    transition: all 0.15s ease;
    white-space: nowrap;
  }

  .settings-nav-btn i {
    font-size: 12px;
    color: var(--text-dim);
    width: auto;
  }

  .settings-nav-btn.active {
    background: var(--bg-surface);
    color: var(--accent-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-weight: 700;
  }

  .settings-nav-btn.active i {
    color: var(--accent-primary);
  }

  /* Hide desktop content header on mobile */
  .settings-content-header {
    display: none !important;
  }

  .settings-content-panel {
    flex: 1;
    min-height: 0;
    background: var(--bg-surface);
  }

  .settings-content-body {
    padding: 16px;
    gap: 12px;
    background: var(--bg-surface);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* Setting Items on Mobile matching site card style */
  .setting-item {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    gap: 6px;
  }

  .setting-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-main);
  }

  .setting-desc {
    font-size: 11.5px;
    color: var(--text-dim);
    max-width: 100%;
  }

  .theme-selector-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 100%;
    margin-top: 8px;
  }
}
