@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --ink: #0E1726;
  --navy: #1F3A5F;
  --navy-700: #162C48;
  --saffron: #D98324;
  --green: #1E8E5A;
  --green-light: #E9F7EF;
  --red: #C0392B;
  --red-light: #FDECEA;
  --amber: #B7791F;
  --amber-light: #FEF9E7;
  --bg: #F4F6F9;
  --card: #FFFFFF;
  --line: #DDE3EC;
  --muted: #6B7A90;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(16, 32, 56, 0.08);
  --shadow-lg: 0 10px 30px rgba(16, 32, 56, 0.15);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E6EDF6;
    --navy: #2A4D7B;
    --navy-700: #1E3758;
    --saffron: #E5933A;
    --green: #27AE60;
    --green-light: #163626;
    --red: #E74C3C;
    --red-light: #3D1C1A;
    --amber: #D48E28;
    --amber-light: #3D2D14;
    --bg: #0D131D;
    --card: #151E2E;
    --line: #243247;
    --muted: #8E9EAF;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  font-family: 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

/* Offline Alert Bar */
#offline-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background-color: var(--red);
  color: #FFFFFF;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
#offline-bar.active {
  display: block;
}

/* Government Header Strip */
.gov-strip {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-700) 100%);
  color: #FFFFFF;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}
.gov-emblem {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}
.gov-titles {
  display: flex;
  flex-direction: column;
}
.gov-pretitle {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #F8C380;
  font-weight: 600;
}
.gov-maintitle {
  font-size: 16px;
  font-weight: 600;
  color: #FFFFFF;
  line-height: 1.25;
}

/* Container Constraints */
.mobile-wrapper {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 72px);
}
.admin-wrapper {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* Common Card */
.card {
  background-color: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* Typography & Headers */
h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 600;
}
p {
  color: var(--ink);
}
.muted-text {
  color: var(--muted);
  font-size: 14px;
}

/* Form Controls - Minimum 48px tap targets */
.form-group {
  margin-bottom: 16px;
}
label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--ink);
}
.input-control {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background-color: var(--card);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-control:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.15);
}
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.input-addon-btn {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  width: 44px;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
}

/* Buttons - Minimum 48px height */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s, transform 0.1s, opacity 0.2s;
  gap: 8px;
  user-select: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-primary {
  background-color: var(--navy);
  color: #FFFFFF;
}
.btn-primary:hover {
  background-color: var(--navy-700);
}
.btn-saffron {
  background-color: var(--saffron);
  color: #FFFFFF;
}
.btn-saffron:hover {
  background-color: #BE6F1B;
}
.btn-success {
  background-color: var(--green);
  color: #FFFFFF;
}
.btn-danger {
  background-color: var(--red);
  color: #FFFFFF;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
}
.btn-outline:hover {
  background-color: var(--bg);
}
.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 6px;
}
.btn-block {
  width: 100%;
}

/* Banners & Messages */
.alert-box {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-error {
  background-color: var(--red-light);
  border: 1px solid var(--red);
  color: var(--red);
}
.alert-warning {
  background-color: var(--amber-light);
  border: 1px solid var(--amber);
  color: var(--amber);
}
.alert-success {
  background-color: var(--green-light);
  border: 1px solid var(--green);
  color: var(--green);
}

/* Navigation / Header for Principal */
.app-header-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.school-badge {
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
}
.date-badge {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.menu-trigger {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--ink);
}

/* Status Strip */
.status-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.status-pill {
  flex: 1;
  min-width: 120px;
  padding: 8px 12px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}
.status-pill.pending {
  border: 1.5px solid var(--line);
  color: var(--muted);
  background: var(--card);
}
.status-pill.marked {
  background-color: var(--green-light);
  border: 1.5px solid var(--green);
  color: var(--green);
}

/* Meal Selector - Segmented Control */
.segmented-control {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  gap: 4px;
}
.segment-btn {
  flex: 1;
  min-height: 44px;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.segment-btn.active {
  background: var(--card);
  color: var(--navy);
  box-shadow: var(--shadow);
}

/* Camera Stage - 3:4 aspect ratio */
.camera-container {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #000000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.camera-video, .camera-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.camera-video.mirrored {
  transform: scaleX(-1);
}
.camera-canvas {
  display: none;
}
.camera-controls-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
}
.flip-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.flip-btn:active {
  transform: rotate(180deg);
  transition: transform 0.3s;
}

/* Camera Shutter Actions */
.shutter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
}
.shutter-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: var(--saffron);
  border: 5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 15px rgba(217, 131, 36, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s, background-color 0.2s;
}
.shutter-btn:active {
  transform: scale(0.92);
}
.shutter-btn svg {
  width: 32px;
  height: 32px;
  fill: #FFFFFF;
}

/* Location Chip */
.location-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 16px;
  align-self: center;
}

/* Success Card Full Overlay */
.success-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: var(--bg);
  padding: 24px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.success-overlay.active {
  display: flex;
}
.success-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background-color: var(--green);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 10px 25px rgba(30, 142, 90, 0.3);
}

/* Modals */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.active {
  display: flex;
}
.modal-card {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

/* Spinner Overlay */
.spinner-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 23, 38, 0.7);
  z-index: 1050;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #FFFFFF;
}
.spinner-overlay.active {
  display: flex;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--saffron);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 14px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}
.toast {
  background: var(--ink);
  color: #FFFFFF;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: auto;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Admin Tabs & Layout */
.admin-tabs {
  display: flex;
  border-bottom: 2px solid var(--line);
  margin-bottom: 20px;
  gap: 8px;
  overflow-x: auto;
}
.admin-tab-btn {
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.admin-tab-btn.active {
  color: var(--navy);
  border-bottom-color: var(--navy);
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  background-color: var(--bg);
  font-weight: 600;
  color: var(--ink);
}
tr:last-child td {
  border-bottom: none;
}
.img-thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--line);
}

/* Live Board Cards */
.live-summary-bar {
  display: flex;
  gap: 16px;
  background: var(--card);
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.schools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.school-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.school-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--ink);
}
.school-card-meals {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Print Stylesheet */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 12pt;
  }
  .gov-strip, .admin-tabs, .btn, .no-print, #offline-bar, .modal-backdrop, .toast-container {
    display: none !important;
  }
  .admin-wrapper {
    max-width: 100% !important;
    padding: 0 !important;
  }
  .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
  }
  .print-header h2 {
    font-size: 16pt;
    margin-bottom: 4px;
  }
  table {
    border: 1px solid #000;
    font-size: 10pt;
  }
  th, td {
    border: 1px solid #000 !important;
    padding: 6px 8px !important;
  }
  th {
    background-color: #EEE !important;
  }
}
.print-header {
  display: none;
}
