/* =====================================================
   DEEDO FLUÊNCIA — Design System
   ===================================================== */

/* --- Design Tokens --- */
:root {
  --sidebar-bg: #0C1427;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --sidebar-link: rgba(255,255,255,0.60);
  --sidebar-link-hover: #ffffff;
  --sidebar-hover-bg: rgba(255,255,255,0.07);
  --sidebar-active-bg: rgba(99,160,255,0.14);
  --sidebar-active-color: #93c5fd;
  --sidebar-label-color: rgba(255,255,255,0.28);
  --sidebar-divider: rgba(255,255,255,0.07);

  --accent: #3B82F6;
  --accent-dark: #2563EB;
  --accent-light: #EFF6FF;
  --accent-rgb: 59,130,246;

  --surface: #ffffff;
  --bg: #F1F5F9;
  --bg-2: #e8edf5;
  --text: #0F172A;
  --text-2: #1E293B;
  --text-muted: #475569; /* slate-600 — contraste WCAG AA confortável sobre branco */
  --border: #E2E8F0;

  --success: #10B981;
  --success-light: #ECFDF5;
  --success-text: #065f46;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --warning-text: #92400e;
  --danger: #EF4444;
  --danger-light: #FEF2F2;
  --danger-text: #991b1b;
  --info: #0EA5E9;
  --info-light: #F0F9FF;
  --info-text: #0c4a6e;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.09), 0 4px 6px -4px rgba(0,0,0,.05);

  --transition: 150ms ease;
  --transition-md: 220ms ease;

  /* Legacy compat */
  --app-primary: var(--accent);
  --app-surface: var(--surface);
  --app-body-bg: var(--bg);
  --app-border: var(--border);
  --app-text-muted: var(--text-muted);
  --app-shadow-lg: var(--shadow-lg);
  --app-radius: var(--radius);
  --app-radius-lg: var(--radius-lg);
  --app-card-bg: var(--surface);
  --app-transition: var(--transition);
}

/* --- Base --- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Outfit', 'Segoe UI', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 0.9375rem;
  line-height: 1.55;
}

/* =====================================================
   SIDEBAR
   ===================================================== */

.app-sidebar {
  background-color: var(--sidebar-bg) !important;
  width: var(--sidebar-width) !important;
  display: flex !important;
  flex-direction: column;
  border-right: none !important;
  padding: 0 !important;
}

@media (min-width: 992px) {
  .app-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    z-index: 1020 !important;
    transform: none !important;
    visibility: visible !important;
  }
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
  color: #fff;
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.015em;
  border-bottom: 1px solid var(--sidebar-divider);
  flex-shrink: 0;
  text-decoration: none;
}
.app-sidebar-brand:hover { color: #fff; }

.brand-icon {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #fff;
  flex-shrink: 0;
}

.app-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 8px;
  scrollbar-width: none;
}
.app-sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-label-color);
  padding: 14px 20px 5px;
  display: block;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 20px;
  color: var(--sidebar-link);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 450;
  transition: color var(--transition), background var(--transition);
  position: relative;
  line-height: 1.3;
}
.sidebar-nav-item .nav-icon {
  width: 16px;
  text-align: center;
  font-size: 0.78rem;
  flex-shrink: 0;
  opacity: 0.75;
}
.sidebar-nav-item:hover {
  color: var(--sidebar-link-hover);
  background-color: var(--sidebar-hover-bg);
}
.sidebar-nav-item.active {
  color: var(--sidebar-active-color);
  background-color: var(--sidebar-active-bg);
  font-weight: 500;
}
.sidebar-nav-item.active .nav-icon { opacity: 1; }
.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  background: var(--sidebar-active-color);
  border-radius: 0 3px 3px 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--sidebar-divider);
  margin: 6px 0;
}

