/* ============================================
   Sistema de Questões — Minas Educa Style
   ============================================ */

:root {
  --primary: #3d5a9b;
  --primary-dark: #2d4278;
  --primary-light: #e8edff;
  --accent: #00c3c3;
  --accent-dark: #00a0a0;
  --warning: #f5a623;
  --danger: #e74c3c;
  --success: #27ae60;
  --info: #3498db;
  --bg: #f5f6fa;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f0f2f5;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-500: #adb5bd;
  --gray-700: #495057;
  --gray-900: #212529;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 2px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.6;
}

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, #1a2f5e 0%, #2d4278 50%, #3d5a9b 100%);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 200;
}

/* ===== HAMBURGER BUTTON ===== */
.hamburger-btn {
  display: none; /* oculto no desktop */
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
  transition: background .2s;
}
.hamburger-btn:hover { background: rgba(255,255,255,.22); }
.hamburger-btn span {
  display: block;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all .3s ease;
  transform-origin: center;
}
/* Animação X ao abrir */
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== MOBILE DRAWER ===== */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 299;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .3s;
}
.drawer-overlay.open { display: block; opacity: 1; }

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh; /* dynamic viewport height */
  width: 300px;
  max-width: 85vw;
  background: white;
  z-index: 300;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,.2);
  overflow-y: auto;
}
.mobile-drawer.open { transform: translateX(0); }

.drawer-header {
  background: linear-gradient(135deg, #1a2f5e, #3d5a9b);
  padding: 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.drawer-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.drawer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  border: 2px solid rgba(255,255,255,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.drawer-user-name {
  color: white;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}
.drawer-user-role {
  color: rgba(255,255,255,.7);
  font-size: 12px;
  margin-top: 2px;
}
.drawer-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s;
}
.drawer-close:hover { background: rgba(255,255,255,.3); }

.drawer-nav {
  flex: 1;
  padding: 12px 8px;
}
.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--gray-700);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all .2s;
}
.drawer-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.drawer-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.drawer-link-icon { font-size: 18px; width: 24px; text-align: center; }

.drawer-footer {
  padding: 16px;
  border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.drawer-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.drawer-logout:hover { background: #ffcdd2; }

/* Desktop nav — visível apenas no desktop */
.desktop-nav { display: flex; }
.header-desktop-only { display: flex; }


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

.header-brand img {
  height: 36px;
}

.header-brand span {
  color: white;
  font-weight: 700;
  font-size: 16px;
}

.header-brand .tagline {
  color: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 400;
  display: block;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 16px;
  color: rgba(255,255,255,.9);
  font-size: 13px;
}

.header-user .user-name {
  font-weight: 500;
}

.header-user .badge-role {
  background: rgba(255,255,255,.15);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}

.btn-logout {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: white;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: background .2s;
}

.btn-logout:hover { background: rgba(255,255,255,.2); }

/* ===== NAV TABS ===== */
.nav-tabs {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.nav-tab {
  padding: 14px 16px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all .2s;
}

.nav-tab:hover { color: var(--primary); border-bottom-color: var(--gray-300); }
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== LAYOUT ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-content {
  padding: 24px;
  min-height: calc(100vh - 120px);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-900);
}

.page-title small {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.card-body {
  padding: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-900);
  background: var(--gray-50);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ===== FORM LAYOUT (same as Minas Educa) ===== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-weight: 500;
  font-size: 13px;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-label .req {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61,90,155,.1);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23495057' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ===== ALTERNATIVES ===== */
.alternatives-section {
  margin-top: 20px;
}

.alternatives-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
}

.alternative-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
}

.alternative-item.is-correct {
  background: #e8f5e9;
  border-color: #66bb6a;
}

.alternative-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.alternative-letra {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.alternative-item.is-correct .alternative-letra {
  background: var(--success);
}

.correta-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-700);
  user-select: none;
}

.correta-label input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--success);
  cursor: pointer;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #229954; }

