/* =========================================================
   DESIGN SYSTEM & CSS VARIABLES
   แดชบอร์ดส่งแผนฯ และคลิปวิดีโอ ธรรมดี ด้วยหลักสูตร 68
   ========================================================= */

:root {
  /* Color Palette */
  --primary: #1e40af;         /* Royal Navy Blue */
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --primary-bg: #eff6ff;

  --accent-emerald: #059669;
  --accent-emerald-light: #d1fae5;
  --accent-emerald-text: #065f46;

  --accent-indigo: #4f46e5;
  --accent-indigo-light: #e0e7ff;
  
  --accent-amber: #d97706;
  --accent-amber-light: #fef3c7;
  --accent-amber-text: #92400e;

  --accent-rose: #e11d48;
  --accent-rose-light: #ffe4e6;
  --accent-rose-text: #9f1239;

  /* Neutral Slate */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Typography */
  --font-heading: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.06);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: #f4f6fb;
  color: var(--slate-800);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========================================================
   HEADER & NAVBAR
   ========================================================= */

.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e40af 100%);
  color: white;
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.app-header::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 40%;
  background: radial-gradient(circle at top right, rgba(255,255,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.header-container {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  position: relative;
  z-index: 1;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand-logo-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo-img {
  width: 62px;
  height: 62px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.25));
  transition: transform var(--transition-fast);
}

.brand-logo-img:hover {
  transform: scale(1.05);
}

.brand-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: #fbbf24;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.brand-top-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.brand-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  background: rgba(251, 191, 36, 0.2);
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.4);
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-full);
}

.dev-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-heading);
  font-size: 0.775rem;
  font-weight: 500;
  background: rgba(56, 189, 248, 0.18);
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 0.15rem 0.65rem;
  border-radius: var(--radius-full);
  backdrop-filter: blur(6px);
}

.dev-badge strong {
  color: #ffffff;
  font-weight: 600;
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.25;
  color: #ffffff;
  letter-spacing: -0.2px;
}

.brand-subtitle {
  font-size: 0.95rem;
  color: #cbd5e1;
  margin-top: 0.2rem;
}

.highlight-title {
  color: #fbbf24;
  font-weight: 600;
}

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

/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: #2563eb;
  color: white;
}
.btn-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border-color: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.25);
}

.btn-outline {
  background: transparent;
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.btn-ghost {
  background: transparent;
  color: var(--slate-600);
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}
.btn-ghost:hover {
  color: var(--slate-900);
  background: var(--slate-200);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-video {
  background: #dc2626;
  color: white;
}
.btn-video:hover {
  background: #b91c1c;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-pdf {
  background: #4f46e5;
  color: white;
}
.btn-pdf:hover {
  background: #4338ca;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-info-outline {
  background: var(--slate-100);
  color: var(--slate-700);
  border-color: var(--slate-300);
}
.btn-info-outline:hover {
  background: var(--slate-200);
  color: var(--slate-900);
}

/* =========================================================
   LIVE SYNC BANNER
   ========================================================= */

.sync-banner {
  background: #1e293b;
  color: #94a3b8;
  font-size: 0.8rem;
  padding: 0.35rem 1.25rem;
  border-bottom: 1px solid #334155;
}

.sync-banner-content {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
  box-shadow: 0 0 6px #10b981;
}

.status-dot.syncing {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.spinning {
  animation: spin 1s linear infinite;
}

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

/* =========================================================
   MAIN LAYOUT & KPI SECTION
   ========================================================= */

.main-content {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  flex: 1;
  width: 100%;
}

.kpi-section {
  margin-bottom: 1.5rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.1rem;
}

.kpi-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  gap: 1.1rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.bg-blue { background: #dbeafe; color: #1d4ed8; }
.bg-emerald { background: #d1fae5; color: #047857; }
.bg-indigo { background: #e0e7ff; color: #4338ca; }
.bg-amber { background: #fef3c7; color: #b45309; }

.kpi-info {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--slate-500);
}

.kpi-value-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1.15;
}

.kpi-unit {
  font-size: 0.85rem;
  color: var(--slate-500);
  font-weight: 500;
}

.kpi-subtext {
  font-size: 0.775rem;
  color: var(--slate-500);
  margin-top: 0.15rem;
}

.text-emerald { color: #059669 !important; }
.text-indigo { color: #4f46e5 !important; }
.text-amber { color: #d97706 !important; }

/* =========================================================
   CHARTS & ANALYTICS SECTION
   ========================================================= */

.charts-section {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

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

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--slate-800);
}

.section-title i {
  color: var(--primary);
  font-size: 1.1rem;
}

.section-title h2 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
}

.btn-text {
  background: transparent;
  border: none;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}
.btn-text:hover {
  background: var(--primary-bg);
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  transition: all var(--transition-normal);
}

.charts-grid.collapsed {
  display: none;
}

.chart-card {
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-200);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.chart-header {
  margin-bottom: 0.75rem;
}

.chart-header h3 {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--slate-700);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.chart-header h3 i {
  color: var(--primary-light);
  font-size: 0.85rem;
}

.chart-body {
  position: relative;
  height: 220px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   FILTER & SEARCH CONTROLS
   ========================================================= */

.controls-section {
  margin-bottom: 1.25rem;
}

.controls-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}

.search-bar-wrap {
  margin-bottom: 1rem;
}

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--slate-400);
  font-size: 1rem;
  pointer-events: none;
}

.search-input-group input {
  width: 100%;
  padding: 0.75rem 2.75rem 0.75rem 2.6rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius-md);
  background: var(--slate-50);
  color: var(--slate-900);
  transition: all var(--transition-fast);
}

.search-input-group input:focus {
  outline: none;
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.clear-search-btn {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--slate-400);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 50%;
}
.clear-search-btn:hover {
  color: var(--slate-700);
}

.filters-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) auto;
  gap: 0.85rem;
  align-items: flex-end;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-item label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--slate-600);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.filter-item select {
  font-family: var(--font-body);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-300);
  background: white;
  color: var(--slate-800);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}

