:root {
  /* Colors */
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --secondary: #10B981;
  --secondary-hover: #059669;
  --danger: #EF4444;
  --bg-color: #F8FAFC;
  --surface: #FFFFFF;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border: #E2E8F0;
  
  /* Layout */
  --sidebar-w: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  
  /* Transitions */
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --bg-color: #0F172A;
  --surface: #1E293B;
  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --border: #334155;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

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

body {
  font-family: 'Prompt', 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
  overflow-x: hidden;
}

/* ===== Typography ===== */
h1, h2, h3, h4 { font-weight: 600; }
.card-title { font-size: 1.1rem; margin-bottom: 1rem; color: var(--text-main); }
.page-title { font-size: 1.5rem; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: var(--transition);
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
  line-height: 1.2;
}

.logo-icon { font-size: 1.75rem; }

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
}

.nav-menu {
  list-style: none;
  padding: 1rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  transition: var(--transition);
}

.nav-item:hover {
  background: rgba(79, 70, 229, 0.05);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding-top: 70px; /* Space for topbar */
  min-height: 100vh;
  transition: margin-left 0.3s;
}

.main-content.expanded {
  margin-left: 0;
}

/* ===== Topbar ===== */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-w);
  height: 70px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  border-bottom: 1px solid var(--border);
  z-index: 90;
  transition: left 0.3s;
}

[data-theme="dark"] .topbar {
  background: rgba(30, 41, 59, 0.8);
}

.topbar.expanded {
  left: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
}

.search-box {
  position: relative;
}

.search-box input {
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  width: 250px;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ===== Pages ===== */
.page {
  display: none;
  padding: 2rem;
  animation: fadeIn 0.4s ease;
}

.page.active {
  display: block;
}

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

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

.filter-bar {
  display: flex;
  gap: 1rem;
}

.filter-bar input, .filter-bar select {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-family: inherit;
  outline: none;
}

.filter-bar input:focus, .filter-bar select:focus {
  border-color: var(--primary);
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  transition: transform 0.3s, box-shadow 0.3s;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.stat-blue::before { background: #3B82F6; }
.stat-green::before { background: #10B981; }
.stat-purple::before { background: #8B5CF6; }
.stat-orange::before { background: #F59E0B; }

.stat-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}

.stat-blue .stat-icon { background: rgba(59, 130, 246, 0.1); }
.stat-green .stat-icon { background: rgba(16, 185, 129, 0.1); }
.stat-purple .stat-icon { background: rgba(139, 92, 246, 0.1); }
.stat-orange .stat-icon { background: rgba(245, 158, 11, 0.1); }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--text-muted); font-size: 0.875rem; }

/* ===== Charts Row ===== */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

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

/* ===== Card & Tables ===== */
.card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.table-wrapper { overflow-x: auto; }

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

.data-table th, .data-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background: rgba(0,0,0,0.02); }
[data-theme="dark"] .data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.875rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--border); color: var(--text-main); }
.btn-secondary:hover { filter: brightness(0.9); }
.btn-success { background: var(--secondary); color: white; }
.btn-success:hover { background: var(--secondary-hover); }
.btn-info { background: #3B82F6; color: white; }
.btn-info:hover { background: #2563EB; }

/* ===== Gallery Grid & Photos ===== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.photo-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
  aspect-ratio: 1;
  transition: var(--transition);
}

.photo-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow);
}

.photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  color: white;
  padding: 1rem 0.5rem 0.5rem;
  font-size: 0.75rem;
  opacity: 0;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
}

.photo-card:hover .photo-overlay { opacity: 1; }

.video-icon {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: white;
  background: rgba(0,0,0,0.5);
  width: 50px; height: 50px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ===== Activities Grid ===== */
.activities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.activity-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.activity-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.activity-title { font-size: 1.125rem; font-weight: 600; color: var(--text-main); }
.activity-date { font-size: 0.875rem; color: var(--text-muted); }
.activity-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.activity-actions {
  display: flex;
  gap: 0.5rem;
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.lightbox.active { display: flex; opacity: 1; }

.lightbox-img {
  max-width: 90%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 30px rgba(0,0,0,0.5);
}

.lightbox-close {
  position: absolute; top: 20px; right: 20px;
  background: none; border: none; color: white;
  font-size: 2rem; cursor: pointer;
}

.lightbox-prev, .lightbox-next {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.1); border: none; color: white;
  font-size: 2rem; padding: 1rem; cursor: pointer; border-radius: 50%;
  transition: background 0.3s;
}

.lightbox-prev:hover, .lightbox-next:hover { background: rgba(255,255,255,0.3); }
.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

.lightbox-caption {
  position: absolute; bottom: 20px; left: 0; width: 100%;
  text-align: center; color: white; padding: 1rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
}

/* ===== Report Builder ===== */
.report-builder {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 2rem;
  height: calc(100vh - 180px);
}

.report-settings {
  overflow-y: auto;
  padding-right: 0.5rem;
}

.report-preview-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.02);
}

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