.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-warning:hover { background: #e08e0b; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #c0392b; }

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}
.btn-secondary:hover { background: var(--gray-300); }

.btn-accent {
  background: var(--accent);
  color: white;
}
.btn-accent:hover { background: var(--accent-dark); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.badge-draft { background: #fff3e0; color: #e65100; }
.badge-review { background: #e3f2fd; color: #1565c0; }
.badge-approved { background: #e8f5e9; color: #2e7d32; }
.badge-rejected { background: #ffebee; color: #c62828; }

.badge-professor { background: #e8edff; color: var(--primary); }
.badge-aprovador { background: #fff3e0; color: #e65100; }
.badge-super-admin { background: #f3e5f5; color: #6a1b9a; }

.badge-pending { background: #fff8e1; color: #f57f17; }
.badge-blocked { background: #ffebee; color: #c62828; }

/* ===== TABLE ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

thead th {
  background: var(--gray-50);
  padding: 11px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--gray-200);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  vertical-align: middle;
}

tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }

/* ===== ALERTS / FLASH ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid var(--success); }
.alert-error { background: #ffebee; color: #c62828; border-left: 4px solid var(--danger); }
.alert-info { background: #e3f2fd; color: #1565c0; border-left: 4px solid var(--info); }
.alert-warning { background: #fff8e1; color: #f57f17; border-left: 4px solid var(--warning); }

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  text-align: center;
}

.stat-card .stat-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
  font-weight: 500;
}

/* ===== BNCC SELECTOR ===== */
.bncc-container {
  margin-bottom: 8px;
}

.bncc-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  margin-bottom: 6px;
}

.bncc-results {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  display: none;
  background: white;
  z-index: 10;
  box-shadow: var(--shadow);
}

.bncc-result-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid var(--gray-100);
  transition: background .15s;
}

.bncc-result-item:hover { background: var(--primary-light); }

.bncc-result-item .bncc-code { font-weight: 700; color: var(--primary); }
.bncc-result-item .bncc-desc { color: var(--gray-700); }

.bncc-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.bncc-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.bncc-tag button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

/* ===== TAGS INPUT ===== */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  min-height: 40px;
  cursor: text;
  background: white;
}

.tags-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61,90,155,.1);
}

.tag-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--gray-200);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--gray-900);
}

.tag-item button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--gray-500);
  font-size: 14px;
}

.tag-input {
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  flex: 1;
  min-width: 80px;
}

/* ===== SIDE PANEL ===== */
.side-panel {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  position: sticky;
  top: 80px;
}

.side-panel-section {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--gray-200);
}

.side-panel-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.side-panel-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 10px;
}

/* ===== RADIO TIPO ===== */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-700);
}

.radio-option input[type="radio"] {
  accent-color: var(--primary);
  cursor: pointer;
}

/* ===== FILTER TABS ===== */
.filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-300);
  background: white;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
  text-decoration: none;
  cursor: pointer;
  transition: all .2s;
}

.filter-tab:hover { border-color: var(--primary); color: var(--primary); }
.filter-tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a2f5e 0%, #2d4278 50%, #3d5a9b 100%);
  padding: 24px;
}

.auth-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  text-align: center;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  text-align: center;
  margin-bottom: 28px;
}

