/* ==========================================================================
   FORM S02 / UDISE MANAGEMENT STUDIO & OFFICIAL PRINT SYSTEM
   Modern UI Tokens, Glassmorphism, Interactive Studio & Pixel-Perfect Print
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-main: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.85);
  --bg-card-hover: rgba(28, 36, 56, 0.95);
  --bg-surface: #131b2e;
  --bg-input: #1b2438;
  
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --primary-hover: #2563eb;
  --secondary: #6366f1;
  --accent: #06b6d4;
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.3);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.3);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  
  --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);
  --shadow-glow: 0 0 25px var(--primary-glow);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  --bg-surface: #e2e8f0;
  --bg-input: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --border-color: rgba(0, 0, 0, 0.1);
  --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 Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Header */
.app-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.brand-badge-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.badge-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-primary { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-success { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* Live Status Dot */
.live-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 10px var(--success);
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); opacity: 0.8; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Studio Layout Container */
.studio-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Stats Ribbon */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-md);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  border-radius: 4px 0 0 4px;
}

.stat-card.stat-green::after { background: var(--success); }
.stat-card.stat-amber::after { background: var(--warning); }
.stat-card.stat-purple::after { background: var(--secondary); }

.stat-info .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-info .stat-val {
  font-size: 1.75rem;
  font-weight: 800;
  margin-top: 0.2rem;
  font-family: var(--font-mono);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 1.3rem;
}

/* Control Hub & Filter Toolbar */
.control-hub {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 280px;
}

.search-box input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.select-control {
  padding: 0.65rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.select-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Buttons System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--primary-glow);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  box-shadow: 0 4px 14px var(--success-glow);
}
.btn-success:hover {
  background: linear-gradient(135deg, #10b981, #059669);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--bg-input);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
}
.btn-danger:hover {
  background: #ef4444;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 0.55rem;
  border-radius: var(--radius-md);
}

/* Tabs & View Switcher */
.view-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Table Design */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.data-table th {
  background: rgba(15, 23, 42, 0.75);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table tbody tr.row-selected {
  background: rgba(59, 130, 246, 0.12);
}

.data-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.student-meta-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.student-name-primary {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.9rem;
}

.student-sub-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: var(--transition);
  overflow: hidden;
}

.modal-overlay.active .modal-box {
  transform: translateY(0);
}

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

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

/* Form Grid */
.form-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 0.35rem;
  border-bottom: 1px dashed var(--border-color);
  margin-top: 0.5rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
  transition: var(--transition);
}

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

/* Toast Notifications */
#toast-box {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  box-shadow: var(--shadow-lg);
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.toast-success { border-left: 4px solid var(--success); }
.toast.toast-error { border-left: 4px solid var(--danger); }
.toast.toast-info { border-left: 4px solid var(--primary); }

@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   OFFICIAL FORM S02 A4 PRINT ENGINE (EXACT REPLICA OF FORM_S02 (1).PDF)
   ========================================================================== */

.print-preview-container {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  padding: 2rem 0;
  background: #525659;
}

.print-preview-container.active {
  display: flex;
}

/* A4 Sheet Definition */
.s02-page,
.s02-page * {
  color: #000000 !important;
  box-sizing: border-box;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.s02-page {
  width: 297mm;
  min-height: 210mm;
  height: 210mm;
  max-height: 210mm;
  padding: 5mm 10mm 4mm 10mm;
  background: #ffffff !important;
  color: #000000 !important;
  font-family: 'Times New Roman', Times, serif;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  page-break-inside: avoid;
  break-inside: avoid;
  overflow: hidden;
}

/* Official Typography & Borders */
.s02-header-title {
  text-align: center;
  font-size: 13pt;
  font-weight: bold;
  letter-spacing: 0.5px;
  line-height: 1.15;
  margin-bottom: 1px;
}

.s02-header-sub1 {
  text-align: center;
  font-size: 10.5pt;
  font-weight: bold;
  margin-bottom: 1px;
}

.s02-header-sub2 {
  text-align: center;
  font-size: 8.5pt;
  font-style: italic;
  line-height: 1.15;
  margin-bottom: 1px;
}

.s02-header-sub3 {
  text-align: center;
  font-size: 8pt;
  margin-bottom: 3px;
}

/* Metadata Bar */
.s02-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 8pt;
  margin-bottom: 3px;
}

