/* =====================================================================
   SKBTP Portal Ibu Bapa/ Penjaga — Shared Design System
   Minimalist, clean, white theme. Mobile-first & fully responsive.
   ===================================================================== */

:root {
  /* Brand */
  --color-primary: #0f6e6e;
  --color-primary-dark: #0b5555;
  --color-primary-light: #e6f3f3;
  --color-accent: #2a9d8f;

  /* Status */
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-info: #2563eb;
  --color-info-bg: #eff6ff;

  /* Neutrals */
  --color-bg: #f7f8fa;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #1f2933;
  --color-text-muted: #6b7280;
  --color-text-faint: #9ca3af;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.10);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Legacy custom-property aliases (referenced by inline styles inside
     PHP-echoed markup elsewhere in the app — kept so those old
     var(--primary-color) etc. references still resolve sensibly) */
  --primary-color: var(--color-primary);
  --secondary-color: var(--color-accent);
  --accent-color: #0099CC;
  --hover-bg: var(--color-primary-light);
  --success-color: var(--color-success);
  --danger-color: var(--color-danger);
  --light-bg: var(--color-bg);
  --white: #ffffff;
  --shadow: var(--shadow-md);

  /* Layout */
  --content-max: 1040px;
  --content-narrow: 560px;
  --nav-height: 60px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-dark); }

h1, h2, h3, h4 { color: var(--color-text); font-weight: 700; line-height: 1.3; }

img { max-width: 100%; }

hr { border: none; border-top: 1px solid var(--color-border); margin: 24px 0; }

/* ---------------------------------------------------------------------
   Layout helpers
   --------------------------------------------------------------------- */
.page-wrap {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 16px 56px;
}

.page-wrap--narrow {
  max-width: var(--content-narrow);
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.stack { display: flex; flex-direction: column; gap: 16px; }

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }

/* ---------------------------------------------------------------------
   Top brand / navigation bar
   --------------------------------------------------------------------- */
.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  height: var(--nav-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text);
  font-weight: 700;
  font-size: 15px;
  min-width: 0;
}