/* ===== QUESTION VIEW ===== */
.question-view {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.q-enunciado {
  font-size: 15px;
  line-height: 1.8;
  margin-bottom: 24px;
  color: var(--gray-900);
}

.q-alternatives {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.q-alt {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.q-alt.correct {
  background: #e8f5e9;
  border-color: #a5d6a7;
}

.q-alt-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.q-alt.correct .q-alt-letter {
  background: var(--success);
}

/* ===== NOTICE BOXES ===== */
.notice-box {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a2f5e 0%, #3d5a9b 100%);
}

.notice-card {
  background: white;
  border-radius: 20px;
  padding: 48px 40px;
  text-align: center;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.notice-icon {
  font-size: 56px;
  margin-bottom: 20px;
}

.notice-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.notice-text {
  color: var(--gray-500);
  line-height: 1.7;
  margin-bottom: 24px;
}

/* ===== ERRORS DISPLAY ===== */
.error-list {
  background: #ffebee;
  border: 1px solid #ef9a9a;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.error-list ul {
  list-style: none;
  padding: 0;
}

.error-list li {
  font-size: 13px;
  color: #c62828;
  padding: 2px 0;
}

.error-list li::before {
  content: '⚠ ';
}

/* ===== ACTIONS ROW ===== */
.actions-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--gray-700);
  margin-bottom: 8px;
}

/* ===== TINYMCE WRAPPER ===== */
.tinymce-wrapper {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tinymce-wrapper .tox-tinymce {
  border: none !important;
}

/* ===== REJECTION BOX ===== */
.rejection-box {
  background: #fff8e1;
  border: 1px solid #ffcc02;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.rejection-box .rejection-title {
  font-weight: 600;
  color: #e65100;
  margin-bottom: 6px;
  font-size: 13px;
}

.rejection-box .rejection-text {
  color: var(--gray-700);
  font-size: 13px;
}

/* ===== FOOTER ===== */
.footer {
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 12px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-500);
}

/* ============================================
   RESPONSIVO COMPLETO — Tablet e Celular
   ============================================ */

/* ===== TABLET (até 900px) ===== */
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .header { padding: 0 16px; height: 56px; }
  .page-content { padding: 16px; }
  .side-panel { position: static; }
  .table-wrapper { border-radius: 8px; }
  thead th, tbody td { padding: 10px 10px; font-size: 12px; }
}

/* ===== MOBILE — HAMBURGER ATIVA (até 768px) ===== */
@media (max-width: 768px) {
  /* Mostra hamburger, esconde nav e user do desktop */
  .hamburger-btn { display: flex; }
  .header-desktop-only { display: none !important; }
  .desktop-nav { display: none !important; }

  /* Header ajustado */
  .header { padding: 0 14px; height: 54px; }

  /* Remove sticky do nav (não existe mais) */
  .nav-tabs { display: none; }
}

/* ===== CELULAR (até 640px) ===== */
@media (max-width: 640px) {
  /* === LAYOUT === */
  .page-content { padding: 12px; min-height: auto; }
  .container { padding: 0 12px; }

  /* === PAGE HEADER === */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header .btn { width: 100%; justify-content: center; }
  .page-title { font-size: 17px; }

  /* === STATS GRID === */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 10px; }
  .stat-card .stat-number { font-size: 24px; }
  .stat-card .stat-label { font-size: 11px; }

  /* === CARDS === */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }

  /* === FORMULÁRIO === */
  .form-group { margin-bottom: 14px; }
  .form-label { font-size: 12px; }
  .form-control { font-size: 16px; padding: 11px 12px; } /* 16px evita zoom no iOS */

  /* Side panel embaixo */
  .side-panel { position: static; margin-top: 16px; padding: 16px; }

  /* === ALTERNATIVAS === */
  .alternative-item { padding: 10px; }
  .alternative-header { flex-wrap: wrap; gap: 8px; }
  .correta-label { font-size: 12px; }

  /* === BOTÕES === */
  .btn { padding: 10px 14px; font-size: 13px; }
  .btn-sm { padding: 7px 12px; font-size: 12px; }
  .btn-lg { padding: 12px 20px; font-size: 14px; }

  /* Botões de ação — empilhar em coluna */
  .actions-row { flex-direction: column; gap: 8px; width: 100%; }
  .actions-row .btn { width: 100%; justify-content: center; }

  /* === TABELAS — scroll horizontal === */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 520px; }
  thead th { font-size: 11px; padding: 8px 10px; }
  tbody td { font-size: 12px; padding: 10px 10px; }

  /* === AUTH PAGES === */
  .auth-page { padding: 16px; align-items: flex-start; padding-top: 40px; }
  .auth-card { padding: 24px 18px; border-radius: 12px; }
  .auth-title { font-size: 20px; }
  .auth-logo .logo-icon { width: 52px; height: 52px; font-size: 24px; }

  /* === FILTER TABS === */
  .filter-tabs { gap: 6px; }
  .filter-tab { padding: 5px 12px; font-size: 11px; }

  /* === QUESTION VIEW === */
  .question-view { padding: 16px; }
  .q-enunciado { font-size: 14px; }
  .q-alt { padding: 10px 12px; gap: 8px; }

  /* === NOTICE BOX === */
  .notice-card { padding: 32px 20px; }
  .notice-icon { font-size: 44px; }
  .notice-title { font-size: 20px; }

  /* === BNCC / TAGS === */
  .bncc-selected { gap: 4px; }
  .bncc-tag { font-size: 11px; padding: 3px 8px; }
  .tag-item { font-size: 11px; }

  /* === ADMIN TABLE === */
  .hide-mobile { display: none; }

  /* === FOOTER === */
  .footer { padding: 10px 16px; font-size: 11px; }

  /* === REJECTION BOX === */
  .rejection-box { padding: 12px; }

  /* === EMPTY STATE === */
  .empty-state { padding: 40px 16px; }
  .empty-state .empty-icon { font-size: 40px; }
  .empty-state h3 { font-size: 16px; }
}

