/* ========================================
   CSS Custom Properties
   ======================================== */
:root {
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --primary-light: #e3f2fd;
  --primary-accent: #bbdefb;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --error: #d32f2f;
  --error-bg: #ffebee;
  --warning: #f57c00;
  --warning-bg: #fff3e0;
  --info: #0277bd;
  --info-bg: #e1f5fe;
  --gray: #555;
  --border: #ddd;
  --radius: 8px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.08);
  --shadow: 0 2px 10px rgba(0,0,0,.1);
  --text: #222;
}

/* ========================================
   Reset
   ======================================== */
*, *::before, *::after { box-sizing: border-box; }

/* ========================================
   Base
   ======================================== */
body {
  font-family: system-ui, -apple-system, Arial, sans-serif;
  background: #f4f6fb;
  margin: 0;
  padding: 0;
  color: var(--text);
  line-height: 1.65;
}

/* ========================================
   Layout
   ======================================== */
main {
  padding: 2rem 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

h1 { color: var(--primary); margin-top: 0; }
h2 { color: var(--primary); }
h3 { color: var(--primary); }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========================================
   HERO SECTION
   ======================================== */
.hero {
  position: relative;
  background: url('/images/hero.webp') no-repeat center center / cover;
  min-height: 40vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 900px;
  padding: 2rem;
  animation: fadeInUp 1s ease-out;
  top: 30px;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: #fff;
  text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  display: inline-block;
  padding-left: 100%;
  animation: scrollLeft 20s linear infinite;
}

@keyframes scrollLeft {
  0%   { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-100%, 0, 0); }
}

.hero h1:hover { animation-play-state: paused; }

.hero p {
  font-size: 1.4rem;
  margin-bottom: 2rem;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.7);
}

.hero .btn-primary {
  margin-top: 1rem;
  padding: 0.9rem 2rem;
  font-size: 1.1rem;
}

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

/* ========================================
   Buttons
   ======================================== */
.btn-primary {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  transition: background 0.2s, box-shadow 0.2s;
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
  color: white;
  text-decoration: none;
}

/* ========================================
   Grid Section (Vision, Mission)
   ======================================== */
.grid-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  padding: 3rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

.grid-item { text-align: center; }

.grid-item img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

/* ========================================
   CTA Section
   ======================================== */
.cta {
  text-align: center;
  background: var(--primary);
  color: white;
  padding: 2.5rem 2rem;
  border-radius: var(--radius);
  margin: 3rem 2rem;
}

.cta h2 { color: white; margin-top: 0; }
.cta p  { font-size: 1.2rem; margin-bottom: 1rem; }

.cta-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

