/* =========================
   CSS Variables & Root Styles
========================= */
:root {
  --bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --card: #f3f4f6;
  --border: #e5e7eb;
  --school-blue: #004080;
  --school-navy: #002b5c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================
   Base Reset & Typography
========================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  scroll-behavior: smooth;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--brand-2);
  text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* =========================
   Header & Navigation
========================= */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.3s ease;
}

.site-header.scrolled {
  box-shadow: var(--shadow-md);
}

.header-inner {
  display: flex;
  flex-direction: column;
  padding: 0.8rem 0;
  gap: 0.5rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

/* --- Brand Section --- */
.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-shrink: 0;
}

.logo {
  height: 80px;
  width: auto;
  object-fit: contain;
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.05);
}

.site-title a {
  display: flex;
  flex-direction: column;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  line-height: 1.2;
  transition: color 0.3s ease;
}

.site-title a:hover {
  color: var(--school-blue);
  text-decoration: none;
}

.site-title small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
  margin-top: 2px;
}

/* --- Navigation Menu --- */
#nav-menu {
  width: 100%;
  background: var(--school-blue);
  border-radius: var(--radius-md);
  padding: 0.5rem;
}

.nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 0.25rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.nav li {
  margin: 0;
  padding: 0;
  display: inline-block;
}

.nav a {
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  display: block;
  position: relative;
  transition: var(--transition);
  padding: 10px 14px;
  color: white;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.nav a:hover,
.nav a:focus {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  text-decoration: none;
  outline: none;
}

.nav a:active {
  transform: translateY(0);
}

.nav a.active {
  background: rgba(255, 255, 255, 0.3);
  font-weight: 600;
}

/* Underline effect */
.nav a::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  width: 0;
  height: 2px;
  background: white;
  transition: width 0.3s ease, left 0.3s ease;
}

.nav a:hover::after,
.nav a.active::after {
  width: 60%;
  left: 20%;
}

/* --- Hamburger Menu Toggle --- */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 12px;
  background-color: var(--school-navy);
  border: none;
  border-radius: var(--radius-md);
  transition: background-color 0.3s ease;
  z-index: 1001;
}

.menu-toggle:hover {
  background-color: #003a6e;
}

.menu-toggle:focus {
  outline: 2px solid var(--school-blue);
  outline-offset: 2px;
}

.menu-toggle span {
  display: block;
  width: 25px;
  height: 3px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hamburger to X Animation */
.menu-toggle.active span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
  transform: translateX(-10px);
}

.menu-toggle.active span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* =========================
   Mobile Navigation (≤768px)
========================= */
@media (max-width: 768px) {
  .header-top {
    position: relative;
  }

  .brand {
    flex: 1;
    min-width: 0;
  }

  .site-title a {
    font-size: 1rem;
  }

  .site-title small {
    font-size: 0.7rem;
  }

  .menu-toggle {
    display: flex;
  }

  #nav-menu {
    background: var(--school-navy);
    padding: 0;
  }

  .nav {
    flex-direction: column;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
  }

  .nav.active {
    max-height: 800px;
    opacity: 1;
    box-shadow: var(--shadow-md);
  }

  .nav li {
    width: 100%;
    display: block;
  }

  .nav a {
    padding: 16px 20px;
    text-align: left;
    border-radius: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .nav a::after {
    display: none;
  }

  .nav li:last-child a {
    border-bottom: none;
  }

  .nav a:hover,
  .nav a:focus {
    background-color: rgba(255, 255, 255, 0.15);
    padding-left: 28px;
    transform: none;
  }

  .nav a:active {
    background-color: rgba(255, 255, 255, 0.25);
  }

  .nav a.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-left: 4px solid white;
    padding-left: 24px;
  }
}

/* =========================
   Desktop Navigation (≥769px)
========================= */
@media (min-width: 769px) {
  .menu-toggle {
    display: none;
  }
}

/* =========================
   Hero Slider
========================= */
.hero {
  margin: 1.5rem 0 2rem;
}

.slider {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.slide {
  display: none;
  position: relative;
}

.slide.active {
  display: block;
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide img {
  width: 100%;
  height: 360px;
  object-fit: cover;
  display: block;
}

.slide .caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1rem 1.5rem;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 500;
}

.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  border: none;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 1.4rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.slider-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: translateY(-50%) scale(1.1);
}

.slider-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.slider-btn.prev {
  left: 0.8rem;
}

.slider-btn.next {
  right: 0.8rem;
}

/* =========================
   Layout Grid & Cards
========================= */
.grid.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0 2rem;
}

@media (min-width: 800px) {
  .grid.two-col {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card h2 {
  color: var(--school-blue);
  margin-bottom: 1rem;
}

/* =========================
   Buttons
========================= */
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-md);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--brand-2);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn.btn-secondary {
  background: var(--school-blue);
}

.btn.btn-secondary:hover {
  background: var(--school-navy);
}

/* =========================
   Lists (Notices, Achievements, Links)
========================= */
ul.notices,
ul.achievements,
ul.quick-links {
  list-style: none;
  margin: 1rem 0;
}

ul.notices li,
ul.achievements li,
ul.quick-links li {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

ul.notices li:hover,
ul.achievements li:hover,
ul.quick-links li:hover {
  background: var(--card);
  padding-left: 1rem;
}

ul.notices li:last-child,
ul.achievements li:last-child,
ul.quick-links li:last-child {
  border-bottom: none;
}

ul.notices li small {
  color: var(--muted);
  margin-left: 0.5rem;
  font-size: 0.85rem;
}

/* =========================
   Gallery Grid
========================= */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.gallery-grid img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
}

.gallery-grid img:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

/* =========================
   Tables
========================= */
.table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table th,
.table td {
  border: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
}

.table th {
  background: var(--school-blue);
  color: white;
  font-weight: 600;
}

.table tbody tr:hover {
  background: var(--card);
}

.table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

/* =========================
   Admin Navigation & Badges
========================= */
.admin-nav {
  display: flex;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
}

.badge.badge-success {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}

.badge.badge-warning {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.badge.badge-danger {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

/* =========================
   Forms
========================= */
.form {
  max-width: 640px;
}

.form label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  font-weight: 600;
  color: var(--text);
}

.form input[type="text"],
.form input[type="date"],
.form input[type="email"],
.form input[type="password"],
.form input[type="file"],
.form textarea,
.form select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
  background: white;
}

.form input:focus,
.form textarea:focus,
.form select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form textarea {
  min-height: 120px;
  resize: vertical;
}

.form button {
  margin-top: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-error {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* =========================
   Footer
========================= */
.site-footer {
  background: #111827;
  color: #e5e7eb;
  margin-top: 3rem;
  border-top: 4px solid var(--school-blue);
}

.footer-inner {
  padding: 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-inner p {
  margin: 0;
}

.footer-inner a {
  color: #93c5fd;
}

.footer-inner a:hover {
  color: #dbeafe;
}

/* =========================
   Accessibility & Utilities
========================= */
.nav a:focus-visible,
.btn:focus-visible,
.menu-toggle:focus-visible,
.form input:focus-visible,
.form textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =========================
   Responsive Optimizations
========================= */
@media (max-width: 768px) {
  .container {
    padding: 0 0.75rem;
  }

  .hero {
    margin: 1rem 0;
  }

  .slide img {
    height: 240px;
  }

  .card {
    padding: 1rem;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .header-inner {
    padding: 0.8rem 1rem;
  }

  .nav {
    gap: 0.3rem;
  }

  .nav a {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}