/* ===== MUITO PEQUENO (iPhone SE, etc) ===== */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px 8px; }
  .stat-card .stat-number { font-size: 20px; }
  .page-content { padding: 10px; }
  .auth-card { padding: 20px 14px; }
  .filter-tab { padding: 4px 10px; font-size: 10px; }
  .badge { font-size: 10px; padding: 2px 7px; }
}

/* ===== TINYMCE NO MOBILE ===== */
@media (max-width: 768px) {
  .tox-tinymce { min-height: 160px !important; }
  .tox-editor-container { width: 100% !important; max-width: 100% !important; }
  .tox .tox-toolbar { flex-wrap: wrap !important; }
}

/* ===== TABELA USUÁRIOS ===== */
@media (max-width: 640px) {
  .users-table thead th:nth-child(3),
  .users-table tbody td:nth-child(3) { display: none; }
}

/* ===== FORMULARIO QUESTÃO ===== */
@media (max-width: 640px) {
  .form-grid-inline { display: flex; flex-direction: column; gap: 12px; }
  .form-grid-inline > * { width: 100%; }
}

/* ===== CELULAR (até 640px) ===== */
@media (max-width: 640px) {
  /* === HEADER MOBILE === */
  .header { padding: 0 12px; height: 52px; gap: 8px; }
  .header-user { gap: 8px; }
  .header-user .user-name { display: none; } /* oculta nome no celular */
  .header-user .badge-role { font-size: 10px; padding: 2px 6px; }
  .btn-logout { padding: 5px 10px; font-size: 11px; }

  /* Marca do sistema — reduz texto */
  .header-brand > div > span:first-child { font-size: 13px; }
  .header-brand > div > span.tagline { display: none; }

  /* === NAV TABS MOBILE === */
  .nav-tabs {
    padding: 0 8px;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tab { padding: 12px 10px; font-size: 12px; }

  /* === LAYOUT === */
  .page-content { padding: 12px; min-height: auto; }
  .container { padding: 0 12px; }

  /* === PAGE HEADER === */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header .btn { width: 100%; justify-content: center; }
  .page-title { font-size: 17px; }

  /* === STATS GRID === */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 10px; }
  .stat-card .stat-number { font-size: 24px; }
  .stat-card .stat-label { font-size: 11px; }

  /* === CARDS === */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }

  /* === FORMULÁRIO === */
  .form-group { margin-bottom: 14px; }
  .form-label { font-size: 12px; }
  .form-control { font-size: 14px; padding: 10px 12px; } /* maior p/ celular */

  /* Side panel embaixo no mobile */
  .side-panel {
    position: static;
    margin-top: 16px;
    padding: 16px;
  }

  /* === ALTERNATIVAS === */
  .alternative-item { padding: 10px; }
  .alternative-header { flex-wrap: wrap; gap: 8px; }
  .correta-label { font-size: 12px; }

  /* === BOTÕES === */
  .btn { padding: 10px 14px; font-size: 13px; }
  .btn-sm { padding: 7px 12px; font-size: 12px; }
  .btn-lg { padding: 12px 20px; font-size: 14px; }

  /* Botões de ação — empilhar em coluna */
  .actions-row {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  .actions-row .btn { width: 100%; justify-content: center; }

  /* === TABELAS — converter para cards no celular === */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 520px; } /* força scroll horizontal */
  thead th { font-size: 11px; padding: 8px 10px; }
  tbody td { font-size: 12px; padding: 10px 10px; }

  /* === AUTH PAGES === */
  .auth-page { padding: 16px; align-items: flex-start; padding-top: 40px; }
  .auth-card { padding: 24px 18px; border-radius: 12px; }
  .auth-title { font-size: 20px; }
  .auth-logo .logo-icon { width: 52px; height: 52px; font-size: 24px; }

  /* === FILTER TABS === */
  .filter-tabs { gap: 6px; }
  .filter-tab { padding: 5px 12px; font-size: 11px; }

  /* === QUESTION VIEW === */
  .question-view { padding: 16px; }
  .q-enunciado { font-size: 14px; }
  .q-alt { padding: 10px 12px; gap: 8px; }

  /* === NOTICE BOX === */
  .notice-card { padding: 32px 20px; }
  .notice-icon { font-size: 44px; }
  .notice-title { font-size: 20px; }

  /* === BNCC / TAGS === */
  .bncc-selected { gap: 4px; }
  .bncc-tag { font-size: 11px; padding: 3px 8px; }
  .tag-item { font-size: 11px; }

  /* === ADMIN QUESTIONS TABLE — hide colunas menos importantes === */
  .hide-mobile { display: none; }

  /* === FOOTER === */
  .footer { padding: 10px 16px; font-size: 11px; }

  /* === REJECTION BOX === */
  .rejection-box { padding: 12px; }

  /* === EMPTY STATE === */
  .empty-state { padding: 40px 16px; }
  .empty-state .empty-icon { font-size: 40px; }
  .empty-state h3 { font-size: 16px; }
}