.preview-zoom {
  display: flex; align-items: center; gap: 1rem;
}

.preview-zoom button {
  background: var(--surface); border: 1px solid var(--border);
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.preview-zoom button:hover { background: var(--border); }

.preview-scroll {
  flex: 1;
  overflow: auto;
  padding: 2rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #E2E8F0;
}

[data-theme="dark"] .preview-scroll { background: #0F172A; }

/* The A4 Paper */
.report-preview {
  width: 794px; /* A4 width at 96dpi */
  min-height: 1123px; /* A4 height at 96dpi */
  background: white;
  color: black;
  box-shadow: 0 5px 20px rgba(0,0,0,0.15);
  margin: 0 auto;
  transform-origin: top center;
  transition: transform 0.2s;
  overflow: hidden;
  position: relative;
}

.report-page {
  padding: 50px 60px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block; margin-bottom: 0.5rem;
  font-weight: 500; font-size: 0.875rem;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-color);
  color: var(--text-main);
  font-family: inherit;
  outline: none;
  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 rgba(79,70,229,0.1);
}

.template-selector {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
}
.template-opt {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}
.template-opt:hover { background: rgba(79,70,229,0.05); }
.template-opt.active {
  border-color: var(--primary);
  background: rgba(79,70,229,0.1);
  color: var(--primary);
  font-weight: 600;
}
.template-preview { display: block; font-size: 1.5rem; margin-bottom: 0.25rem; }

.form-actions {
  display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1.5rem;
}

.photo-select-actions {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;
}
.selected-count { font-size: 0.875rem; color: var(--primary); font-weight: 600; }

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

.photo-select-item {
  aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden;
  position: relative; cursor: pointer; border: 2px solid transparent;
}
.photo-select-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-select-item.selected { border-color: var(--primary); }
.photo-select-item.selected::after {
  content: '✓'; position: absolute; top: 5px; right: 5px;
  background: var(--primary); color: white; width: 20px; height: 20px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}

/* Report Internal Styles (Classic Template) */
.report-header-section { text-align: center; margin-bottom: 2rem; position: relative; }
.report-school-name { font-size: 1.25rem; margin-bottom: 0.5rem; }
.report-divider { width: 100px; height: 3px; background: #000; margin: 0 auto 1.5rem; }
.report-main-title { font-size: 2rem; font-weight: 700; margin-bottom: 0.5rem; line-height: 1.3; }
.report-date { font-size: 1.1rem; color: #555; }
.report-description-section { font-size: 1.1rem; line-height: 1.6; margin-bottom: 2rem; text-indent: 2rem; }
.report-photos-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 3rem; }
.report-photo-item { border: 1px solid #ddd; padding: 10px; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.report-photo-item img { width: 100%; height: 200px; object-fit: cover; }
.report-footer-section { padding-top: 2rem; margin-top: auto; display: flex; justify-content: flex-end; }
.report-signature { text-align: center; width: 250px; }
.report-author { font-size: 1.1rem; font-weight: 600; margin-top: 30px; }
.report-position { font-size: 1rem; color: #555; }

.preview-empty { grid-column: 1 / -1; text-align: center; padding: 4rem; color: #aaa; border: 2px dashed #ddd; border-radius: 10px; }

/* Responsive */
@media (max-width: 1024px) {
  .report-builder { grid-template-columns: 1fr; height: auto; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { left: 0; }
  .mobile-menu-btn { display: block; }
}

/* Toast */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface); color: var(--text-main); padding: 1rem; border-radius: var(--radius-sm); border-left: 4px solid var(--primary); box-shadow: var(--shadow-lg); animation: slideInRight 0.3s ease; display: flex; align-items: center; gap: 0.75rem; }
.toast.success { border-color: var(--secondary); }
.toast.error { border-color: var(--danger); }
@keyframes slideInRight { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
