/* QAP Estudo — Sistema Visual (Nunito + Operacional Executivo: Verde-Petróleo, Sidebar Escura & Ouro Pontual) */

/* Variáveis de tema: Modo Escuro Grafite Carbono Neutro (#1E2224) */
:root {
  color-scheme: dark;
  --bg-app: #1e2224;
  --bg-sidebar: #171b1d;
  --bg-topbar: #1a1e20;
  --bg-card: #262b2e;
  --bg-card-alt: #2e3438;
  --bg-input: #1d2123;
  --border-main: #353c40;
  --border-subtle: #444d52;
  --text-primary: #f1f5f5;
  --text-secondary: #ced6d8;
  --text-muted: #909ca0;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-text: #2dd4bf;
  --accent-soft: rgba(20, 184, 166, 0.14);
  --accent-border: rgba(45, 212, 191, 0.32);
  --gold: #e0b454;
  --gold-soft: rgba(224, 180, 84, 0.12);
  --gold-border: rgba(224, 180, 84, 0.32);
  --text-success: #34d399;
  --text-warning: #fbbf24;
  --text-danger: #f87171;
  --text-info: #2dd4bf;
}

/* Variáveis de tema: Modo Claro Pedra Suave (Padrão) + Sidebar Escura Fixa */
html.light-theme {
  color-scheme: light;
  --bg-app: #f4f5f3;
  --bg-sidebar: #182224;
  --bg-topbar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-alt: #f6f7f5;
  --bg-input: #ffffff;
  --border-main: #e4e7e4;
  --border-subtle: #cfd6d4;
  --text-primary: #141b1d;
  --text-secondary: #3c484b;
  --text-muted: #687578;
  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-text: #0f766e;
  --accent-soft: #edf7f6;
  --accent-border: #b8ded9;
  --gold: #b48224;
  --gold-soft: #fbf7ed;
  --gold-border: #e7d8b4;
  --text-success: #059669;
  --text-warning: #b45309;
  --text-danger: #dc2626;
  --text-info: #0f766e;
}

/* Ajustes semânticos de contraste (WCAG AA) */
html:not(.light-theme) .text-red-500 { color: var(--text-danger); }
html:not(.light-theme) .text-emerald-500 { color: var(--text-success); }
html:not(.light-theme) .text-teal-500,
html:not(.light-theme) .text-teal-600 { color: var(--accent-text); }
html:not(.light-theme) .text-amber-500 { color: var(--text-warning); }

html.light-theme .text-emerald-500 { color: var(--text-success) !important; }
html.light-theme .text-red-500 { color: var(--text-danger) !important; }
html.light-theme .text-amber-500 { color: var(--text-warning) !important; }
html.light-theme .text-teal-500,
html.light-theme .text-teal-600 { color: var(--accent-text) !important; }
html.light-theme .hover\:text-teal-500:hover,
html.light-theme .hover\:text-teal-600:hover { color: var(--accent-text) !important; }