/* ===== MUITO PEQUENO (até 380px — iPhone SE, etc) ===== */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px 8px; }
  .stat-card .stat-number { font-size: 20px; }

  .nav-tab { padding: 10px 8px; font-size: 11px; }
  .page-content { padding: 10px; }
  .auth-card { padding: 20px 14px; }

  .filter-tab { padding: 4px 10px; font-size: 10px; }
  .badge { font-size: 10px; padding: 2px 7px; }
}

/* ===== TINYEMCE NO MOBILE — garante que o editor não estoura ===== */
@media (max-width: 640px) {
  .tox-tinymce { min-height: 160px !important; }
  .tox-toolbar__group { flex-wrap: wrap; }
  .tox-editor-container { width: 100% !important; max-width: 100% !important; }
  .tox .tox-toolbar { flex-wrap: wrap !important; }
}

/* ===== TABELA USUÁRIOS — responsiva ===== */
@media (max-width: 640px) {
  .users-table thead th:nth-child(3),
  .users-table tbody td:nth-child(3) { display: none; } /* oculta coluna Escola */
}

/* ===== FORMULARIO DE QUESTÃO — fix grid no mobile ===== */
@media (max-width: 640px) {
  .form-grid-inline {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .form-grid-inline > * { width: 100%; }
}

/* Limite para imagens geradas pelo usuario/IA */
.q-enunciado img, .q-alternatives img, .tinymce-wrapper img, .card-body img {
  max-width: 100%;
  max-height: 350px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
  margin: 10px 0;
}
