/* styles.css - Modern, High-End Responsive Styles for Instant Rased (رصد فوري) */

:root {
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  
  /* Color Palette - Dark Slate / Modern Glass */
  --bg-main: #0b1120;
  --bg-secondary: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.75);
  --bg-card-hover: rgba(51, 65, 85, 0.85);
  --border-color: rgba(148, 163, 184, 0.15);
  --border-active: rgba(56, 189, 248, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-primary: #0ea5e9;
  --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
  --accent-glow: rgba(56, 189, 248, 0.25);

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.25);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.25);
  --warning: #f59e0b;
  --neutral-scanned: #0284c7;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  
  --transition-fast: 0.18s ease;
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: #ffffff;
  --border-color: rgba(100, 116, 139, 0.18);
  --border-active: rgba(14, 165, 233, 0.5);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --accent-primary: #0284c7;
  --accent-gradient: linear-gradient(135deg, #0284c7 0%, #1d4ed8 100%);
  --accent-glow: rgba(2, 132, 199, 0.2);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.12);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Navigation & Header */
.app-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  box-shadow: 0 0 16px var(--accent-glow);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Nav Pills */
.nav-pills {
  display: flex;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.3rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.nav-pill-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.nav-pill-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.nav-pill-btn.active {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 2px 10px var(--accent-glow);
}

/* Header Utilities */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
}

.offline-dot {
  width: 7px;
  height: 7px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Main Container */
.main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* PWA Banners (Install & Auto-Update) */
.pwa-banner {
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.3s ease-out;
}

.install-banner {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15) 0%, rgba(37, 99, 235, 0.1) 100%);
  border: 1px solid var(--border-active);
}

.update-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(5, 150, 105, 0.1) 100%);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.banner-content {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.banner-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.banner-text strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.banner-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.icon-btn.btn-sm {
  width: 30px;
  height: 30px;
  font-size: 0.8rem;
}

/* Views & Transitions */
.view-section {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Page Headers */
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.title-wrap h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.title-wrap p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--success-glow);
}

.btn-success:hover {
  filter: brightness(1.1);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

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

.btn-lg {
  padding: 0.85rem 1.6rem;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

/* Cards & Grids */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  position: relative;
  backdrop-filter: blur(12px);
}

.card:hover {
  border-color: var(--border-active);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-primary);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0;
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: all var(--transition-normal);
}

.modal-backdrop.active .modal-box {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Forms */
.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

/* ==========================================================================
   LIVE CLASSROOM SCANNER INTERFACE (High Aesthetics & Neutral Student Grid)
   ========================================================================== */

.scanner-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .scanner-layout {
    grid-template-columns: 1fr;
  }
}

.camera-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  position: relative;
}

.camera-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#overlay-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.camera-hud {
  position: absolute;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.scanner-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.camera-controls-bar {
  padding: 0.85rem 1.25rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Neutral Student Grid (Classroom Privacy Screen) */
.student-grid-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  min-height: 520px;
}

.student-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.counter-tag {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.student-tiles-scroll {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Responsive Grid of Student Tiles */
.student-tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

/* Individual Student Tile */
.student-tile {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.6rem;
  text-align: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 78px;
}

.tile-number {
  position: absolute;
  top: 6px;
  inset-inline-start: 8px;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
}

.tile-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.4rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-status {
  font-size: 0.7rem;
  margin-top: 0.25rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Scanned State - NEUTRAL BLUE (Strict Privacy: Choice is hidden) */
.student-tile.is-scanned {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.35) 0%, rgba(14, 165, 233, 0.2) 100%);
  border-color: var(--accent-primary);
  box-shadow: 0 0 14px var(--accent-glow);
  transform: scale(1.03);
}

.student-tile.is-scanned .tile-number {
  color: #38bdf8;
}

.student-tile.is-scanned .tile-status {
  color: #38bdf8;
  font-weight: 700;
}

/* Evaluated State (Post-Grading) */
.student-tile.is-correct {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.35) 0%, rgba(5, 150, 105, 0.2) 100%);
  border-color: var(--success);
  box-shadow: 0 0 14px var(--success-glow);
}

.student-tile.is-correct .tile-status {
  color: #34d399;
  font-weight: 800;
}

.student-tile.is-incorrect {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.3) 0%, rgba(185, 28, 28, 0.15) 100%);
  border-color: var(--danger);
}

.student-tile.is-incorrect .tile-status {
  color: #f87171;
}

.student-tile.is-missing {
  opacity: 0.45;
}