.app-sidebar-footer {
  border-top: 1px solid var(--sidebar-divider);
  padding: 10px 12px;
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}
.sidebar-user-avatar {
  width: 30px;
  height: 30px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  line-height: 1.25;
}
.sidebar-user-role {
  font-size: 0.68rem;
  color: var(--sidebar-label-color);
  display: block;
  text-transform: capitalize;
}
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  background: none;
  border: none;
  color: var(--sidebar-link);
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: color var(--transition), background var(--transition);
  font-family: inherit;
  text-decoration: none;
}
.sidebar-logout i { font-size: 0.75rem; width: 14px; text-align: center; }
.sidebar-logout:hover {
  color: #fca5a5;
  background: rgba(239,68,68,0.12);
}

/* =====================================================
   APP WRAPPER & TOPBAR
   ===================================================== */

.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
@media (min-width: 992px) {
  .app-wrapper { margin-left: var(--sidebar-width); }
}

.app-topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.topbar-hamburger {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  line-height: 1;
  transition: color var(--transition), background var(--transition);
}
.topbar-hamburger:hover { color: var(--text); background: var(--bg); }

.topbar-brand-mobile {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
  text-decoration: none;
  flex: 1;
}
.topbar-brand-mobile:hover { color: var(--text); }

.topbar-breadcrumb { flex: 1; min-width: 0; }
.topbar-breadcrumb .breadcrumb {
  margin: 0;
  padding: 0;
  font-size: 0.8125rem;
}
.topbar-breadcrumb .breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }
.topbar-breadcrumb .breadcrumb-item a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.topbar-breadcrumb .breadcrumb-item a:hover { color: var(--accent); }
.topbar-breadcrumb .breadcrumb-item.active {
  color: var(--text-2);
  font-weight: 500;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-size: 0.8125rem;
  color: var(--text-2);
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  line-height: 1;
}
.topbar-user-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.08);
  color: var(--text);
}
.topbar-avatar {
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */

.app-main {
  flex: 1;
  padding: 28px 28px 36px;
}
@media (max-width: 767px) { .app-main { padding: 20px 16px 28px; } }

.skip-link {
  position: absolute;
  top: -100px;
  left: 0.5rem;
  z-index: 9999;
  padding: 0.4rem 0.875rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  text-decoration: none;
  transition: top var(--transition);
}
.skip-link:focus { top: 0.5rem; color: #fff; }

/* =====================================================
   BOOTSTRAP OVERRIDES
   ===================================================== */

/* Cards */
.card {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow);
  background: var(--surface);
  margin-bottom: 20px;
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}
.card-body { padding: 20px; }
.card-footer {
  background: transparent !important;
  border-top: 1px solid var(--border) !important;
  padding: 12px 20px;
}
.card-hover {
  transition: box-shadow var(--transition-md), transform var(--transition-md);
}
.card-hover:hover {
  box-shadow: var(--shadow-md) !important;
  transform: translateY(-2px);
}
.card-elevated { box-shadow: var(--shadow-md) !important; }
.card-outlined { box-shadow: none !important; }

/* Buttons */
.btn {
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  border-radius: var(--radius-sm) !important;
  font-size: 0.875rem;
  transition: all var(--transition);
  letter-spacing: 0;
  line-height: 1.5;
}
.btn-primary { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-dark) !important;
  border-color: var(--accent-dark) !important;
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.2) !important;
  color: #fff !important;
}
.btn-success { background: var(--success) !important; border-color: var(--success) !important; color: #fff !important; }
.btn-success:hover { background: #059669 !important; border-color: #059669 !important; box-shadow: 0 0 0 3px rgba(16,185,129,.2) !important; }
.btn-danger { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff !important; }
.btn-secondary { background: var(--bg) !important; border-color: var(--border) !important; color: var(--text-2) !important; }
.btn-secondary:hover { background: var(--bg-2) !important; color: var(--text) !important; }
.btn-outline-secondary { border-color: var(--border) !important; color: var(--text-2) !important; }
.btn-outline-secondary:hover { background: var(--bg) !important; border-color: var(--border) !important; color: var(--text) !important; }
.btn-sm { font-size: 0.8125rem !important; padding: 0.3rem 0.75rem !important; }
.btn-lg { font-size: 0.9375rem !important; padding: 0.6rem 1.25rem !important; }

/* Forms */
.form-control, .form-select {
  font-family: 'Outfit', sans-serif;
  border-radius: var(--radius-sm) !important;
  border-color: var(--border);
  font-size: 0.875rem;
  color: var(--text);
  padding: 0.5rem 0.75rem;
  background-color: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb),.1);
  color: var(--text);
  background-color: var(--surface);
}
.form-control::placeholder { color: #94a3b8; }
.form-label { font-size: 0.8125rem; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger) !important; }
.form-control.is-invalid:focus, .form-select.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.1) !important; }
.invalid-feedback { font-size: 0.78rem; color: var(--danger); }
.form-text { font-size: 0.78rem; color: var(--text-muted); }