.filter-item select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.filter-actions {
  display: flex;
  align-items: flex-end;
}

.quick-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--slate-100);
  flex-wrap: wrap;
}

.pill-label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--slate-500);
}

.pill-btn {
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  color: var(--slate-700);
  font-family: var(--font-heading);
  font-size: 0.775rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.pill-btn:hover {
  background: var(--slate-200);
  color: var(--slate-900);
}

.pill-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* =========================================================
   RESULTS HEADER & VIEW SWITCH
   ========================================================= */

.results-header-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.results-count {
  font-size: 0.9rem;
  color: var(--slate-600);
}

.results-count strong {
  color: var(--primary);
  font-size: 1.05rem;
}

.view-switch-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.view-label {
  font-family: var(--font-heading);
  font-size: 0.825rem;
  color: var(--slate-500);
}

.view-toggle-buttons {
  display: flex;
  background: var(--slate-200);
  padding: 2px;
  border-radius: var(--radius-sm);
}

.toggle-btn {
  background: transparent;
  border: none;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--slate-600);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.toggle-btn.active {
  background: white;
  color: var(--slate-900);
  box-shadow: var(--shadow-sm);
}

/* =========================================================
   CARD GRID VIEW
   ========================================================= */

.cards-grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.25rem;
}

.school-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
}

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

.card-top {
  padding: 1rem 1.15rem 0.75rem;
  border-bottom: 1px solid var(--slate-100);
  background: #fafcff;
}

.card-tags {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-cluster {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  background: #e0f2fe;
  color: #0369a1;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.tag-size {
  font-size: 0.725rem;
  background: var(--slate-100);
  color: var(--slate-600);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
}

.card-school-name {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--slate-900);
  line-height: 1.35;
  margin-bottom: 0.25rem;
}