/* CTA box is primary blue, so its buttons need contrast to read as links */
.cta .btn-primary {
  background: white;
  color: var(--primary);
  border: 2px solid white;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cta .btn-primary:hover,
.cta .btn-primary:focus-visible {
  background: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ========================================
   Intro & Highlights
   ======================================== */
.intro {
  max-width: 800px;
  margin: 2rem auto;
  text-align: center;
}

.intro h2 { color: var(--primary); margin-bottom: 1rem; font-size: 2rem; }

.highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  max-width: 1100px;
  margin: 3rem auto;
}

.highlight-box {
  flex: 1 1 280px;
  background: var(--primary-light);
  border-left: 5px solid var(--primary);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.highlight-box h3    { color: var(--primary); margin-bottom: 0.75rem; }
.highlight-box p,
.highlight-box ul    { color: #222; line-height: 1.6; }
.highlight-box ul    { list-style: none; padding-left: 0; }
.highlight-box li    { margin-bottom: 0.5rem; }

/* ========================================
   Values Section
   ======================================== */
.values-section {
  background: var(--primary-light);
  border-left: 5px solid var(--primary);
  padding: 1.5rem;
  margin-top: 2rem;
  border-radius: var(--radius);
}

.values-section h3   { color: var(--primary); margin-bottom: 0.75rem; font-size: 1.4rem; }
.values-section ul   { list-style: none; padding-left: 0; margin: 0; }
.values-section li   { margin-bottom: 0.75rem; font-size: 1.05rem; color: #222; line-height: 1.6; }
.values-section li strong { color: var(--primary); }

/* ========================================
   Global Form Elements
   ======================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-weight: 600;
  color: #333;
  font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.15);
}

input[readonly],
input[disabled] {
  background: #f0f0f0;
  color: var(--gray);
  cursor: not-allowed;
}

select { cursor: pointer; background-color: white; }

textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.55;
}

button[type="submit"] {
  display: block;
  width: 100%;
  background: var(--primary);
  color: white;
  padding: 0.9rem 1.75rem;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  margin-top: 0.5rem;
}

button[type="submit"]:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

/* ========================================
   Form Section Cards (Apply / Alumni)
   ======================================== */
.form-section {
  background: #fff;
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-section h2 {
  margin: 0 0 0.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--primary);
  color: var(--primary);
  font-size: 1.15rem;
}

/* ========================================
   Academics Container
   ======================================== */
.academics-container {
  max-width: 900px;
  margin: 2.5rem auto;
  padding: 2rem;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.academics-container h2 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

.course-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.course-box {
  background: var(--primary-light);
  padding: 1rem 1.5rem;
  border-left: 5px solid var(--primary);
  border-radius: 6px;
}

.course-box h3 { margin: 0 0 0.5rem; color: var(--primary); }

.academics-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dashboard-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2rem;
}

/* ========================================
   Auth Forms (Login, Register, etc.)
   ======================================== */
.auth-container {
  max-width: 480px;
  margin: 2.5rem auto;
  background: #ffffff;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  border-top: 4px solid var(--primary);
}

.auth-container h1 {
  text-align: center;
  margin-bottom: 1.75rem;
  color: var(--primary);
  font-size: 1.8rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.auth-form .form-group { gap: 0.3rem; }

.auth-form p {
  text-align: center;
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--gray);
}

.auth-form a { color: var(--primary); text-decoration: none; }
.auth-form a:hover { text-decoration: underline; }

/* ========================================
   Contact Container
   ======================================== */
.contact-container {
  max-width: 620px;
  margin: 2.5rem auto;
  background: #fff;
  padding: 2rem;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.contact-container h1,
.contact-container h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--primary);
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-form label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

/* ========================================
   Apply Container
   ======================================== */
.apply-container {
  max-width: 720px;
  margin: 2.5rem auto;
  background: #fff;
  padding: 2rem;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.application-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin: 1.5rem 0;
}

/* ========================================
   Admin Tables
   ======================================== */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

th, td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

thead th {
  background: var(--primary-light);
  font-weight: 700;
  color: var(--primary);
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

tbody tr:hover { background: #f5faff; }
tbody tr:last-child td { border-bottom: none; }

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 30px !important;
}

th.sortable:hover { background: var(--primary-accent) !important; }
th.sortable::after { content: "↕"; position: absolute; right: 10px; opacity: 0.4; font-size: 0.9em; }
th.sortable.asc::after  { content: "↑"; opacity: 1; font-weight: bold; }
th.sortable.desc::after { content: "↓"; opacity: 1; font-weight: bold; }

/* Mobile stacked table: each row becomes a card, each cell a "label | value" pair.
   A grid (not an absolutely positioned label) keeps long labels and values from overlapping. */
@media (max-width: 640px) {
  .table-wrapper { overflow-x: hidden; }

  .table-wrapper table,
  .table-wrapper thead,
  .table-wrapper tbody,
  .table-wrapper th,
  .table-wrapper td,
  .table-wrapper tr { display: block; }
  .table-wrapper thead tr { position: absolute; top: -9999px; left: -9999px; }

  .table-wrapper tbody tr {
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    background: #fafafa;
    box-shadow: var(--shadow-sm);
  }

  .table-wrapper td {
    display: grid;
    grid-template-columns: minmax(5.5rem, 38%) minmax(0, 1fr);
    column-gap: 0.75rem;
    align-items: start;
    justify-items: start; /* badges and buttons keep their natural width */
    border: none;
    padding: 0.5rem 0;
    min-height: 2rem;
    overflow-wrap: anywhere;
  }

  .table-wrapper td::before {
    content: attr(data-label);
    font-weight: 700;
    color: #444;
    font-size: 0.85rem;
  }

  /* Wide content (action buttons, details, messages) goes under its label */
  .table-wrapper td.details-cell,
  .table-wrapper td.message-cell { grid-template-columns: minmax(0, 1fr); row-gap: 0.4rem; }
}

/* ========================================
   Status Badges
   ======================================== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}

.status-pending  { background: var(--warning); }
.status-approved { background: var(--success); }
.status-rejected { background: var(--error); }
.status-no-application { background: #757575; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  background: var(--primary);
}

.badge-admin { background: var(--error); }

/* ========================================
   Cards (Details/Summary accordion)
   ======================================== */
.card {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.card summary {
  padding: 1rem 1.25rem;
  background: var(--primary-light);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: #333;
  list-style: none;
}

.card summary::-webkit-details-marker { display: none; }

.card summary::after {
  content: '▼';
  font-size: 0.75rem;
  transition: transform 0.2s;
  flex-shrink: 0;
  opacity: 0.7;
}

.card[open] summary::after { transform: rotate(180deg); }

.card .details {
  padding: 1.25rem;
  background: #fafafa;
  border-top: 1px solid var(--border);
  line-height: 1.7;
}

.card .section { margin-bottom: 1rem; }
.card .section:last-child { margin-bottom: 0; }
.card .section strong { color: var(--primary); display: block; margin-bottom: 0.25rem; }

.card pre {
  background: #fff;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  border: 1px solid #eee;
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0.4rem 0;
  font-size: 0.92rem;
}

/* ========================================
   Profile / Info Card
   ======================================== */
.profile-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}

.profile-card h2 { margin-top: 0; }

/* ========================================
   Messages
   ======================================== */
.error {
  color: var(--error);
  background: var(--error-bg);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  border-left: 4px solid var(--error);
  margin-bottom: 1rem;
  font-weight: 600;
}

.success {
  color: var(--success);
  background: var(--success-bg);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  border-left: 4px solid var(--success);
  margin-bottom: 1rem;
  font-weight: 600;
}

.warning {
  color: var(--warning);
  background: var(--warning-bg);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  border-left: 4px solid var(--warning);
  margin-bottom: 1rem;
  font-weight: 600;
}

.info {
  color: var(--info);
  background: var(--info-bg);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  border-left: 4px solid var(--info);
  margin-bottom: 1rem;
  font-weight: 600;
}

/* ========================================
   Footer
   ======================================== */
.footer {
  background: #111827;
  color: #fff;
  text-align: center;
  padding: 1.5rem 1rem;
  margin-top: 3rem;
}

.footer-social { margin-bottom: 0.75rem; }

.footer-social a {
  color: #fff;
  margin: 0 10px;
  display: inline-block;
  transition: color 0.3s;
}

.footer-social a:hover { color: #60a5fa; text-decoration: none; }

.footer-social .social-icon {
  width: 32px;
  height: 32px;
  transition: transform 0.3s, opacity 0.3s;
  vertical-align: middle;
}

.footer-social .social-icon:hover { transform: scale(1.2); opacity: 0.8; }

/* ========================================
   Responsive Breakpoints
   ======================================== */
@media (max-width: 900px) {
  .highlights { flex-direction: column; margin: 2rem 1rem; }
  .grid-section { padding: 2rem 1rem; }
}

@media (max-width: 768px) {
  main { padding: 1.5rem 1rem; }
  .container { padding: 1rem; }

  .hero { min-height: 35vh; }
  .hero h1 { font-size: 2rem; animation-duration: 15s; }
  .hero p  { font-size: 1.2rem; }

  .auth-container  { margin: 1.5rem 1rem; padding: 2rem 1.5rem; }
  .contact-container,
  .apply-container,
  .academics-container { margin: 1.5rem 1rem; padding: 1.5rem; }

  .cta { margin: 2rem 1rem; }
}

@media (max-width: 480px) {
  main { padding: 1rem 0.75rem; }
  .container { padding: 0.75rem; }

  .hero h1 { font-size: 1.6rem; animation-duration: 12s; }
  .hero p  { font-size: 1rem; }

  .auth-container  { margin: 1rem 0.5rem; padding: 1.5rem 1.25rem; }
  .contact-container,
  .apply-container,
  .academics-container { margin: 1rem 0.5rem; padding: 1.25rem 1rem; }

  .form-section { padding: 1.25rem 1rem; }
  .cta { margin: 2rem 0.5rem; padding: 1.5rem 1rem; }

  button[type="submit"] { font-size: 1rem; padding: 0.85rem; }
}

/* ========================================
   Print
   ======================================== */
@media print {
  .table-wrapper, .form-section, .card { box-shadow: none; border: 1px solid #ccc; }
  .header, .footer { display: none; }
}

/* ========================================
   Site header, navigation and donate dialog
   (loaded last so it wins over earlier rules, as when it was inline)
   ======================================== */
* { box-sizing: border-box; margin:0; padding:0; }
body { font-family: system-ui, -apple-system, Arial, sans-serif; line-height: 1.6; }

/* ==================== HEADER ==================== */
.header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.header .container {
  max-width: 1200px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.logo-container { flex-shrink: 0; }
.logo {
  height: 75px;
  width: auto;
  border-radius: var(--radius);
  object-fit: contain;
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--primary);
}
nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
nav a {
  color: var(--gray);
  text-decoration: none;
  font-weight: 500;
  padding: .4rem .6rem;
  border-radius: 6px;
  transition: all .2s;
}
nav a:hover,
nav a.active {
  background: rgba(25,118,210,.1);
  color: var(--primary);
}

/* Donate Button Styling */
nav .donate {
  background: #d32f2f;
  color: white;
  font: inherit;
  font-weight: 600;
  border: none;
  padding: .4rem .6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
}
nav .donate:hover,
nav .donate:focus-visible {
  background: #b71c1c;
}

.user-nav { display: flex; align-items: center; gap: .75rem; }
.inline-form { display: inline; margin: 0; }
/* button.link-button beats the site-wide button[type="submit"] style */
button.link-button,
button.link-button:hover {
  display: inline;
  width: auto;
  margin: 0;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  font: inherit;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==================== DONATE DIALOG ==================== */
dialog.modal {
  margin: auto; /* the global * { margin: 0 } reset would pin it to the top-left */
  border: none;
  padding: 0;
  background: transparent;
  max-width: 95vw;
  max-height: 95vh;
}
dialog.modal::backdrop {
  background: rgba(0,0,0,0.7);
}
.modal-content {
  background: white;
  padding: 20px;
  border-radius: 12px;
  max-height: 95vh;
  overflow: auto;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.modal-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 2px solid #ddd;
}
.close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  font-weight: bold;
  line-height: 1;
  background: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: #333;
}
.close-btn:hover,
.close-btn:focus-visible {
  color: #d32f2f;
}

/* ==================== MOBILE MENU ==================== */
@media (max-width: 768px) {
  .nav-toggle { display: block; }
  nav {
    order: 3;
    width: 100%;
    flex-basis: 100%;
  }
  nav ul {
    flex-direction: column;
    align-items: stretch;
    background: white;
    border: 1px solid transparent;
    border-radius: var(--radius);
    /* Closed: no padding, border or shadow, so nothing peeks out; hidden
       (after the slide-up finishes) so closed links can't be tabbed to */
    padding: 0 1rem;
    max-height: 0;
    overflow: hidden;
    visibility: hidden;
    transition: max-height .3s ease, padding .3s ease, visibility 0s linear .3s;
  }
  nav ul.open {
    max-height: 500px;
    padding: 1rem;
    visibility: visible;
    border-color: var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    transition: max-height .3s ease, padding .3s ease, visibility 0s;
  }
  nav a, nav .donate { display: block; width: 100%; text-align: left; padding: .75rem 0; border-bottom: 1px solid #eee; }
  nav .donate { padding: .75rem .6rem; }
  nav a:last-child { border-bottom: none; }
}

/* ==================== PAGINATION ==================== */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0;
}