/* Tables */
.table {
  font-size: 0.875rem;
  color: var(--text-2);
  --bs-table-bg: transparent;
  --bs-table-hover-bg: rgba(241,245,249,0.8);
  margin-bottom: 0;
}
.table thead th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border) !important;
  padding: 10px 16px;
  white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table-responsive {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
}

/* Badges */
.badge {
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 20px;
}
.bg-success { background: var(--success) !important; }
.bg-danger { background: var(--danger) !important; }
.bg-warning { background: var(--warning) !important; }
.bg-primary { background: var(--accent) !important; }

/* Alerts */
.alert {
  border-radius: var(--radius) !important;
  border: none !important;
  font-size: 0.875rem;
  padding: 12px 16px;
}
.alert-success { background: var(--success-light); color: var(--success-text); }
.alert-danger  { background: var(--danger-light);  color: var(--danger-text);  }
.alert-warning { background: var(--warning-light); color: var(--warning-text); }
.alert-info    { background: var(--info-light);    color: var(--info-text);    }

/* Modals */
.modal-content { border: none !important; border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-lg) !important; }
.modal-header { padding: 18px 22px 14px; border-bottom: 1px solid var(--border) !important; }
.modal-title { font-weight: 600; font-size: 0.9375rem; color: var(--text); }
.modal-body { padding: 18px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border) !important; }

/* Dropdowns */
.dropdown-menu {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  font-size: 0.875rem;
  padding: 6px;
}
.dropdown-item { border-radius: var(--radius-sm); padding: 7px 10px; color: var(--text-2); font-size: 0.875rem; transition: background var(--transition); }
.dropdown-item:hover { background: var(--bg); color: var(--text); }

/* Toasts */
.toast { border-radius: var(--radius) !important; font-size: 0.875rem; border: none !important; font-family: 'Outfit', sans-serif; }
.toast-container { z-index: 1090; }

/* Breadcrumb */
.breadcrumb { font-size: 0.8125rem; margin-bottom: 0; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }
.breadcrumb-item.active { color: var(--text-2); font-weight: 500; }

/* Progress */
.progress { border-radius: 20px; background: var(--bg-2); height: 6px; }
.progress-bar { background: var(--accent); border-radius: 20px; }

/* Pagination */
.page-link { color: var(--accent); border-color: var(--border); font-size: 0.875rem; padding: 6px 12px; border-radius: var(--radius-sm) !important; }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); }

/* =====================================================
   CUSTOM COMPONENTS
   ===================================================== */

/* Stat/Feature cards for dashboard */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition-md), transform var(--transition-md);
  height: 100%;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  margin-bottom: 16px;
}
.stat-card-icon.blue  { background: var(--accent-light);  color: var(--accent); }
.stat-card-icon.green { background: var(--success-light); color: var(--success); }
.stat-card-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-card-icon.red   { background: var(--danger-light);  color: var(--danger); }
.stat-card-icon.slate { background: var(--bg-2);          color: var(--text-muted); }
.stat-card-icon.violet { background: #f5f3ff;             color: #7c3aed; }

.stat-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 6px;
}
.stat-card-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.45;
  flex: 1;
}
.stat-card-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: gap var(--transition);
}
.stat-card-link:hover { color: var(--accent-dark); gap: 8px; }

/* Audio record button */
.record-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  font-size: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-md);
  border: none;
}
@media (max-width: 576px) { .record-btn { width: 72px; height: 72px; } }