/* Floating Bottom Action Bar for Scanner */
.scanner-action-bar {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* ==========================================================================
   POST-SCANNING GRADING & ANALYTICS MODAL
   ========================================================================== */

.grading-modal-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.choice-selection-box {
  text-align: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.choice-buttons-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.btn-choice {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 0.5rem;
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.btn-choice span.choice-sub {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-choice:hover {
  border-color: var(--accent-primary);
  background: rgba(56, 189, 248, 0.1);
  transform: translateY(-2px);
}

.btn-choice.selected {
  border-color: #10b981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(5, 150, 105, 0.2) 100%);
  color: #34d399;
  box-shadow: 0 0 16px var(--success-glow);
}

/* Distribution Chart */
.analytics-chart-box {
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
}

.chart-bars-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.chart-bar-row {
  display: grid;
  grid-template-columns: 32px 1fr 60px;
  align-items: center;
  gap: 0.75rem;
}

.chart-bar-label {
  font-weight: 800;
  font-size: 1rem;
}

.chart-bar-track {
  height: 22px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.chart-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.chart-bar-fill.correct {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.chart-bar-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: end;
}

/* ==========================================================================
   PRINTABLE CARDS SYSTEM (@media print & A4 Formatting)
   ========================================================================== */

.print-controls-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.printable-cards-grid {
  display: grid;
  gap: 1.5rem;
  margin: 0 auto;
}

/* Layout: 2 per page */
.printable-cards-grid.layout-2-per-page {
  grid-template-columns: 1fr;
  max-width: 780px;
}

/* Layout: 4 per page */
.printable-cards-grid.layout-4-per-page {
  grid-template-columns: 1fr 1fr;
  max-width: 960px;
}

/* Student Card Physical Simulation */
.student-card {
  background: #ffffff;
  color: #0f172a;
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  padding: 1.5rem;
  position: relative;
  page-break-inside: avoid;
  break-inside: avoid;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.student-card.layout-2-per-page {
  min-height: 480px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.student-card.layout-4-per-page {
  min-height: 380px;
  padding: 1rem;
}

.card-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.card-student-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.card-student-num {
  background: #0f172a;
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 900;
  padding: 0.2rem 0.65rem;
  border-radius: 6px;
}

.card-student-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.card-class-info {
  text-align: end;
}

.card-class-name {
  font-size: 1rem;
  font-weight: 700;
  color: #334155;
}

.card-class-sub {
  font-size: 0.8rem;
  color: #64748b;
  display: block;
}

/* Center Marker Zone with 4 edges */
.card-marker-zone {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 0.5rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.student-card.layout-4-per-page .card-marker-zone {
  width: 220px;
  height: 220px;
}

.marker-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  background: #000000;
  padding: 2px;
}

.student-card.layout-4-per-page .marker-container {
  width: 140px;
  height: 140px;
}

.marker-container svg {
  width: 100%;
  height: 100%;
}

/* 4 Oriented Edges */
.choice-edge {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #1e293b;
}

.choice-edge .choice-letter {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
}

.choice-edge .choice-hint {
  font-size: 0.65rem;
  font-weight: 700;
  color: #64748b;
}

.edge-top {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.edge-bottom {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

.edge-left {
  left: 0;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
}

.edge-right {
  right: 0;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
}

/* Subtle Student Secret Guides (Printed lightly inside margin) */
.student-secret-guides {
  display: flex;
  justify-content: space-around;
  margin-top: 0.5rem;
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: bold;
}

.card-footer {
  text-align: center;
  margin-top: 0.85rem;
  padding-top: 0.5rem;
  border-top: 1px solid #f1f5f9;
}

.card-instruction {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 600;
}

/* PRINT MEDIA QUERIES (Exact A4 Formatting) */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .print-controls-bar,
  .nav-pills,
  .btn,
  .modal-backdrop,
  footer {
    display: none !important;
  }

  .main-content {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .view-section {
    display: none !important;
  }

  #view-print-cards {
    display: block !important;
  }

  .printable-cards-grid {
    display: block !important;
    gap: 0 !important;
  }

  .student-card {
    border: 1px dashed #64748b !important;
    box-shadow: none !important;
    margin-bottom: 8mm !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .student-card.layout-2-per-page {
    height: 130mm !important;
    max-height: 132mm !important;
  }

  .student-card.layout-4-per-page {
    width: 48% !important;
    display: inline-block !important;
    vertical-align: top !important;
    height: 125mm !important;
    margin-right: 2% !important;
  }
}

/* RTL / LTR Helpers */
[dir="rtl"] .card-meta {
  text-align: right;
}

[dir="ltr"] .card-meta {
  text-align: left;
}

[dir="ltr"] .card-class-info {
  text-align: right;
}

[dir="rtl"] .card-class-info {
  text-align: left;
}

/* ==========================================================================
   HEADER VERSION BADGE & APP FOOTER
   ========================================================================== */

.app-version-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(14, 165, 233, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(14, 165, 233, 0.3);
  letter-spacing: 0.04em;
}

.app-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  margin-top: auto;
  backdrop-filter: blur(12px);
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.footer-credit, .footer-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.footer-author-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.2);
  transition: all var(--transition-fast);
}

.footer-author-link:hover {
  background: var(--accent-gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 10px var(--accent-glow);
  transform: translateY(-1px);
}

.footer-link-icon {
  font-size: 0.8rem;
  font-weight: 900;
}

.footer-doc-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-doc-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.footer-bullet {
  color: var(--border-color);
  font-size: 0.8rem;
}

.footer-version-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.footer-version-tag {
  background: rgba(15, 23, 42, 0.6);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  color: var(--accent-primary);
  font-size: 0.78rem;
}

.footer-rights {
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .footer-container {
    flex-direction: column;
    text-align: center;
    justify-content: center;
  }
}

/* ==========================================================================
   MOBILE DRAWER & HAMBURGER MENU STYLES
   ========================================================================== */

.mobile-menu-btn {
  display: none;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 325px;
  max-width: 88vw;
  background: var(--bg-secondary);
  z-index: 1300;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

[dir="rtl"] .mobile-drawer {
  right: 0;
  left: auto;
  transform: translateX(100%);
  border-left: 1px solid var(--border-color);
  border-right: none;
}

[dir="rtl"] .mobile-drawer.active {
  transform: translateX(0);
}

[dir="ltr"] .mobile-drawer {
  left: 0;
  right: auto;
  transform: translateX(-100%);
  border-right: 1px solid var(--border-color);
  border-left: none;
}

[dir="ltr"] .mobile-drawer.active {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.45);
}

[data-theme="light"] .drawer-header {
  background: rgba(241, 245, 249, 0.85);
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.drawer-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 10px var(--accent-glow);
}

.drawer-title {
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.drawer-close-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.drawer-section-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding-inline-start: 0.2rem;
}

.drawer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  gap: 0.75rem;
}

.drawer-item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.drawer-item-icon {
  font-size: 1.35rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

[data-theme="light"] .drawer-item-icon {
  background: rgba(0, 0, 0, 0.05);
}

.drawer-item-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-item-subtitle {
  font-size: 0.78rem;
  color: var(--accent-primary);
  font-weight: 600;
}

.drawer-item-btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.drawer-action-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-align: start;
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  width: 100%;
}

.drawer-action-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.drawer-btn-text strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-btn-text small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.3;
}

.drawer-link-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: rgba(14, 165, 233, 0.06);
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.drawer-link-item:hover {
  background: rgba(14, 165, 233, 0.12);
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.drawer-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  background: rgba(15, 23, 42, 0.4);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

[data-theme="light"] .drawer-footer {
  background: rgba(241, 245, 249, 0.7);
}

.drawer-license-tag {
  color: var(--accent-primary);
  font-weight: 700;
}

/* ==========================================================================
   MOBILE & SMALL SCREENS RESPONSIVE NAVIGATION
   ========================================================================== */

@media (max-width: 900px) {
  /* Remove backdrop-filter containing block so fixed bottom nav-pills locks to viewport bottom */
  .app-header {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transform: none !important;
    filter: none !important;
    contain: none !important;
  }

  /* Compact Slim Top Header */
  .header-container {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    position: static !important;
    transform: none !important;
    filter: none !important;
    contain: none !important;
  }

  .brand-section {
    flex-shrink: 0;
    gap: 0.45rem;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .brand-text h1 {
    font-size: 1.05rem;
    white-space: nowrap;
  }

  .brand-text p {
    display: none;
  }

  .app-version-badge {
    display: none; /* Hide on mobile header to save space */
  }

  /* Compact Header Action Buttons on Mobile */
  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
  }

  .mobile-menu-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
    transition: background var(--transition-fast), border-color var(--transition-fast);
  }

  .mobile-menu-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-primary);
  }

  /* Language and theme are organized neatly inside the mobile drawer */
  .header-actions #btn-toggle-lang,
  .header-actions #btn-toggle-theme {
    display: none !important;
  }

  #btn-pwa-install {
    display: inline-flex !important;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
    border-radius: var(--radius-full);
    flex-shrink: 0;
  }

  #btn-pwa-install span:last-child {
    font-size: 0.78rem;
  }

  #btn-open-test-card {
    display: none; /* Saved space for mobile header */
  }

  .offline-badge {
    display: none; /* Saved space for mobile header */
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    flex-shrink: 0;
    padding: 0;
  }

  /* Ergonomic Native Mobile Bottom Navigation Bar */
  .nav-pills {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(16px);
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--border-color);
    padding: 0.4rem 0.5rem 0.5rem 0.5rem;
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
    margin: 0;
  }

  [data-theme="light"] .nav-pills {
    background: rgba(255, 255, 255, 0.96);
  }

  .nav-pill-btn {
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.72rem;
    padding: 0.35rem 0.4rem;
    border-radius: var(--radius-sm);
    flex: 1;
    text-align: center;
  }

  .nav-pill-btn span:first-child {
    font-size: 1.2rem;
    line-height: 1;
  }

  /* Prevent bottom bar from overlapping content or footer */
  .main-content {
    padding: 1rem 0.85rem 5.5rem 0.85rem;
  }

  .app-footer {
    margin-bottom: 4.8rem;
  }

  .page-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .scanner-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .student-grid-panel {
    height: auto;
    min-height: 360px;
    max-height: 520px;
  }

  .student-tiles-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 0.5rem;
  }

  .student-tile {
    padding: 0.5rem 0.3rem;
    min-height: 64px;
  }

  .tile-name {
    font-size: 0.78rem;
  }
}