.card-group-type {
  font-size: 0.8rem;
  color: var(--slate-500);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-group-type.type-old {
  color: #0d9488;
}
.card-group-type.type-new {
  color: #ea580c;
}

.card-body {
  padding: 1rem 1.15rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.info-row {
  display: flex;
  font-size: 0.85rem;
  gap: 0.5rem;
}

.info-label {
  color: var(--slate-500);
  min-width: 80px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.info-value {
  color: var(--slate-800);
  font-weight: 500;
}

.grade-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.2rem;
}

.grade-pill {
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #475569;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--slate-200);
}

.local-curr-snippet {
  background: #f8fafc;
  border-left: 3px solid #3b82f6;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  color: var(--slate-700);
  border-radius: 0 4px 4px 0;
  line-height: 1.4;
  margin-top: 0.2rem;
}

.card-footer {
  padding: 0.85rem 1.15rem;
  background: white;
  border-top: 1px solid var(--slate-100);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* =========================================================
   TABLE VIEW
   ========================================================= */

.table-view {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

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

.data-table thead th {
  background: #f8fafc;
  color: var(--slate-700);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.825rem;
  padding: 0.85rem 1rem;
  border-bottom: 1.5px solid var(--slate-200);
  white-space: nowrap;
}

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

.data-table tbody tr:hover {
  background: #f8fafc;
}

.pagination-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--slate-200);
  background: #f8fafc;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.pagination-info {
  font-size: 0.825rem;
  color: var(--slate-500);
}

.pagination-controls {
  display: flex;
  gap: 0.35rem;
}

.page-btn {
  background: white;
  border: 1px solid var(--slate-300);
  color: var(--slate-700);
  min-width: 32px;
  height: 32px;
  border-radius: 6px;
  font-family: var(--font-heading);
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* =========================================================
   STATUS BADGES
   ========================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-success {
  background: var(--accent-emerald-light);
  color: var(--accent-emerald-text);
}

.badge-muted {
  background: var(--slate-100);
  color: var(--slate-500);
}

.badge-yt {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-drive {
  background: #dbeafe;
  color: #1d4ed8;
}

/* =========================================================
   MODALS
   ========================================================= */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
}

.modal-dialog {
  position: relative;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
  z-index: 1001;
}

.modal-md { max-width: 600px; }
.modal-lg { max-width: 850px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  margin-bottom: 0.35rem;
}

.modal-title-wrap h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--slate-900);
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--slate-500);
  margin-top: 0.15rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--slate-400);
  font-size: 1.25rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--slate-200);
  color: var(--slate-800);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: #f8fafc;
  border-top: 1px solid var(--slate-200);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Video Player in Modal */
.video-player-container {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 1rem;
}

.video-player-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-empty-notice {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--slate-400);
  text-align: center;
  padding: 1rem;
}

.video-meta-details {
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid var(--slate-200);
  font-size: 0.875rem;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-table th {
  text-align: left;
  padding: 0.6rem 0.8rem;
  width: 32%;
  color: var(--slate-500);
  font-family: var(--font-heading);
  font-size: 0.825rem;
  border-bottom: 1px solid var(--slate-100);
}

.detail-table td {
  padding: 0.6rem 0.8rem;
  color: var(--slate-800);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--slate-100);
}

/* =========================================================
   EMPTY STATE & TOAST
   ========================================================= */

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  background: white;
  border-radius: var(--radius-md);
  border: 1px dashed var(--slate-300);
}

.empty-icon {
  font-size: 3rem;
  color: var(--slate-300);
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--slate-700);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--slate-500);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #0f172a;
  color: white;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-size: 0.875rem;
  z-index: 2000;
  animation: slideUp 0.3s ease-out;
}

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

/* =========================================================
   FOOTER
   ========================================================= */

.app-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 1.75rem 1.25rem;
  margin-top: auto;
  border-top: 1px solid #1e293b;
  font-size: 0.825rem;
}

.footer-container {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

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

.footer-logo-img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  flex-shrink: 0;
}

.footer-left strong {
  color: white;
}

.developer-credit-footer {
  color: #38bdf8;
  font-family: var(--font-heading);
  font-size: 0.825rem;
  margin-top: 0.25rem;
}

.developer-credit-footer strong {
  color: #fbbf24;
}

.pdpa-notice {
  color: #64748b;
  margin-top: 0.25rem;
  font-size: 0.775rem;
}

.deploy-tag {
  background: #1e293b;
  color: #38bdf8;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid #334155;
  font-family: var(--font-heading);
  font-size: 0.75rem;
}

/* =========================================================
   RESPONSIVE DESIGN
   ========================================================= */

@media (max-width: 900px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .filters-wrap {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .brand-text h1 {
    font-size: 1.2rem;
  }
  .cards-grid-view {
    grid-template-columns: 1fr;
  }
  .filters-wrap {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .header-actions .btn {
    flex: 1;
  }
}

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

@media print {
  .app-header, .sync-banner, .controls-section, .view-switch-wrap, .btn, .modal, .toast, .app-footer, .header-actions {
    display: none !important;
  }
  body {
    background: white;
    color: black;
  }
  .cards-grid-view {
    display: block;
  }
  .school-card {
    page-break-inside: avoid;
    border: 1px solid #ccc;
    margin-bottom: 1rem;
  }
}