/* ===== Recorder UI ===== */
.recorder-card .reading-text {
  font-size: 1.1rem;
  line-height: 1.75;
  max-height: 50vh;
  overflow-y: auto;
}

.recorder-card .word {
  display: inline;
  padding: 0 2px;
  border-radius: 4px;
  transition: background var(--transition), color var(--transition);
}
.recorder-card .word.read {
  background: var(--accent-light);
  color: var(--accent-dark);
}
.recorder-card .word.current {
  background: var(--warning-light);
  color: var(--warning-text);
  box-shadow: 0 0 0 2px var(--warning);
  animation: wordPulse 1.2s ease-in-out infinite;
}
@keyframes wordPulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--warning); }
  50%      { box-shadow: 0 0 0 4px rgba(245,158,11,.3); }
}

.timer-display {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: .5px;
}
.timer-display .timer-sep { color: var(--text-muted); margin: 0 .25rem; }
#timerElapsed { color: var(--danger); }
[data-state="paused"] #timerElapsed { color: var(--warning); }
[data-state="review"] #timerElapsed { color: var(--success); }

.meta-stats { display: flex; gap: .5rem; flex-wrap: wrap; }
.meta-stats .badge { padding: .5rem .75rem; font-size: .8rem; font-weight: 500; }

.recording-progress {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-2);
}
.recording-progress::-webkit-progress-bar { background: var(--bg-2); border-radius: 999px; }
.recording-progress::-webkit-progress-value { background: var(--success); transition: width var(--transition), background var(--transition-md); border-radius: 999px; }
.recording-progress::-moz-progress-bar { background: var(--success); border-radius: 999px; }
.recording-progress.is-warning::-webkit-progress-value { background: var(--warning); }
.recording-progress.is-warning::-moz-progress-bar { background: var(--warning); }
.recording-progress.is-danger::-webkit-progress-value { background: var(--danger); }
.recording-progress.is-danger::-moz-progress-bar { background: var(--danger); }

.waveform-wrap {
  padding: .5rem;
  background: var(--bg-2);
  border-radius: var(--radius);
}
.waveform-canvas {
  display: block;
  width: 100%;
  height: 70px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}
.speech-debug {
  padding: .4rem .6rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: .8rem;
  min-height: 1.6em;
  line-height: 1.4;
  word-break: break-word;
}
[data-state="paused"] .waveform-canvas { opacity: .5; }

.recording-dot {
  color: var(--danger);
  font-size: .7rem;
  animation: recPulse 1.2s ease-in-out infinite;
}
[data-state="paused"] .recording-dot { animation-play-state: paused; color: var(--warning); }
@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .25; }
}

.recorder-card .controls-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.recorder-card .controls-panel.d-none { display: none !important; }

.control-cluster {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
}
.control-btn {
  min-width: 120px;
  padding: .75rem 1.25rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border-radius: var(--radius);
  transition: transform var(--transition), box-shadow var(--transition);
}
.control-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.control-btn:active:not(:disabled) { transform: translateY(0); }
.control-btn .control-label { white-space: nowrap; }

.btn-group-final {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.btn-group-final .control-btn { min-width: 0; width: 100%; }
@media (max-width: 576px) {
  .btn-group-final { grid-template-columns: 1fr; }
  .control-btn { min-width: 0; width: 100%; }
}

.preview-player audio {
  width: 100%;
  border-radius: var(--radius);
  outline: none;
}

.recorder-card .hint-panel { margin-bottom: 1rem; }

/* Focus ring */
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:focus-visible { outline-offset: 1px; }

/* =====================================================
   GUEST / AUTH LAYOUT
   ===================================================== */

.auth-wrap { min-height: 100vh; display: flex; }

.auth-panel-left {
  width: 42%;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 40px;
  position: relative;
  overflow: hidden;
}
.auth-panel-left::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 280px;
  height: 280px;
  background: rgba(59,130,246,0.12);
  border-radius: 50%;
  pointer-events: none;
}
.auth-panel-left::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -60px;
  width: 220px;
  height: 220px;
  background: rgba(99,160,255,0.07);
  border-radius: 50%;
  pointer-events: none;
}
.auth-panel-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  padding: 40px 32px;
}
.auth-form-box { width: 100%; max-width: 380px; }