.brand img { height: 32px; width: auto; border-radius: 4px; flex-shrink: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-toggle {
  display: none;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--color-text);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links > li { position: relative; }

.nav-links a {
  display: block;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.nav-links > li > a:hover,
.nav-links > li:hover > a {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.nav-links a.is-logout { color: var(--color-danger); }
.nav-links a.is-logout:hover { background: var(--color-danger-bg); }

.nav-links .dropdown-arrow::after { content: "\25BE"; margin-left: 6px; font-size: 10px; }

.sub-menu {
  list-style: none;
  margin: 0;
  padding: 6px;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 260px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 50;
}

.nav-links > li:hover .sub-menu { display: block; }

.sub-menu a { color: var(--color-text); font-weight: 500; padding: 10px 12px; border-radius: var(--radius-sm); }
.sub-menu a:hover { background: var(--color-primary-light); color: var(--color-primary-dark); }

@media (max-width: 780px) {
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    gap: 2px;
  }
  .nav-links.is-open { display: flex; }
  .nav-links > li { width: 100%; }
  .nav-links a { width: 100%; }
  .sub-menu {
    position: static;
    box-shadow: none;
    border: none;
    background: var(--color-bg);
    display: block;
    margin: 2px 0 6px 8px;
  }
  .nav-links > li:hover .sub-menu { display: block; }
}

/* ---------------------------------------------------------------------
   Cards
   --------------------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.card-header {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--color-primary-dark);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.card--accent { border-top: 3px solid var(--color-primary); }

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  width: 100%;
}

.auth-card__banner { width: 100%; display: block; }

.auth-card__header {
  background: var(--color-primary);
  color: #fff;
  text-align: center;
  padding: 18px 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 15px;
}

.auth-card__body { padding: 28px 24px; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.field { margin-bottom: 18px; }

.field label,
label.field-label {
  display: block;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.field-hint {
  display: block;
  font-size: 12px;
  color: var(--color-primary);
  margin-top: -2px;
  margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="tel"],
input:not([type]),
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn, input[type="button"], input[type="submit"], button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  background: var(--color-primary);
  color: #fff;
}

.btn:hover, input[type="button"]:hover, input[type="submit"]:hover, button:hover {
  background: var(--color-primary-dark);
}

.btn:active, input[type="button"]:active, input[type="submit"]:active, button:active {
  transform: translateY(1px);
}

.btn-block { width: 100%; }
.btn-secondary { background: #fff; color: var(--color-text); border: 1.5px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); }
.btn-success { background: var(--color-success); }
.btn-success:hover { background: #128a3e; }
.btn-warning { background: var(--color-warning); }
.btn-warning:hover { background: #b45f04; }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }

/* ---------------------------------------------------------------------
   Alerts / status
   --------------------------------------------------------------------- */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 14px;
  border: 1px solid transparent;
}
.alert-success { background: var(--color-success-bg); color: #166534; border-color: #bbf7d0; }
.alert-danger { background: var(--color-danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-info { background: var(--color-info-bg); color: #1e40af; border-color: #bfdbfe; }
.alert-warning { background: var(--color-warning-bg); color: #92400e; border-color: #fde68a; }

.status-paid { color: var(--color-success); font-weight: 700; }
.text-red { color: var(--color-danger); font-weight: 600; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  background: var(--color-bg);
  color: var(--color-primary-dark);
  text-align: left;
  padding: 11px 12px;
  border-bottom: 2px solid var(--color-border);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--color-border); }
.data-table tr:last-child td { border-bottom: none; }

table.profile-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.profile-table td { padding: 8px 6px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.profile-table td:first-child { width: 34%; font-weight: 600; color: var(--color-text-muted); }

@media (max-width: 640px) {
  .profile-table td { display: block; width: 100% !important; border-bottom: none; padding: 4px 0; }
  .profile-table td:first-child { padding-top: 12px; font-size: 12px; text-transform: uppercase; }
  .profile-table tr { display: block; border-bottom: 1px solid var(--color-border); padding-bottom: 6px; }
}

/* ---------------------------------------------------------------------
   List items (children / student cards)
   --------------------------------------------------------------------- */
ul.item-list { list-style: none; margin: 0; padding: 0; }

.item-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.item-card__title { font-weight: 700; font-size: 15px; color: var(--color-text); }
.item-card__meta { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }
.item-card__highlight { font-size: 1.1em; font-weight: 700; color: var(--color-primary); }

.notice-box {
  margin-top: 12px;
  border: 1px solid var(--color-danger);
  background: var(--color-danger-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.info-box {
  margin-top: 10px;
  font-size: 13px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 33, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.is-open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  border-top: 5px solid var(--color-primary);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  position: relative;
}

.modal-close {
  position: absolute;
  right: 14px;
  top: 14px;
  border: none;
  background: var(--color-bg);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
}
.modal-close:hover { background: var(--color-border); }

.modal-item { margin-bottom: 14px; }
.modal-item__label { font-weight: 700; color: var(--color-accent); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.3px; }
.modal-item__value { font-size: 14px; border-bottom: 1px solid var(--color-border); padding-bottom: 6px; margin-top: 3px; }

/* ---------------------------------------------------------------------
   Certificates / simple list-link pages
   --------------------------------------------------------------------- */
.cert-list { list-style: none; margin: 0; padding: 0; }
.cert-item {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.cert-item:hover { background: var(--color-primary-light); transform: translateX(3px); }
.cert-item a { display: block; padding: 13px 15px; text-decoration: none; color: var(--color-text); font-weight: 600; }

/* ---------------------------------------------------------------------
   Backward-compatible aliases
   (class names produced by dynamic/echoed PHP output across the app)
   --------------------------------------------------------------------- */
.responsive-image { width: 28px; vertical-align: middle; }

.student-list-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  padding: 15px;
  margin-bottom: 14px;
  list-style: none;
  border-radius: var(--radius-md);
}

/* Legacy modal markup (#dataModal / .modal-content / .close-modal ...)
   kept working alongside the new .modal-overlay/.modal-box system. */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background-color: rgba(15, 23, 33, 0.5);
}
.modal.is-open { display: block; }
.modal-content {
  background-color: var(--color-surface);
  margin: 8% auto;
  padding: 22px;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border-top: 5px solid var(--color-primary);
}
.close-modal {
  color: var(--color-text-faint);
  float: right;
  font-size: 26px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}
.close-modal:hover { color: var(--color-text); }
.modal-body-item { margin-bottom: 14px; clear: both; }
.modal-label { font-weight: 700; color: var(--color-accent); font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.3px; }
.modal-value { font-size: 0.95em; border-bottom: 1px solid var(--color-border); padding-bottom: 5px; margin-top: 3px; }

/* Bare, un-classed <table> tags used by several legacy pages */
table:not(.data-table):not(.profile-table) {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 14px;
}
table:not(.data-table):not(.profile-table) th {
  background: var(--color-bg);
  padding: 10px;
  text-align: left;
  border-bottom: 2px solid var(--color-border);
  color: var(--color-primary-dark);
}
table:not(.data-table):not(.profile-table) td {
  padding: 10px;
  border-bottom: 1px solid var(--color-border);
}

/* ---------------------------------------------------------------------
   Footer
   --------------------------------------------------------------------- */
.site-footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--color-text-faint);
  padding: 24px 16px 8px;
}
.site-footer a { color: var(--color-text-muted); font-weight: 600; text-decoration: none; }
.site-footer a:hover { color: var(--color-primary); }

/* ---------------------------------------------------------------------
   Print
   --------------------------------------------------------------------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: none; }
}
