/* ============================================================
   FANZONE-SETTINGS.CSS
   Glassmorphism dark-navy design system for the Settings page
   ============================================================ */

/* --- SECTIONS --- */
.fz-set-section {
  margin-bottom: var(--space-lg, 24px);
}

.fz-set-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display, "Space Grotesk", sans-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-text, #eef1fb);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ink-line, rgba(233, 238, 255, 0.1));
}

.fz-set-section-title svg {
  width: 20px;
  height: 20px;
  color: var(--page-accent, #8a9bb8);
  flex-shrink: 0;
}

/* --- CARDS (glassmorphism) --- */
.fz-set-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--ink-line, rgba(233, 238, 255, 0.1));
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-lg, 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- PROFILE --- */
.fz-set-profile-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.fz-set-profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(
    135deg,
    var(--page-accent, #8a9bb8),
    var(--page-accent-2, #00d4ff)
  );
  box-shadow: 0 4px 16px var(--page-accent-soft, rgba(138, 155, 184, 0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(138, 155, 184, 0.3);
}

.fz-set-profile-info {
  flex: 1;
  min-width: 0;
}

.fz-set-profile-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fz-set-name-input {
  background: rgba(11, 15, 30, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm, 8px);
  padding: 8px 12px;
  color: var(--ink-text, #eef1fb);
  font-size: 16px;
  font-family: var(--font-body, sans-serif);
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
  max-width: 200px;
}

.fz-set-name-input:focus {
  border-color: var(--page-accent, #8a9bb8);
}

.fz-set-name-save {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-muted, #9aa3c4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.fz-set-name-save:hover {
  background: var(--page-accent, #8a9bb8);
  color: #fff;
  border-color: var(--page-accent, #8a9bb8);
}

.fz-set-name-save svg {
  width: 16px;
  height: 16px;
}

.fz-set-profile-id {
  font-size: 11px;
  font-family: var(--font-mono, "Space Mono", monospace);
  color: var(--ink-muted, #9aa3c4);
  margin-top: 4px;
}

/* Profile stats grid */
.fz-set-profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
}

.fz-set-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 8px;
  border-radius: var(--radius-md, 12px);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.fz-set-stat-val {
  font-family: var(--font-mono, "Space Mono", monospace);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-text, #eef1fb);
  line-height: 1;
}

.fz-set-stat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted, #9aa3c4);
  margin-top: 4px;
}

/* Level bar */
.fz-set-level-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fz-set-level-bar-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.fz-set-level-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--page-accent, #8a9bb8),
    var(--page-accent-2, #00d4ff)
  );
  box-shadow: 0 0 12px var(--page-accent-soft, rgba(138, 155, 184, 0.15));
  transition: width 0.6s ease-out;
}

.fz-set-level-bar-text {
  font-size: 12px;
  font-family: var(--font-mono, monospace);
  color: var(--ink-muted, #9aa3c4);
  white-space: nowrap;
}

/* --- PREFERENCES --- */
.fz-set-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.fz-set-pref-row:last-child {
  border-bottom: none;
}

.fz-set-pref-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fz-set-pref-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-text, #eef1fb);
}

.fz-set-pref-desc {
  font-size: 12px;
  color: var(--ink-muted, #9aa3c4);
}

/* Nation theme select (reuses .fz-set-theme-select class name
   for consistency with existing CSS, now used for nation dropdown) */
.fz-set-theme-select {
  padding: 8px 12px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(11, 15, 30, 0.9);
  color: var(--ink-text, #eef1fb);
  font-size: 13px;
  font-family: var(--font-body, sans-serif);
  cursor: pointer;
  min-height: 38px;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa3c4' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  flex-shrink: 0;
}

/* Nation theme preview — dual color */
.fz-set-theme-preview {
  padding: 14px 16px;
  border-radius: var(--radius-md, 12px);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.fz-set-theme-preview-nation {
  font-size: 16px;
  font-weight: 800;
  background: linear-gradient(
    135deg,
    var(--page-accent, #8a9bb8),
    var(--page-accent-2, #00d4ff)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.fz-set-theme-preview-colors {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.fz-set-theme-color-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fz-set-theme-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  transition:
    background 0.3s,
    box-shadow 0.3s;
}

.fz-set-theme-color-label {
  font-size: 12px;
  font-family: var(--font-mono, monospace);
  color: var(--ink-muted, #9aa3c4);
  white-space: nowrap;
}

.fz-set-theme-select option {
  background: #0b0f1e;
  color: #eef1fb;
  padding: 8px 12px;
}

.fz-set-theme-select:focus-visible {
  border-color: var(--page-accent, #8a9bb8);
}

/* --- DATA MANAGEMENT --- */
.fz-set-data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.fz-set-data-row:last-child {
  border-bottom: none;
}

.fz-set-data-row--danger .fz-set-data-label {
  color: #ff5555;
}

.fz-set-data-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fz-set-data-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-text, #eef1fb);
}

.fz-set-data-desc {
  font-size: 12px;
  color: var(--ink-muted, #9aa3c4);
}

.fz-set-btn-danger {
  background: rgba(255, 85, 85, 0.1);
  border-color: rgba(255, 85, 85, 0.3);
  color: #ff5555;
}

.fz-set-btn-danger:hover {
  background: rgba(255, 85, 85, 0.2);
  border-color: #ff5555;
}

/* --- DEBUG SECTION --- */
.fz-set-debug-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.fz-set-debug-subsection {
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.fz-set-debug-subtitle {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-muted, #9aa3c4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Validation results */
.fz-set-validate-results {
  margin-top: 8px;
  padding: 12px;
  border-radius: var(--radius-md, 12px);
  font-size: 13px;
  font-family: var(--font-mono, monospace);
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
}

.fz-set-validate-results.valid {
  background: rgba(0, 200, 100, 0.06);
  border: 1px solid rgba(0, 200, 100, 0.2);
  color: #4ade80;
}

.fz-set-validate-results.invalid {
  background: rgba(255, 85, 55, 0.06);
  border: 1px solid rgba(255, 85, 55, 0.2);
  color: #ff8866;
}

/* Storage grid */
.fz-set-storage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.fz-set-storage-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-sm, 8px);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.fz-set-storage-key {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-text, #eef1fb);
  word-break: break-all;
}

.fz-set-storage-size {
  font-size: 10px;
  font-family: var(--font-mono, monospace);
  color: var(--ink-muted, #9aa3c4);
}

/* Granular reset buttons */
.fz-set-granular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.fz-set-granular-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink-text, #eef1fb);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body, sans-serif);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.fz-set-granular-btn:hover {
  background: rgba(255, 85, 85, 0.08);
  border-color: rgba(255, 85, 85, 0.2);
  color: #ff8866;
}

.fz-set-granular-count {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--ink-muted, #9aa3c4);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* Raw JSON viewer */
.fz-set-raw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.fz-set-raw-json {
  background: rgba(11, 15, 30, 0.8);
  border: 1px solid var(--ink-line, rgba(233, 238, 255, 0.08));
  border-radius: var(--radius-md, 12px);
  padding: 16px;
  font-size: 12px;
  font-family: var(--font-mono, "Space Mono", monospace);
  color: var(--ink-text, #eef1fb);
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* --- MODAL --- */
.fz-set-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fz-set-fade 0.2s ease;
}

/* CRITICAL: the [hidden] attribute selector has HIGHER specificity
   than the bare .fz-set-modal-overlay class selector above (two
   selector components vs one), so this rule reliably wins and
   forces display:none whenever JS sets overlay.hidden = true --
   regardless of stylesheet load order. Without this, the browser's
   default `[hidden] { display: none }` UA-stylesheet rule ties in
   specificity with our class rule and loses because our stylesheet
   loads after the UA stylesheet, so the modal would stay visually
   visible (display:flex) even while hidden=true in the DOM. */
.fz-set-modal-overlay[hidden] {
  display: none;
}

@keyframes fz-set-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fz-set-modal {
  background: rgba(11, 15, 30, 0.98);
  border: 1px solid var(--ink-line, rgba(233, 238, 255, 0.1));
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-lg, 24px);
  max-width: 400px;
  width: calc(100% - 32px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: fz-set-slide 0.3s ease-out;
}

@keyframes fz-set-slide {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.fz-set-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-text, #eef1fb);
  margin-bottom: 8px;
}

.fz-set-modal-desc {
  font-size: 14px;
  color: var(--ink-muted, #9aa3c4);
  line-height: 1.5;
  margin-bottom: 20px;
}

.fz-set-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Nation theme preview mobile */
.fz-set-theme-preview-colors {
  flex-direction: column;
  gap: 10px;
}

/* --- MOBILE --- */
@media (max-width: 767px) {
  .fz-set-card {
    padding: var(--space-md, 16px);
  }

  .fz-set-profile-row {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }

  .fz-set-profile-name-row {
    justify-content: center;
  }

  .fz-set-name-input {
    max-width: 180px;
  }

  .fz-set-profile-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .fz-set-pref-row,
  .fz-set-data-row,
  .fz-set-debug-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .fz-set-pref-row > label,
  .fz-set-data-row > button,
  .fz-set-data-row > label,
  .fz-set-debug-row > button {
    align-self: flex-end;
  }

  .fz-set-level-bar {
    flex-direction: column;
    gap: 4px;
  }

  .fz-set-level-bar-text {
    font-size: 11px;
  }

  .fz-set-granular-grid {
    grid-template-columns: 1fr 1fr;
  }

  .fz-set-storage-grid {
    grid-template-columns: 1fr;
  }

  .fz-set-raw-json {
    font-size: 10px;
    padding: 12px;
  }
}

@media (max-width: 380px) {
  .fz-set-profile-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .fz-set-granular-grid {
    grid-template-columns: 1fr;
  }
}