@media (max-width: 767px) {
  .auth-panel-left { display: none; }
  .auth-panel-right { padding: 32px 20px; background: var(--bg); }
  .auth-form-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
  }
}

/* =====================================================
   PRINT STYLES
   ===================================================== */

@media print {
  .app-sidebar, .app-topbar, .toast-container, .d-print-none { display: none !important; }
  .app-wrapper { margin-left: 0 !important; }
  .app-main { padding: 0 !important; }
  body { font-size: 10pt; color: #000; background: #fff; font-family: 'Outfit', 'Segoe UI', Arial, sans-serif; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; }
  .btn { display: none !important; }
  a { color: inherit; text-decoration: none; }

  @page { size: A4; margin: 1.5cm 2cm 1.5cm 2cm; }
  h1, h2, h3 { page-break-after: avoid; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  thead { display: table-header-group; }

  /* ── Print Report Layout ─────────────────────────────── */
  .print-report { font-size: 10pt; line-height: 1.5; color: #1a1a1a; }

  /* Header */
  .print-header-table { width: 100%; border-bottom: 3px solid #0C1427; padding-bottom: 12px; margin-bottom: 16px; border-collapse: collapse; }
  .print-header-logo { width: 120px; vertical-align: middle; padding-right: 16px; }
  .print-header-logo img { height: 60px; width: auto; }
  .print-header-title { vertical-align: middle; }
  .print-header-title h1 { font-size: 16pt; font-weight: 700; margin: 0 0 2px 0; color: #0C1427; letter-spacing: -0.02em; }
  .print-header-title p { font-size: 9pt; margin: 0; color: #555; text-transform: uppercase; letter-spacing: 0.05em; }

  /* Info table */
  .print-info-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px; }
  .print-info-table td { padding: 6px 12px; font-size: 9.5pt; border-bottom: 1px solid #e9ecef; width: 50%; }
  .print-info-table tr:last-child td { border-bottom: none; }

  /* Section title */
  .print-section-title { font-size: 11pt; font-weight: 700; color: #0C1427; border-bottom: 2px solid #0C1427; padding-bottom: 4px; margin: 18px 0 10px 0; text-transform: uppercase; letter-spacing: 0.03em; }

  /* KPI boxes */
  .print-kpi-table { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
  .print-kpi { text-align: center; border: 1px solid #dee2e6; padding: 10px 8px; width: 25%; }
  .print-kpi-value { display: block; font-size: 18pt; font-weight: 700; color: #0C1427; line-height: 1.2; }
  .print-kpi-label { display: block; font-size: 8pt; color: #555; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 2px; }
  .print-kpi-highlight { background: #0C1427; }
  .print-kpi-highlight .print-kpi-value { color: #fff; font-size: 12pt; }
  .print-kpi-highlight .print-kpi-label { color: #ccc; }
  .print-kpi-ref { font-size: 8pt; color: #777; margin: 0 0 12px 0; text-align: center; }

  /* Pedagogical table */
  .print-ped-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
  .print-ped-table td { padding: 7px 10px; font-size: 9.5pt; border-bottom: 1px solid #e9ecef; vertical-align: top; }
  .print-ped-label { width: 200px; font-weight: 600; color: #333; background: #f8f9fa; }
  .print-suggestions { margin: 0; padding-left: 18px; }
  .print-suggestions li { margin-bottom: 2px; }

  /* Transcription */
  .print-transcription { background: #f8f9fa; border: 1px solid #dee2e6; padding: 10px 14px; margin-bottom: 14px; }
  .print-transcription-label { font-size: 9pt; color: #555; margin: 0 0 6px 0; }
  .print-transcription-text { font-size: 10pt; font-style: italic; color: #333; margin: 0; line-height: 1.6; }

  /* Errors table */
  .print-errors-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
  .print-errors-table th { background: #0C1427; color: #fff; font-size: 8.5pt; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 10px; text-align: left; }
  .print-errors-table td { padding: 5px 10px; font-size: 9.5pt; border-bottom: 1px solid #e9ecef; }
  .print-errors-table tbody tr:nth-child(even) { background: #f8f9fa; }

  /* Signatures */
  .print-signature-table { width: 100%; border-collapse: collapse; margin-top: 50px; }
  .print-signature-table td { width: 50%; text-align: center; padding: 0 30px; vertical-align: bottom; }
  .print-signature-line { border-bottom: 1px solid #333; margin: 0 auto; width: 80%; margin-bottom: 6px; }
  .print-signature-name { font-size: 9pt; font-weight: 600; margin: 0; }
  .print-signature-role { font-size: 8pt; color: #666; margin: 0; }

  /* Footer */
  .print-footer { text-align: center; font-size: 7.5pt; color: #999; border-top: 1px solid #dee2e6; padding-top: 8px; margin-top: 24px; }
}

/* Card "Navegar por Escola e Turma" — links de turma dentro do accordion */
.report-classroom-link {
    color: var(--text);
    text-decoration: none;
    font-size: .85rem;
    border-radius: 6px;
    transition: background-color .15s ease, color .15s ease;
}
.report-classroom-link:hover {
    background-color: rgba(59, 130, 246, .08);
    color: var(--accent);
}
.report-classroom-link:hover i {
    color: var(--accent) !important;
}

/* ============================
   Componentes utilitários
   ============================ */

/* Page header (componente <x-app.page-header>) */
.page-header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1.5rem;
}
@media (min-width: 768px) {
    .page-header { flex-direction: row; align-items: center; }
}
.page-header-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.015em;
}
.page-header-subtitle {
    margin: .25rem 0 0;
    font-size: .8125rem;
    color: var(--text-muted);
}

/* Empty state (componente <x-app.empty-state>) */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}
.empty-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--bg-2);
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.empty-state-icon i {
    font-size: 1.5rem;
}
.empty-state-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 .25rem;
}
.empty-state-message {
    font-size: .875rem;
    color: var(--text-muted);
    margin: 0 0 1.5rem;
}
.empty-state-spacer { height: 1rem; }

/* Status badge (utilizar com cores semânticas) */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .25rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 500;
}
.status-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-badge-pending { background: var(--bg-2); color: var(--text-muted); }
.status-badge-processing { background: rgba(245, 158, 11, .12); color: #92400e; }
.status-badge-completed { background: var(--success-light); color: var(--success-text); }
.status-badge-error { background: rgba(239, 68, 68, .12); color: #991b1b; }
.status-badge-draft { background: var(--bg-2); color: var(--text-muted); }
.status-badge-in_progress { background: rgba(245, 158, 11, .12); color: #92400e; }
.status-badge-archived { background: rgba(15, 23, 42, .08); color: #334155; }

/* Utility: texto muted explícito (alternativa às utilidades Bootstrap quando precisamos do nosso token) */
.text-muted-strong { color: var(--text-muted) !important; }

/* ============================
   Defensivo: nunca renderizar backdrop do offcanvas no desktop.
   A sidebar é fixa via CSS, e a Bootstrap não deveria criar backdrop —
   mas em alguns cenários (resize cruzando breakpoint) ela teima.
   ============================ */
@media (min-width: 992px) {
    .offcanvas-backdrop { display: none !important; }
    .app-sidebar.offcanvas { transition: none !important; }
}

/* ============================================================
   MOBILE OPTIMIZATIONS
   Focado em uso em Chrome Android + Safari iOS pelos professores.
   Touch targets ≥ 44x44px (Apple HIG / Material Design).
   ============================================================ */

/* Scale slightly up base font on mobile pra leitura confortável sem zoom */
@media (max-width: 576px) {
    body {
        font-size: 1rem; /* 16px — evita auto-zoom do iOS Safari em inputs */
        line-height: 1.5;
    }
    .form-label { font-size: .875rem; font-weight: 600; }
    .breadcrumb { font-size: .8rem; }
    .text-muted { font-size: inherit; }
}

/* Inputs: altura confortável + iOS Safari não dá zoom em font-size >= 16px */
@media (max-width: 768px) {
    .form-control,
    .form-select {
        font-size: 16px;
        padding: .625rem .75rem;
        min-height: 44px;
    }
    textarea.form-control { min-height: auto; }
}

/* Touch targets — qualquer botão (incluindo .btn-sm) com ícone-only fica ≥ 44px */
@media (max-width: 768px) {
    .btn-sm {
        min-height: 40px;
        padding: .45rem .75rem;
    }
    /* Botões só com ícone (sem texto descritivo) — quadrado 44x44 */
    .btn-sm[aria-label]:not(:has(span)),
    .btn-sm > i:only-child {
        /* heurística — força padding maior */
    }
    .btn-sm.btn-icon-only,
    .btn[aria-label] > i:only-child {
        padding: .55rem;
    }
    /* Botões dentro de tabelas (coluna ações) — espaçamento confortável */
    table .btn-sm {
        margin-bottom: 2px;
    }
}

/* Page header em mobile: empilha completo, action button vira full-width */
@media (max-width: 768px) {
    .page-header {
        gap: .75rem;
    }
    .page-header > .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }
    .page-header-title { font-size: 1.15rem; }
    .page-header-subtitle { font-size: .8125rem; }
}

/* Stat cards: padding mais generoso em mobile pra hover/tap funcionar bem */
@media (max-width: 576px) {
    .stat-card {
        padding: 18px 16px;
    }
    .stat-card-title { font-size: 1.05rem; }
    .stat-card-icon {
        width: 38px;
        height: 38px;
    }
}

/* Tabelas: mostra hint de scroll horizontal e melhora UX */
@media (max-width: 768px) {
    .table-responsive {
        position: relative;
        -webkit-overflow-scrolling: touch;
    }
    .table {
        font-size: .875rem;
    }
    .table th, .table td {
        white-space: nowrap;
    }
    /* Quando declarado com .table-stack-mobile, quebra cada linha em "card" */
    .table-stack-mobile thead { display: none; }
    .table-stack-mobile,
    .table-stack-mobile tbody,
    .table-stack-mobile tr,
    .table-stack-mobile td {
        display: block;
        width: 100%;
    }
    .table-stack-mobile tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: .75rem;
        padding: .75rem 1rem;
    }
    .table-stack-mobile td {
        white-space: normal;
        border: none !important;
        padding: .35rem 0;
        position: relative;
        padding-left: 40%;
    }
    .table-stack-mobile td::before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        top: .35rem;
        width: 38%;
        font-size: .7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--text-muted);
    }
    .table-stack-mobile td[data-label="Ações"],
    .table-stack-mobile td.actions-cell {
        padding-left: 0;
        padding-top: .5rem;
        margin-top: .5rem;
        border-top: 1px solid var(--border) !important;
        display: flex;
        flex-wrap: wrap;
        gap: .35rem;
    }
    .table-stack-mobile td[data-label="Ações"]::before,
    .table-stack-mobile td.actions-cell::before { display: none; }
}

/* Modal: dialog com width adaptado a mobile + footer com botões empilhados se houver 3+ */
@media (max-width: 576px) {
    .modal-dialog {
        margin: .5rem;
        max-width: calc(100% - 1rem);
    }
    .modal-content { border-radius: var(--radius-lg); }
    .modal-footer {
        flex-direction: column-reverse;
        gap: .5rem;
    }
    .modal-footer > .btn,
    .modal-footer > form,
    .modal-footer > a {
        width: 100%;
        margin: 0 !important;
    }
    .modal-footer > form > .btn { width: 100%; }
}

/* Toolbar de ações na header (sessions/show, etc): empilha em mobile */
@media (max-width: 768px) {
    .header-actions-mobile {
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
        width: 100%;
    }
    .header-actions-mobile > .btn,
    .header-actions-mobile > form,
    .header-actions-mobile > a {
        flex: 1 1 calc(50% - .25rem);
        min-height: 44px;
        font-size: .85rem;
    }
    .header-actions-mobile .btn-icon-mobile {
        flex: 0 0 44px !important;
        padding: .55rem;
    }
}

/* Badges e status-badge: aumentar em mobile pra leitura */
@media (max-width: 576px) {
    .badge { font-size: .75rem; padding: .35em .6em; }
    .status-badge { font-size: .8rem; padding: .3rem .6rem; }
}

/* Pagination: targets de toque maiores */
@media (max-width: 576px) {
    .page-link {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Sidebar offcanvas em mobile: largura adequada (não 100vw) */
@media (max-width: 991.98px) {
    .app-sidebar.offcanvas-start {
        --bs-offcanvas-width: 280px;
        width: 280px !important;
        max-width: 85vw;
    }
}

/* Topbar em mobile: hamburger maior, padding ajustado */
@media (max-width: 768px) {
    .app-topbar {
        padding: 0 16px;
        gap: 8px;
    }
    .topbar-hamburger {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    .topbar-user-btn {
        padding: .35rem .5rem;
        min-height: 40px;
    }
    .topbar-avatar {
        width: 30px !important;
        height: 30px !important;
    }
}

/* Conteúdo principal: padding apropriado em mobile */
@media (max-width: 576px) {
    .app-main {
        padding: 1rem !important;
    }
}

/* Cards em geral: arredondamento e espaço mais agradável em mobile */
@media (max-width: 576px) {
    .card,
    .app-card {
        border-radius: var(--radius);
    }
}

/* Sticky bottom action bar — para forms longos */
@media (max-width: 768px) {
    .form-actions-sticky {
        position: sticky;
        bottom: 0;
        background: var(--surface);
        margin: 1rem -1rem -1rem;
        padding: .75rem 1rem;
        border-top: 1px solid var(--border);
        z-index: 10;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, .04);
    }
    .form-actions-sticky .btn { min-height: 44px; }
}

/* ============================================================
   RECORDER MOBILE — UX crítica para o professor gravando aluno
   ============================================================ */
@media (max-width: 768px) {
    /* Texto da leitura maior em mobile (criança precisa enxergar) */
    .recorder-card .reading-text {
        font-size: 1.2rem;
        line-height: 1.85;
        max-height: 45vh;
        padding: .5rem;
    }
    /* Botão circular de "iniciar" maior em mobile */
    .record-btn {
        width: 96px !important;
        height: 96px !important;
        font-size: 2rem !important;
    }
    /* Cluster de controles ocupa toda a largura, com 2 colunas */
    .control-cluster {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
        padding: 0 .25rem;
    }
    .control-btn {
        min-width: 0 !important;
        width: 100% !important;
        min-height: 52px;
        padding: .75rem !important;
        font-size: .9rem;
    }
    /* Card geral de gravação: padding mobile-friendly */
    .recorder-card {
        margin-left: -.5rem;
        margin-right: -.5rem;
    }
    .recorder-card .card-body {
        padding: 1rem .75rem;
    }
    /* Header do card de gravação */
    .recorder-card .card-header h4 {
        font-size: 1rem;
    }
    /* Timer e word-count maiores em mobile */
    #timerElapsed, #timerTotal {
        font-size: 1.25rem !important;
    }
    /* Modal de "Avaliar próximo" ocupa width máximo confortável */
    #evaluationDoneModal .modal-content {
        margin: 0 .5rem;
    }
}

@media (max-width: 480px) {
    /* Em telas muito estreitas, controles ficam em 1 coluna */
    .control-cluster {
        grid-template-columns: 1fr;
    }
    .recorder-card .reading-text {
        font-size: 1.1rem;
        line-height: 1.7;
    }
}

/* Em landscape mobile (altura limitada), encolhe altura da leitura */
@media (max-height: 500px) and (orientation: landscape) {
    .recorder-card .reading-text {
        max-height: 30vh;
        font-size: 1rem;
    }
    .record-btn {
        width: 64px !important;
        height: 64px !important;
        font-size: 1.3rem !important;
    }
}