/* Verde-Petróleo fechado (#0F766E) nos CTAs sólidos do Modo Claro */
html.light-theme .bg-teal-600 { background-color: #0f766e; }
html.light-theme .hover\:bg-teal-500:hover { background-color: #115e59; }
html.light-theme .next-study-hero .bg-teal-600 { background-color: #0d9488; }
html.light-theme .next-study-hero .hover\:bg-teal-500:hover { background-color: #14b8a6; }

html.light-theme .bg-emerald-500\/15,
html.light-theme .bg-emerald-500\/20 { background-color: rgba(5, 150, 105, 0.10); }
html.light-theme .bg-amber-500\/15,
html.light-theme .bg-amber-500\/20 { background-color: rgba(217, 119, 6, 0.11); }
html.light-theme .bg-red-500\/15,
html.light-theme .bg-red-500\/20 { background-color: rgba(220, 38, 38, 0.09); }
html.light-theme .bg-teal-500\/15,
html.light-theme .bg-teal-500\/20 { background-color: rgba(15, 118, 110, 0.10); }

/* Badges semânticos de desempenho (Ruim / Regular / Bom) */
.perf-good { background-color: rgba(16, 185, 129, 0.16); color: var(--text-success); border-color: rgba(16, 185, 129, 0.34); }
.perf-regular { background-color: rgba(245, 158, 11, 0.17); color: var(--text-warning); border-color: rgba(245, 158, 11, 0.36); }
.perf-bad { background-color: rgba(239, 68, 68, 0.16); color: var(--text-danger); border-color: rgba(239, 68, 68, 0.34); }
.perf-neutral { background-color: var(--bg-card-alt); color: var(--text-muted); border-color: var(--border-main); }

html.light-theme .perf-good { background-color: #ecfdf5; color: #047857; border-color: #a7f3d0; }
html.light-theme .perf-regular { background-color: #fffbeb; color: #b45309; border-color: #fde68a; }
html.light-theme .perf-bad { background-color: #fef2f2; color: #b91c1c; border-color: #fecaca; }

html.light-theme .theme-card {
  box-shadow: 0 2px 10px rgba(15, 23, 25, 0.04), 0 1px 2px rgba(15, 23, 25, 0.02);
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Números alinhados na própria Nunito */
.font-mono {
  font-family: 'Nunito', system-ui, sans-serif !important;
  font-variant-numeric: tabular-nums;
}

.timer-digits {
  font-family: 'Nunito', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.theme-topbar { background-color: var(--bg-topbar); border-color: var(--border-main); }
.theme-card { background-color: var(--bg-card); border-color: var(--border-main); }
.theme-card-alt { background-color: var(--bg-card-alt); border-color: var(--border-main); }
.theme-input { background-color: var(--bg-input); border-color: var(--border-subtle); color: var(--text-primary); }
.theme-text-primary { color: var(--text-primary); }
.theme-text-secondary { color: var(--text-secondary); }
.theme-text-muted { color: var(--text-muted); }
.hover-theme-primary:hover { color: var(--text-primary); }
.theme-border { border-color: var(--border-main); }
.theme-accent-text { color: var(--accent-text); }
.theme-accent-bg { background-color: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-text); }
.theme-gold-text { color: var(--gold); }
.theme-gold-bar { background-color: var(--gold); }
.theme-accent-bar { background-color: var(--accent-text); }

/* Botão Dourado Executivo (ex.: Replanejar) */
.btn-gold-exec {
  background-color: #c99738;
  color: #141b1d;
  box-shadow: 0 4px 12px rgba(201, 151, 56, 0.24);
}
.btn-gold-exec:hover {
  background-color: #d8aa4e;
}
html.light-theme .btn-gold-exec {
  background-color: #b48224;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(180, 130, 36, 0.24);
}
html.light-theme .btn-gold-exec:hover {
  background-color: #9a6e1c;
}

/* Sidebar Executiva Escura (recolhimento suave sem saltos) */
#appSidebar {
  position: relative;
}
#topBarDateLabel {
  color: #ffffff;
}
html.light-theme #topBarDateLabel {
  color: var(--text-primary);
}
#fsProgressBar {
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.55s ease, background 0.55s ease;
}

@media (min-width: 768px) {
  #appSidebar {
    width: 256px;
    transition: width 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  }
  #appSidebar .sidebar-inner {
    overflow-x: hidden;
  }
  #appSidebar .sidebar-collapsible-text {
    overflow: hidden;
    white-space: nowrap;
    max-width: 210px;
    opacity: 1;
    transform: translateX(0);
    transition:
      max-width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.22s ease,
      transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
      margin 0.3s ease;
  }
  #appSidebar .sidebar-collapsible-block {
    overflow: hidden;
    max-height: 64px;
    opacity: 1;
    transition:
      max-height 0.3s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.2s ease,
      margin 0.3s ease;
  }
  #appSidebar .nav-btn {
    transition:
      padding 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      gap 0.32s cubic-bezier(0.22, 1, 0.36, 1),
      background-color 0.18s ease,
      color 0.18s ease;
  }
  #appSidebar .sidebar-profile-box,
  #appSidebar .sidebar-cloud-box {
    transition: padding 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  }
  #appSidebar.sidebar-collapsed {
    width: 76px !important;
  }
  #appSidebar.sidebar-collapsed .sidebar-collapsible-text {
    max-width: 0 !important;
    opacity: 0 !important;
    transform: translateX(-8px);
    margin: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-width: 0 !important;
    pointer-events: none;
  }
  #appSidebar.sidebar-collapsed .sidebar-collapsible-block {
    max-height: 0 !important;
    opacity: 0 !important;
    margin-top: 0 !important;
    pointer-events: none;
  }
  #appSidebar.sidebar-collapsed .sidebar-brand-row {
    padding-left: 18px;
    padding-right: 18px;
    gap: 0;
  }
  #appSidebar.sidebar-collapsed .sidebar-profile-box {
    padding-left: 20px;
    padding-right: 20px;
  }
  #appSidebar.sidebar-collapsed .sidebar-profile-row {
    gap: 0;
  }
  #appSidebar.sidebar-collapsed .nav-btn {
    gap: 0;
    padding-left: 20px;
    padding-right: 20px;
    position: relative;
  }
  #appSidebar.sidebar-collapsed .nav-btn > div {
    gap: 0;
  }
  #appSidebar.sidebar-collapsed #navReviewBadge {
    position: absolute;
    top: 4px;
    right: 6px;
    padding: 0 4px;
    font-size: 9px;
    line-height: 14px;
  }
  #appSidebar.sidebar-collapsed .sidebar-cloud-box {
    padding: 10px 8px;
  }
  #appSidebar.sidebar-collapsed .sidebar-cloud-row {
    justify-content: center;
    gap: 0;
  }
  #appSidebar.sidebar-collapsed #sidebarCollapseIcon {
    transform: rotate(180deg);
  }
}

