/* ============================================
   Prova FEBRASGO 2026 — Mobile-First Styles
   ============================================ */

/* === Base Reset === */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
  line-height: 1.6;
  overscroll-behavior-y: none;
}

/* === Safe Area (notch) === */
.safe-area-top {
  height: env(safe-area-inset-top, 0px);
}

.safe-area-inset-top {
  height: env(safe-area-inset-top, 0px);
}

.safe-area-inset-bottom {
  height: env(safe-area-inset-bottom, 0px);
}

/* === Touch Targets (min 44px) === */
.touch-target {
  min-height: 44px;
  min-width: 44px;
}

/* === Scrollbar (desktop) === */
@media (min-width: 768px) {
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  ::-webkit-scrollbar-track {
    background: #F5F7FA;
  }

  ::-webkit-scrollbar-thumb {
    background: #C4CAD0;
    border-radius: 3px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #A0A8B0;
  }
}

/* === Header Glass === */
.header-glass {
  background: linear-gradient(135deg, #003366 0%, #004080 50%, #003366 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 20px rgba(0, 51, 102, 0.3);
}

/* === Glass Morphism === */
.glass-bg {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* === Nav Links (desktop) === */
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  transition: all 0.2s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* === Bottom Navigation (mobile) === */
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  font-size: 10px;
  font-weight: 500;
  color: #666;
  transition: all 0.2s;
  padding: 8px 4px;
  min-height: 56px;
  position: relative;
}

.bottom-nav-item svg {
  transition: all 0.2s;
}

.bottom-nav-item.active {
  color: #003366;
}

.bottom-nav-item.active svg {
  color: #003366;
  transform: scale(1.1);
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: #003366;
  border-radius: 0 0 3px 3px;
}

/* === Sidebar (desktop) === */
.sidebar-block {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  color: #333;
  transition: all 0.2s;
  text-align: left;
}

.sidebar-block:hover {
  background: #F5F7FA;
}

.sidebar-block.active {
  background: #EBF4FF;
  color: #0066CC;
  font-weight: 500;
}

.sidebar-topic {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  color: #333;
  transition: all 0.2s;
  text-align: left;
}

.sidebar-topic:hover {
  background: #F5F7FA;
}

.sidebar-topic.active {
  background: #EBF4FF;
  color: #0066CC;
  font-weight: 500;
}

/* === Progress Dots === */
.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.progress-dot.not-started { background: #D1D5DB; }
.progress-dot.weak { background: #CC0000; }
.progress-dot.medium { background: #F59E0B; }
.progress-dot.strong { background: #00A651; }

/* === Cards === */
.card {
  background: #FFFFFF;
  border-radius: 12px;
  border: 1px solid #E0E4E8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
  transition: box-shadow 0.2s, transform 0.2s;
  overflow: hidden;
}

@media (hover: hover) {
  .card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  }
}

.card-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #E0E4E8;
  font-weight: 600;
  font-size: 0.875rem;
}

.card-body {
  padding: 1rem;
}

@media (min-width: 768px) {
  .card-header {
    padding: 1rem 1.25rem;
  }
  .card-body {
    padding: 1.25rem;
  }
}

/* === Flashcard 3D Flip === */
.flashcard-container {
  perspective: 1200px;
  width: 100%;
  height: 280px;
  touch-action: none;
}

@media (min-width: 768px) {
  .flashcard-container {
    max-width: 560px;
    height: 340px;
    margin: 0 auto;
  }
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  cursor: pointer;
  touch-action: none;
}

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  border: 2px solid #E0E4E8;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
}

.flashcard-front {
  background: linear-gradient(160deg, #FFFFFF 0%, #F8FAFC 100%);
}

.flashcard-back {
  background: linear-gradient(160deg, #F0FFF4 0%, #FFFFFF 100%);
  transform: rotateY(180deg);
}

/* === Quiz Options === */
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 2px solid #E0E4E8;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  min-height: 44px;
}

.quiz-option:active:not(.disabled) {
  transform: scale(0.98);
}

.quiz-option.selected {
  border-color: #0066CC;
  background: #EBF4FF;
}

.quiz-option.correct {
  border-color: #00A651;
  background: #ECFDF5;
}

.quiz-option.incorrect {
  border-color: #CC0000;
  background: #FEF2F2;
}

.quiz-option.disabled {
  cursor: default;
}

.quiz-option .option-letter {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8125rem;
  flex-shrink: 0;
  background: #F5F7FA;
  color: #333;
  border: 2px solid #E0E4E8;
  transition: all 0.2s;
}

.quiz-option.correct .option-letter {
  background: #00A651;
  color: white;
  border-color: #00A651;
}

.quiz-option.incorrect .option-letter {
  background: #CC0000;
  color: white;
  border-color: #CC0000;
}

/* === Heat Map === */
.heatmap-cell {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

@media (min-width: 768px) {
  .heatmap-cell {
    width: 2.5rem;
    height: 2.5rem;
  }
}

.heatmap-cell:active {
  transform: scale(1.15);
}

.heatmap-cell.not-started { background: #E5E7EB; color: #9CA3AF; }
.heatmap-cell.weak { background: #FEE2E2; color: #991B1B; }
.heatmap-cell.medium { background: #FEF3C7; color: #92400E; }
.heatmap-cell.strong { background: #D1FAE5; color: #065F46; }

/* === Progress Bar === */
.progress-bar {
  height: 6px;
  border-radius: 3px;
  background: #E0E4E8;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* === Countdown (Flip Clock style) === */
.countdown-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: #F5F7FA;
  border-radius: 10px;
  min-width: 56px;
  border: 1px solid #E0E4E8;
}

.countdown-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #003366;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.countdown-label {
  font-size: 0.625rem;
  color: #666666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

@media (min-width: 768px) {
  .countdown-value {
    font-size: 1.75rem;
  }
  .countdown-segment {
    padding: 0.625rem 1rem;
    min-width: 64px;
  }
}

/* === Toast Notifications === */
.toast {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  color: white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 360px;
}

.toast-success { background: #00A651; }
.toast-error { background: #CC0000; }
.toast-info { background: #0066CC; }

.toast-icon {
  font-weight: 700;
  font-size: 1rem;
}

/* === Stat Cards === */
.stat-card {
  text-align: center;
  padding: 1.25rem 1rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: #666666;
  font-weight: 500;
}

@media (min-width: 768px) {
  .stat-card {
    padding: 1.5rem;
  }
  .stat-value {
    font-size: 2rem;
  }
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  min-height: 44px;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #003366;
  color: white;
}
.btn-primary:hover { background: #002244; }

.btn-secondary {
  background: #0066CC;
  color: white;
}
.btn-secondary:hover { background: #0052A3; }

.btn-accent {
  background: #00A651;
  color: white;
}
.btn-accent:hover { background: #008C44; }

.btn-error {
  background: #CC0000;
  color: white;
}
.btn-error:hover { background: #A30000; }

.btn-outline {
  background: transparent;
  border: 2px solid #E0E4E8;
  color: #333;
}
.btn-outline:hover {
  border-color: #0066CC;
  color: #0066CC;
  background: #F0F7FF;
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  min-height: 36px;
}

/* === Rating Buttons (flashcard) === */
.rating-btn {
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.8125rem;
  transition: all 0.2s;
  cursor: pointer;
  border: 2px solid transparent;
  min-height: 44px;
}

.rating-btn:active { transform: scale(0.95); }

.rating-btn.again {
  background: #FEE2E2;
  color: #991B1B;
  border-color: #FECACA;
}

.rating-btn.hard {
  background: #FED7AA;
  color: #9A3412;
  border-color: #FDBA74;
}

.rating-btn.good {
  background: #FEF3C7;
  color: #92400E;
  border-color: #FDE68A;
}

.rating-btn.easy {
  background: #D1FAE5;
  color: #065F46;
  border-color: #A7F3D0;
}

/* === Admin Table === */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  background: #F5F7FA;
  padding: 0.625rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  text-align: left;
  border-bottom: 2px solid #E0E4E8;
}

.admin-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid #E0E4E8;
  font-size: 0.8125rem;
}

.admin-table tr:hover td {
  background: #F9FAFB;
}

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-error { background: #FEE2E2; color: #991B1B; }
.badge-info { background: #DBEAFE; color: #1E40AF; }

/* === Study Content (Markdown) === */
.study-content {
  line-height: 1.7;
  font-size: 0.9375rem;
}

@media (min-width: 768px) {
  .study-content {
    font-size: 1rem;
  }
}

.study-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 1.5rem 0 0.75rem;
  color: #003366;
}

.study-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.25rem 0 0.625rem;
  color: #003366;
  border-bottom: 2px solid #E0E4E8;
  padding-bottom: 0.5rem;
}

.study-content h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  color: #333;
}

.study-content p {
  margin-bottom: 0.75rem;
}

.study-content ul, .study-content ol {
  margin-bottom: 0.75rem;
  padding-left: 1.25rem;
}

.study-content li {
  margin-bottom: 0.25rem;
}

.study-content code {
  background: #F5F7FA;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.study-content pre {
  background: #F5F7FA;
  border: 1px solid #E0E4E8;
  border-radius: 8px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
}

.study-content blockquote {
  border-left: 4px solid #0066CC;
  padding-left: 1rem;
  margin: 1rem 0;
  color: #666;
  font-style: italic;
  background: #F8FAFC;
  padding: 0.75rem 1rem;
  border-radius: 0 8px 8px 0;
}

.study-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
}

.study-content th, .study-content td {
  border: 1px solid #E0E4E8;
  padding: 0.5rem 0.625rem;
  text-align: left;
}

.study-content th {
  background: #F5F7FA;
  font-weight: 600;
}

/* === FAB (Floating Action Button) === */
.fab-button {
  position: fixed;
  bottom: 84px;
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #003366;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 51, 102, 0.4);
  z-index: 40;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab-button:active {
  transform: scale(0.92);
}

@media (min-width: 768px) {
  .fab-button {
    bottom: 24px;
    right: 24px;
  }
}

/* === Bottom Sheet === */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
}

.bottom-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 20px 20px 0 0;
  max-height: 80vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: #D1D5DB;
  border-radius: 2px;
  margin: 12px auto;
}

.bottom-sheet-header {
  padding: 0 1.25rem 0.75rem;
  font-weight: 600;
  font-size: 1rem;
}

.bottom-sheet-content {
  padding: 0 1.25rem 1.25rem;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #E0E4E8;
}

.modal-header h3 {
  font-weight: 600;
  font-size: 1rem;
}

.modal-close-btn {
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.2s;
}

.modal-close-btn:hover {
  background: #F5F7FA;
}

.modal-body {
  padding: 1.25rem;
}

/* === Pull to Refresh === */
.pull-refresh-indicator {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: height 0.2s, opacity 0.2s;
  opacity: 0;
}

/* === Loading Spinner === */
.spinner {
  width: 1.75rem;
  height: 1.75rem;
  border: 3px solid #E0E4E8;
  border-top-color: #0066CC;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === Admin Tabs === */
.admin-tab {
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #666;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.admin-tab:hover { color: #333; }

.admin-tab.active {
  color: #003366;
  border-bottom-color: #003366;
}

/* === Bottom Navigation (Mobile) === */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: #FFFFFF;
  border-top: 1px solid #E0E4E8;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
  padding: 0.375rem 0.5rem;
  padding-bottom: calc(0.375rem + env(safe-area-inset-bottom));
}

@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
  }

  body {
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom));
  }

  footer {
    display: none;
  }
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.625rem;
  font-weight: 500;
  color: #9CA3AF;
  transition: all 0.2s;
  text-decoration: none;
  min-width: 3.5rem;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:active {
  transform: scale(0.9);
}

.bottom-nav-item.active {
  color: #003366;
  background: rgba(0, 51, 102, 0.06);
}

.bottom-nav-item.active svg {
  stroke-width: 2.5;
}

/* === Sidebar Topic Items === */
.sidebar-topic-number {
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  font-weight: 600;
  background: #F5F7FA;
  color: #666;
  flex-shrink: 0;
}

.sidebar-topic-title {
  flex: 1;
  min-width: 0;
}

.sidebar-topic-status {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #E0E4E8;
  flex-shrink: 0;
}

.sidebar-topic-status.done {
  background: #00A651;
}

/* === Glass Morphism === */
.glass-bg {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* === Toast Icons === */
.toast-icon {
  font-size: 1rem;
  font-weight: 700;
}

.toast-message {
  flex: 1;
}

/* === Fade transition === */
.fade-enter {
  opacity: 0;
  transform: translateY(8px);
}

.fade-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* === Mobile stat optimizations === */
@media (max-width: 640px) {
  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .card-header {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
  }

  .card-body {
    padding: 0.875rem;
  }

  .flashcard-container {
    height: 260px;
  }

  .countdown-value {
    font-size: 1.25rem;
  }

  .countdown-segment {
    padding: 0.375rem 0.625rem;
  }

  .heatmap-cell {
    width: 2rem;
    height: 2rem;
    font-size: 0.5rem;
  }
}

/* === XS Breakpoint helper === */
@media (min-width: 380px) {
  .xs\:block { display: block; }
}
