/* ==========================================================================
   Sasonis Studios - Settings System Stylesheet
   Modern, scalable, responsive account & security management
   ========================================================================== */

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 100%;
  -webkit-overflow-scrolling: touch;
}

.settings-body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-primary, #090a0f);
  color: var(--text-primary, #f1f5f9);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  position: relative;
  overflow-x: hidden;
  overflow-y: visible;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

/* Ambient Glow Orbs */
.settings-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-orb.orb-violet {
  position: absolute;
  top: -10%;
  left: 20%;
  width: 50vw;
  height: 50vw;
  max-width: 600px;
  max-height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
  filter: blur(80px);
}

.ambient-orb.orb-cyan {
  position: absolute;
  bottom: -10%;
  right: 15%;
  width: 45vw;
  height: 45vw;
  max-width: 550px;
  max-height: 550px;
  background: radial-gradient(circle, rgba(0, 210, 255, 0.09) 0%, transparent 70%);
  filter: blur(80px);
}

.settings-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* Header */
.settings-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(9, 10, 15, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.settings-header .header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(0, 210, 255, 0.15), rgba(99, 102, 241, 0.2));
  border: 1px solid rgba(0, 210, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  display: flex;
  flex-direction: column;
}

.brand-main {
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: #00d2ff;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.settings-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-nav .nav-item {
  color: #94a3b8;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.settings-nav .nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.settings-nav .nav-item.active {
  color: #00d2ff;
  background: rgba(0, 210, 255, 0.08);
}

.settings-nav .nav-item.admin-link {
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.settings-nav .nav-item.admin-link:hover {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.user-avatar-initial {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00d2ff, #6366f1);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-email-text {
  font-size: 0.8rem;
  color: #cbd5e1;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Page Layout */
.settings-main {
  position: relative;
  z-index: 1;
  padding-top: 40px;
  padding-bottom: 80px;
  flex: 1;
}

.settings-page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 8px;
}

.page-subtitle {
  color: #94a3b8;
  font-size: 0.95rem;
  max-width: 650px;
  line-height: 1.5;
}

.settings-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  align-items: start;
}

/* Tabs Sidebar */
.settings-tabs-sidebar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(15, 17, 26, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 12px;
  backdrop-filter: blur(12px);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.tab-btn svg {
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #f1f5f9;
}

.tab-btn.active {
  background: rgba(0, 210, 255, 0.09);
  color: #00d2ff;
  border: 1px solid rgba(0, 210, 255, 0.22);
}

.tab-btn.active svg {
  opacity: 1;
  stroke: #00d2ff;
}

/* Content Area */
.settings-content-card {
  background: rgba(15, 17, 26, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 32px;
  backdrop-filter: blur(16px);
  min-height: 480px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeInPane 0.25s ease-out;
}

@keyframes fadeInPane {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.pane-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

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

.pane-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.pane-desc {
  font-size: 0.88rem;
  color: #94a3b8;
  line-height: 1.45;
}

/* Form Styles */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 600px;
}

.user-badge-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  margin-bottom: 6px;
}

.user-avatar-large {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00d2ff, #6366f1);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 210, 255, 0.25);
}

.user-badge-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.email-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-email-display {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.role-pill {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 210, 255, 0.12);
  color: #00d2ff;
  border: 1px solid rgba(0, 210, 255, 0.3);
  text-transform: uppercase;
}

.role-pill.founder {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(239, 68, 68, 0.2));
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.5);
}

.join-date {
  font-size: 0.78rem;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: rgba(10, 12, 18, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: #00d2ff;
  box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.15);
}

.form-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.02);
}

.form-hint {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.4;
}

.form-actions {
  margin-top: 10px;
}

.settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.settings-btn.primary {
  background: linear-gradient(135deg, #00d2ff, #0077ff);
  color: #000;
  box-shadow: 0 4px 14px rgba(0, 210, 255, 0.25);
}

.settings-btn.primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.settings-btn.danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.settings-btn.danger:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

/* Password Strength */
.pwd-strength-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.pwd-strength-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease, background-color 0.3s ease;
}

.security-notice-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #bae6fd;
  font-size: 0.82rem;
  line-height: 1.45;
}

.security-notice-box svg {
  flex-shrink: 0;
  margin-top: 2px;
}

/* Devices Tab */
.devices-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.device-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: all 0.2s ease;
}

.device-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.device-card.current-device {
  border-color: rgba(0, 210, 255, 0.3);
  background: rgba(0, 210, 255, 0.03);
}

.device-main-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.device-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #00d2ff;
}

.device-text-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.device-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.device-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.current-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  text-transform: uppercase;
}

.device-details-line {
  font-size: 0.8rem;
  color: #94a3b8;
}

.device-last-active {
  font-size: 0.78rem;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
}

/* AI Preferences Tab */
.model-choice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.model-choice-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 18px 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.2s ease;
}

.model-choice-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
}

.model-choice-card input[type="radio"] {
  position: absolute;
  top: 20px;
  right: 20px;
  accent-color: #00d2ff;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.model-choice-card:has(input[type="radio"]:checked) {
  border-color: #00d2ff;
  background: rgba(0, 210, 255, 0.05);
  box-shadow: 0 4px 20px rgba(0, 210, 255, 0.12);
}

.model-card-body {
  padding-right: 32px;
}

.model-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.model-chip {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}

.model-chip.cyan {
  background: rgba(0, 210, 255, 0.15);
  color: #00d2ff;
}

.model-chip.violet {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.model-chip.amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.model-provider {
  font-size: 0.75rem;
  color: #64748b;
}

.model-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.model-desc {
  font-size: 0.84rem;
  color: #94a3b8;
  line-height: 1.45;
}

/* Appearance Tab */
.theme-picker-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.theme-option.active {
  border-color: #00d2ff;
  background: rgba(0, 210, 255, 0.08);
}

.theme-preview {
  width: 100%;
  height: 60px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-theme-preview {
  background: #090a0f;
  box-shadow: inset 0 0 12px rgba(0, 210, 255, 0.2);
}

.oled-theme-preview {
  background: #000000;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.05);
}

.theme-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
}

.toggle-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.setting-subtitle {
  font-size: 0.78rem;
  color: #64748b;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #00d2ff;
}

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

/* Footer */
.settings-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding: 24px 0;
  margin-top: auto;
  text-align: center;
  font-size: 0.8rem;
  color: #64748b;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.speed-toast {
  padding: 12px 18px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: auto;
}

.speed-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.speed-toast-success {
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.speed-toast-warning {
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.speed-toast-error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .settings-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .settings-tabs-sidebar {
    position: sticky;
    top: 70px;
    z-index: 40;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px 10px;
    gap: 6px;
    background: rgba(10, 13, 20, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .settings-tabs-sidebar::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 0.82rem;
    flex-shrink: 0;
  }

  .settings-content-card {
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 36px;
  }

  /* All sections are naturally stacked and scrollable on mobile */
  .tab-pane {
    display: block !important;
    opacity: 1 !important;
    transform: none !important;
    padding-bottom: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    scroll-margin-top: 140px;
  }

  .tab-pane:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }
}

@media (max-width: 480px) {
  .settings-header .settings-nav {
    display: none;
  }

  .user-badge-header {
    flex-direction: column;
    text-align: center;
  }

  .device-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .device-last-active {
    text-align: left;
  }
}