.s02-meta-table td {
  padding: 2px 3px;
  vertical-align: middle;
}

.s02-meta-underline {
  border-bottom: 1px dotted #000;
  display: inline-block;
  padding: 0 4px;
  font-weight: bold;
  font-family: Arial, sans-serif;
  font-size: 7.5pt;
}

/* Main Form S02 Grid Table */
.s02-page-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.s02-data-table {
  width: 100%;
  flex: 1;
  border-collapse: collapse;
  margin-bottom: 2px;
  border: 1.5px solid #000000;
}

.s02-data-table tbody {
  height: 100%;
}

.s02-data-table tbody tr {
  height: calc(100% / 5);
  min-height: 26mm;
}

.s02-data-table th, 
.s02-data-table td {
  border: 1px solid #000000;
  padding: 3px 5px;
  font-size: 7.6pt;
  vertical-align: middle;
  line-height: 1.25;
}

.s02-data-table th {
  font-weight: bold;
  text-align: center;
  background-color: #f2f2f2;
  padding: 4px 3px;
  font-size: 7.8pt;
  height: 8mm;
}

.s02-col-sno { width: 3.5%; text-align: center; font-weight: bold; font-size: 8.5pt; }
.s02-col-basic { width: 19%; }
.s02-col-adm { width: 14%; }
.s02-col-parent { width: 20%; }
.s02-col-contact { width: 13.5%; }
.s02-col-aadhaar { width: 14%; }
.s02-col-reason { width: 16%; }

.field-line {
  margin-bottom: 2px;
  word-break: break-word;
}

.field-lbl {
  font-weight: normal;
  display: inline-block;
  font-size: 7.6pt;
}

.field-val {
  font-weight: bold;
  font-family: Arial, sans-serif;
  font-size: 7.8pt;
}

.field-val-blank {
  display: inline-block;
  min-width: 40px;
  border-bottom: 1px dotted #888;
}

/* Footer Authority Signatures & Seals */
.s02-footer-section {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: 7.5pt;
}

.s02-authority-box {
  width: 48.5%;
  border: 1px solid #000;
  padding: 3px 6px;
  line-height: 1.2;
}

.s02-authority-title {
  font-weight: bold;
  text-align: center;
  border-bottom: 1px solid #000;
  padding-bottom: 1px;
  margin-bottom: 3px;
  font-size: 7.5pt;
}

.s02-auth-field {
  display: flex;
  margin-bottom: 1.5px;
}

.s02-auth-field-lbl {
  width: 75px;
}

.s02-auth-field-val {
  flex: 1;
  border-bottom: 1px dotted #000;
  font-weight: bold;
}

.s02-version-tag {
  text-align: right;
  font-size: 7pt;
  font-family: Arial, sans-serif;
  margin-top: 1px;
}

/* ==========================================================================
   PRINT MEDIA RULES (EXACT 1 TO N MULTI-PAGE A4 LANDSCAPE OUTPUT)
   ========================================================================== */
@media print {
  html, body {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    height: auto !important;
  }
  
  .app-navbar,
  .studio-container,
  .modal-overlay,
  #toast-box,
  .no-print,
  .print-floating-actions {
    display: none !important;
  }
  
  .print-preview-container {
    display: block !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 0 !important;
    width: 100% !important;
  }
  
  .s02-page {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 4mm 8mm 3mm 8mm !important;
    width: 297mm !important;
    height: 210mm !important;
    max-height: 210mm !important;
    page-break-after: always !important;
    break-after: page !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .s02-page:last-child {
    page-break-after: auto !important;
    break-after: auto !important;
  }

  @page {
    size: A4 landscape;
    margin: 0;
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-navbar {
    padding: 0.75rem 1rem;
  }
  .studio-container {
    padding: 1rem;
  }
  .form-grid-3, .form-grid-2 {
    grid-template-columns: 1fr;
  }
  .toolbar-top {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group {
    justify-content: flex-start;
  }
}