/* Timer editável (clique no visor) & linha tracejada executiva */
.timer-dashed-divider {
  border-top: 2px dashed var(--accent-text);
  opacity: 0.72;
}
.timer-clickable {
  cursor: pointer;
  border-radius: 14px;
  padding: 2px 10px;
  transition: background-color 0.16s ease, color 0.16s ease;
}
.timer-clickable:hover {
  background-color: var(--accent-soft);
}
.timer-inline-input {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--accent-text);
  border-radius: 14px;
  text-align: center;
  outline: none;
  font-family: 'Nunito', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
.theme-sidebar {
  background-color: var(--bg-sidebar);
  border-color: #243336;
  color: #f1f5f5;
}
html:not(.light-theme) .theme-sidebar {
  border-color: #2b3135;
}
.theme-sidebar .theme-border { border-color: #243336; }
html:not(.light-theme) .theme-sidebar .theme-border { border-color: #2b3135; }
.theme-sidebar .theme-text-primary { color: #f1f5f5; }
.theme-sidebar .theme-text-secondary { color: #cedad9; }
.theme-sidebar .theme-text-muted { color: #8da2a6; }
.theme-sidebar .hover-theme-primary:hover { color: #ffffff; }
.theme-sidebar .theme-card-alt { background-color: #202d30; border-color: #2b3c40; }
.theme-sidebar .theme-card { background-color: #202d30; border-color: #2e4044; }
html:not(.light-theme) .theme-sidebar .theme-card-alt,
html:not(.light-theme) .theme-sidebar .theme-card {
  background-color: #202629;
  border-color: #30383c;
  box-shadow: none;
}
html.light-theme .theme-sidebar .theme-card { box-shadow: none; }
.theme-sidebar .theme-accent-text { color: #5eead4 !important; }
.theme-sidebar .theme-accent-bg {
  background-color: rgba(20, 184, 166, 0.16);
  border-color: rgba(45, 212, 191, 0.34);
  color: #5eead4;
}
.theme-sidebar .text-red-500 { color: #f87171 !important; }
.theme-sidebar .group:hover .group-hover\:text-teal-600 { color: #5eead4 !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(144, 156, 160, 0.35); border-radius: 9999px; }

/* Estado ativo da navegação lateral (filete esquerdo 3px sem deslocar layout) */
.nav-active,
html.light-theme .nav-active {
  background: rgba(20, 184, 166, 0.14);
  color: #5eead4 !important;
  font-weight: 800;
  box-shadow: inset 3px 0 0 #14b8a6;
}

/* Avatar circular de perfil */
.profile-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  overflow: hidden;
  background: linear-gradient(135deg, #0f766e 0%, #14b8a6 100%);
  color: #ffffff;
  font-weight: 800;
  user-select: none;
  flex-shrink: 0;
}
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Overlay de transição pós-login (sem bordas, fundo sólido da paleta escura) */
#authGuardSplash {
  background-color: #1e2224;
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.45s ease;
  will-change: opacity;
}
#authGuardSplash.splash-fading-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
#authGuardGif {
  display: block;
  border: 0;
  outline: 0;
  box-shadow: none;
  background: transparent;
  -webkit-mask-image: radial-gradient(ellipse 78% 76% at 50% 50%, #000 68%, transparent 100%);
  mask-image: radial-gradient(ellipse 78% 76% at 50% 50%, #000 68%, transparent 100%);
}

/* Animação de entrada suave pós-login */
@keyframes qapFadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.qap-enter-anim {
  animation: qapFadeSlideIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes qapToastBar {
  from { width: 100%; }
  to { width: 0%; }
}
.qap-welcome-bar {
  animation: qapToastBar 3.6s linear forwards;
}

/* Remove setas nativas dos inputs numéricos para evitar cortes visuais */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="color"].color-swatch-input {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
input[type="color"].color-swatch-input::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"].color-swatch-input::-webkit-color-swatch {
  border: 2px solid rgba(144, 156, 160, 0.45);
  border-radius: 10px;
}

@keyframes tourTargetBlink {
  0%, 100% {
    box-shadow: 0 0 0 3px #14b8a6, 0 0 0 0 rgba(20, 184, 166, 0.60), 0 0 22px rgba(20, 184, 166, 0.35);
  }
  50% {
    box-shadow: 0 0 0 4px #e0b454, 0 0 0 11px rgba(224, 180, 84, 0), 0 0 30px rgba(224, 180, 84, 0.45);
  }
}

@keyframes tourCardBlink {
  0%, 100% {
    border-color: #14b8a6;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45), 0 0 0 2px rgba(20, 184, 166, 0.35);
  }
  50% {
    border-color: #e0b454;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.50), 0 0 0 5px rgba(224, 180, 84, 0.32);
  }
}

@keyframes tourCardPop {
  0% { transform: scale(0.97); opacity: 0.78; }
  50% { transform: scale(1.015); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.tour-highlight {
  position: relative;
  z-index: 45;
  border-radius: 16px;
  animation: tourTargetBlink 1.25s ease-in-out infinite !important;
}

#tourCard {
  transition: top 0.34s cubic-bezier(0.22, 1, 0.36, 1), left 0.34s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease;
  will-change: top, left;
}

#tourCard.tour-card-active {
  animation: tourCardBlink 1.4s ease-in-out infinite;
}

#tourCard.tour-card-step-pop {
  animation: tourCardPop 0.34s ease-out, tourCardBlink 1.4s ease-in-out 0.34s infinite;
}

.tour-arrow {
  position: absolute;
  width: 14px;
  height: 14px;
  background-color: var(--bg-card);
  transform: rotate(45deg);
  pointer-events: none;
  z-index: -1;
}

.tour-arrow-top {
  top: -8px;
  border-top: 2px solid #14b8a6;
  border-left: 2px solid #14b8a6;
}

.tour-arrow-bottom {
  bottom: -8px;
  border-bottom: 2px solid #14b8a6;
  border-right: 2px solid #14b8a6;
}

.tour-arrow-left {
  left: -8px;
  border-bottom: 2px solid #14b8a6;
  border-left: 2px solid #14b8a6;
}

.tour-arrow-right {
  right: -8px;
  border-top: 2px solid #14b8a6;
  border-right: 2px solid #14b8a6;
}

/* Destaque do próximo bloco de estudo (Card Escuro Petróleo Executivo em ambos os temas) */
.next-study-hero {
  background: linear-gradient(135deg, #1e2c2e 0%, #243033 100%);
  border: 1.5px solid #32484c;
  border-left: 4px solid #14b8a6;
  color: #f1f5f5;
}
.next-study-hero .hero-title { color: #ffffff; }
.next-study-hero .hero-sub { color: #b9ccce; }
.next-study-hero .hero-pill { background: rgba(20, 184, 166, 0.18); color: #5eead4; }
.next-study-hero .hero-badge-next { background: rgba(20, 184, 166, 0.22); color: #5eead4; }
.next-study-hero .hero-divider { border-color: rgba(255, 255, 255, 0.12); }
.next-study-hero .hero-skip-btn { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16); color: #eaf2f2; }
.next-study-hero .hero-skip-btn:hover { background: rgba(255, 255, 255, 0.15); }
.next-study-hero .hero-track { background: rgba(255, 255, 255, 0.14); }

html.light-theme .next-study-hero {
  background: linear-gradient(135deg, #182528 0%, #1f3134 100%);
  border: 1.5px solid #2b4246;
  border-left: 4px solid #14b8a6;
  color: #f1f5f5;
  box-shadow: 0 6px 20px rgba(24, 34, 36, 0.14);
}
html.light-theme .next-study-hero .hero-title { color: #ffffff; }
html.light-theme .next-study-hero .hero-sub { color: #b9ccce; }
html.light-theme .next-study-hero .hero-pill { background: rgba(20, 184, 166, 0.18); color: #5eead4; }
html.light-theme .next-study-hero .hero-badge-next { background: rgba(20, 184, 166, 0.22); color: #5eead4; }
html.light-theme .next-study-hero .hero-divider { border-color: rgba(255, 255, 255, 0.12); }
html.light-theme .next-study-hero .hero-skip-btn { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); color: #eaf2f2; }
html.light-theme .next-study-hero .hero-skip-btn:hover { background: rgba(255, 255, 255, 0.16); }
html.light-theme .next-study-hero .hero-track { background: rgba(255, 255, 255, 0.14); }

/* Cartão de contagem regressiva da prova (Toque Ouro/Latão Executivo) */
.exam-countdown-card {
  background: var(--bg-card);
  border-color: var(--gold-border);
}
.exam-countdown-right {
  background: linear-gradient(135deg, rgba(224, 180, 84, 0.15) 0%, rgba(180, 130, 36, 0.07) 100%);
  border-left: 1px solid var(--gold-border);
}
.exam-countdown-number {
  color: var(--gold);
}
html.light-theme .exam-countdown-card {
  background: #ffffff;
  border-color: var(--gold-border);
  box-shadow: 0 2px 10px rgba(180, 130, 36, 0.07);
}
html.light-theme .exam-countdown-right {
  background: linear-gradient(135deg, #fbf7ed 0%, #f6eed9 100%);
  border-left: 1px solid var(--gold-border);
}
html.light-theme .exam-countdown-number {
  color: var(--gold);
}

.donut-tooltip {
  background: #171b1d;
  color: #f1f5f5;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.week-block-card {
  color: #141b1d;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.week-block-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 25, 0.12);
}

/* Tela cheia do cronômetro */
#fullscreenTimerOverlay {
  background: radial-gradient(circle at 50% 35%, #262b2e 0%, #171b1d 78%);
}
html.light-theme #fullscreenTimerOverlay {
  background: radial-gradient(circle at 50% 35%, #ffffff 0%, #edf1ef 85%);
}

.subj-select-card { transition: all 0.16s ease; }

/* Escala de 5 pontos (Conhecimento e Peso na Prova) */
.scale-dot {
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  border: 2px solid var(--border-subtle);
  background: var(--bg-card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.16s ease;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.scale-dot:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}
.scale-dot.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.24);
}
.scale-line {
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--border-main);
  transform: translateY(-50%);
  z-index: 1;
}

.subj-select-card.selected {
  background-color: var(--accent-soft);
  border-color: var(--accent);
}
