/* ============================================================
   IW LUNCH SYSTEM — SHARED STYLES
   public/style.css
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --navy: #1a3a2a;
  --blue: #2d6a4f;
  --sky: #eef4f1;
  --green: #1a7a4a;
  --green-lt: #e6f5ed;
  --red: #c0392b;
  --red-lt: #fff0ef;
  --gold: #d4930a;
  --gold-lt: #fef6e0;
  --gray: #f4f6f8;
  --border: #c8ddd3;
  --text: #1a3a2a;
  --muted: #6b7f94;

  --header-parent: #6a8d79;
  --header-admin: #457057;
}

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

/* ── Base ─────────────────────────────────────────────────── */
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
  background: var(--header-parent);
  color: white;
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

.header.admin {
  background: var(--header-admin);
}

.header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  font-weight: 400;
}

/* ── Nav ──────────────────────────────────────────────────── */
.nav {
  display: flex;
  gap: 8px;
}

.nav a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: background 0.15s;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ── Page Layout ──────────────────────────────────────────── */
.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 20px;
}

.page-title {
  font-family: 'DM Serif Display', serif;
  font-size: 26px;
  color: var(--navy);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  margin-top: 28px;
}

.section-label:first-of-type {
  margin-top: 0;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 14px;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: visible;
  margin-bottom: 8px;
}

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

thead {
  position: sticky;
  top: 60px;
  z-index: 10;
}

th {
  background: var(--gray);
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th.right {
  text-align: right;
}

th.center {
  text-align: center;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

.amount-cell {
  text-align: right;
  font-weight: 600;
}

.amount-cell.credit {
  color: var(--green);
}

.amount-cell.debit {
  color: var(--red);
}

.amount-cell.pending {
  color: var(--gold);
}

.date-cell {
  color: var(--muted);
  white-space: nowrap;
}

.center {
  text-align: center;
}

.empty-row td {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border: none;
  transition: all 0.12s;
}

.btn-primary {
  background: var(--blue);
  color: white;
}

.btn-primary:hover {
  background: var(--navy);
}

.btn-success {
  background: var(--green);
  color: white;
}

.btn-success:hover {
  background: #155d38;
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover {
  background: #a93226;
}

.btn-outline {
  background: white;
  color: var(--muted);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* ── Day buttons (M T W R F) ──────────────────────────────── */
.day-btns {
  display: flex;
  gap: 6px;
}

.day-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: all 0.12s;
}

.day-btn:hover {
  border-color: #1a3a5c;
  color: #1a3a5c;
}

.day-btn.active {
  background: #1a3a5c;
  border-color: #1a3a5c;
  color: white;
}

/* ── Nav buttons (prev/next arrows) ──────────────────────── */
.nav-btn {
  padding: 4px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: white;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--navy);
  transition: all 0.12s;
}

.nav-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* ── Student tabs ─────────────────────────────────────────── */
.student-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--sky);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.student-tab {
  padding: 7px 16px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: all 0.15s;
}

.student-tab:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.student-tab.active {
  background: #1a3a5c;
  border-color: #1a3a5c;
  color: white;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--sky);
  color: var(--navy);
  border: 1px solid var(--border);
}

.badge.admin {
  background: var(--gold-lt);
  color: var(--gold);
  border-color: #f0d080;
}

.badge.inactive {
  background: var(--red-lt);
  color: var(--red);
  border-color: #f5c6c3;
}

/* ── Status badges ────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.status-served {
  color: var(--green);
}

.status-pending {
  color: var(--gold);
}

/* ── Type badges (payments) ───────────────────────────────── */
.type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.type-payment {
  background: var(--green-lt);
  color: var(--green);
}

.type-fee {
  background: var(--red-lt);
  color: var(--red);
}

.type-writeoff {
  background: var(--gold-lt);
  color: var(--gold);
}

.type-refund {
  background: var(--sky);
  color: var(--blue);
}

/* ── Grade pill ───────────────────────────────────────────── */
.grade-pill {
  font-size: 11px;
  font-weight: 500;
  background: var(--sky);
  color: var(--navy);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.grade-badge {
  font-size: 10px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 6px;
  border-radius: 8px;
}

/* ── Flash messages ───────────────────────────────────────── */
.flash {
  display: none;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.flash.success {
  display: block;
  background: var(--green-lt);
  color: var(--green);
  border: 1px solid #a5d6a7;
}

.flash.error {
  display: block;
  background: var(--red-lt);
  color: var(--red);
  border: 1px solid #f5c6c3;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="month"],
select {
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: var(--text);
  background: white;
}

input:focus,
select:focus {
  border-color: var(--blue);
}

/* ── Cancel / action buttons ──────────────────────────────── */
.cancel-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
  white-space: nowrap;
}

.cancel-btn:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-lt);
}

.cancelled-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--gray);
  padding: 3px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
}

/* ── Filter / range buttons ───────────────────────────────── */
.filter-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: all 0.12s;
}

.filter-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.filter-btn.active {
  background: #1a3a5c;
  border-color: #1a3a5c;
  color: white;
}

.range-btn {
  padding: 5px 12px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: all 0.12s;
}

.range-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 28px;
  width: 420px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
}

.modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  margin-top: 12px;
}

.modal-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.modal-cancel {
  background: white;
  border: 1.5px solid var(--border);
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.modal-submit {
  background: var(--blue);
  border: none;
  color: white;
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.modal-submit:hover {
  background: var(--navy);
}

/* ── Loading / empty states ───────────────────────────────── */
.loading {
  text-align: center;
  padding: 60px;
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 14px;
  line-height: 1.6;
}

.empty-state a {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 24px;
  background: var(--navy);
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

/* ── Print ────────────────────────────────────────────────── */
@media print {

  .header,
  .nav,
  .no-print {
    display: none !important;
  }

  body {
    background: white;
  }

  .page {
    padding: 0;
    max-width: 100%;
  }

  .table-card {
    border: none;
    border-radius: 0;
  }

  th {
    background: #eee;
  }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 700px) {
  .header {
    padding: 0 16px;
  }

  .page {
    padding: 16px;
  }

  .nav a {
    padding: 5px 10px;
    font-size: 12px;
  }
}