/* ==========================================================================
   SITM College Attendance System - Official Brand Design System
   Matches SITM official website visual language:
   - Warm Editorial Alabaster & Cream backgrounds (#F8F6F0 / #FAF8F5)
   - Deep SITM Midnight Navy (#0B1323)
   - Warm Ochre Gold CTA buttons & accents (#D4A346)
   - Heritage Collegiate Crimson (#801823)
   - Dual-font typography: Plus Jakarta Sans + Playfair Display (Italic Serif)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,600;0,700;1,600;1,700;1,800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* SITM Official Warm Editorial Foundations */
  --bg-page: #F8F6F0;             /* Warm Editorial Alabaster from screenshots */
  --bg-page-subtle: #F2EFE8;
  --surface: #FFFFFF;             /* Pure white card surface */
  --surface-cream: #FAF8F5;       /* Warm cream card surface from modal screenshot */
  --surface-raised: #FFFFFF;
  --surface-subtle: #F4F0E6;      /* Subtle cream backdrop */
  --surface-dark: #0B1323;        /* Deep SITM Midnight Navy from hero screenshot */
  --surface-dark-card: #111D35;

  /* Borders & Dividers */
  --border-subtle: #F0ECE1;
  --border-light: #E6E1D4;        /* Soft warm border */
  --border-medium: #D5CEBD;       /* Muted input underline / borders */
  --border-dark: #0B1323;

  /* Typography */
  --text-primary: #0B1323;        /* Deep ink navy */
  --text-secondary: #4A5568;      /* Warm slate */
  --text-muted: #8C96A6;          /* Muted slate */
  --text-inverse: #FFFFFF;
  --text-gold: #C29337;

  /* SITM Official Brand Palette */
  --sitm-navy: #0B1323;           /* Deep midnight navy */
  --sitm-navy-light: #16243C;
  --sitm-gold: #D4A346;           /* Warm Ochre Gold from primary buttons */
  --sitm-gold-hover: #C29337;
  --sitm-gold-subtle: #FBF4E6;
  --sitm-gold-border: #E8CE95;
  --sitm-crimson: #801823;        /* Heritage SITM Maroon / Crimson */
  --sitm-crimson-hover: #6A121B;
  --sitm-crimson-subtle: #FDF2F3;
  --sitm-crimson-border: #F5D0D5;

  /* Primary Action mapping -> Gold is SITM's primary CTA button color */
  --primary: #D4A346;
  --primary-hover: #C29337;
  --primary-subtle: #FBF4E6;
  --primary-border: #E8CE95;

  /* Status Colors */
  --success: #15803D;             /* Forest Green for Present */
  --success-hover: #166534;
  --success-subtle: #F0FDF4;
  --success-border: #BBF7D0;

  --danger: #801823;              /* SITM Crimson for Absent / Errors */
  --danger-hover: #6A121B;
  --danger-subtle: #FDF2F3;
  --danger-border: #F5D0D5;

  --warning: #D4A346;             /* SITM Ochre Amber */
  --warning-subtle: #FFFBEB;
  --warning-border: #FDE68A;

  /* Faculty Signature Colors (Timetable highlights) */
  --faculty-nitish: #4F46E5;   /* Indigo */
  --faculty-megha: #0284C7;    /* Ocean Blue */
  --faculty-soumyajit: #15803D;/* Forest Emerald */

  /* Typography Settings */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;

  /* Shadows - Subtle & Warm */
  --shadow-xs: 0 1px 2px 0 rgba(11, 19, 35, 0.04);
  --shadow-sm: 0 2px 4px 0 rgba(11, 19, 35, 0.06), 0 1px 2px -1px rgba(11, 19, 35, 0.04);
  --shadow-md: 0 6px 12px -2px rgba(11, 19, 35, 0.08), 0 3px 6px -2px rgba(11, 19, 35, 0.04);
  --shadow-lg: 0 12px 20px -3px rgba(11, 19, 35, 0.1), 0 4px 8px -4px rgba(11, 19, 35, 0.05);
  --shadow-xl: 0 24px 35px -5px rgba(11, 19, 35, 0.15), 0 10px 15px -6px rgba(11, 19, 35, 0.08);

  /* Radii */
  --radius-xs: 3px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  --max-width: 1040px;
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* Header & Collegiate Navigation (SITM Midnight Navy) */
.app-header {
  background: var(--surface-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 20px rgba(11, 19, 35, 0.25);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.brand-crest-img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
  flex-shrink: 0;
  display: block;
}

.login-brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.2));
  flex-shrink: 0;
  display: block;
}

.brand-crest {
  width: 40px;
  height: 40px;
  background: var(--sitm-crimson);
  color: var(--sitm-gold);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  border: 1.5px solid var(--sitm-gold);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.brand-info h1 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #FFFFFF;
  line-height: 1.2;
}

.brand-info p {
  font-size: 0.74rem;
  color: #94A3B8;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* SITM Editorial Typography Utilities */
.editorial-serif {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
}

.editorial-serif-gold {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  color: var(--sitm-gold);
}

.eyebrow-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.eyebrow-label::before {
  content: "";
  display: inline-block;
  width: 22px;
  height: 2px;
  background: var(--sitm-crimson);
  border-radius: 2px;
}

.eyebrow-label-dark {
  color: #94A3B8;
}

.eyebrow-label-dark::before {
  background: var(--sitm-gold);
}

/* Main Layout */
.main-container {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  flex: 1;
}

/* Tactile Buttons (SITM Gold & Collegiate Crimson) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0.65rem 1.25rem;
  font-size: 0.92rem;
  text-decoration: none;
  user-select: none;
  outline: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary Button: SITM Signature Ochre Gold */
.btn-primary {
  background: var(--sitm-gold);
  color: var(--surface-dark);
  border-color: var(--sitm-gold);
  box-shadow: 0 1px 3px rgba(11, 19, 35, 0.08);
}

.btn-primary:hover:not(:disabled) {
  background: var(--sitm-gold-hover);
  border-color: var(--sitm-gold-hover);
  color: var(--surface-dark);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(212, 163, 70, 0.25);
}

.btn-accent {
  background: var(--surface-dark);
  color: white;
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-accent:hover:not(:disabled) {
  background: var(--sitm-navy-light);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 2px 4px rgba(21, 128, 61, 0.2);
}

.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
}

.btn-danger {
  background: var(--sitm-crimson);
  color: white;
  border-color: var(--sitm-crimson);
}

.btn-danger:hover:not(:disabled) {
  background: var(--sitm-crimson-hover);
}

.btn-outline-danger {
  background: transparent;
  border-color: var(--sitm-crimson);
  color: var(--sitm-crimson);
  box-shadow: var(--shadow-xs);
}

.btn-outline-danger:hover:not(:disabled) {
  background: var(--sitm-crimson-subtle);
  border-color: var(--sitm-crimson-hover);
  color: var(--sitm-crimson-hover);
}

.btn-secondary {
  background: var(--surface-cream);
  border-color: var(--border-medium);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: #B5AD9C;
  color: var(--text-primary);
}

/* Universal Header Back Button (Mobile & Desktop) */
.btn-nav-back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 0.84rem;
  padding: 0.42rem 0.8rem;
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF !important;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-nav-back:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateX(-1px);
}

.btn-nav-back:active {
  transform: translateX(-2px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.btn-lg {
  padding: 0.85rem 1.6rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 0.38rem 0.75rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.badge-primary {
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.badge-success {
  background: var(--success-subtle);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-danger {
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-neutral {
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

.badge-dark {
  background: var(--surface-dark);
  color: white;
}

/* Live Online Status Dot */
.network-badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.network-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.badge-online {
  background: var(--success-subtle);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-online::before {
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.25);
}

.badge-offline {
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-offline::before {
  background: var(--danger);
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 90vw;
  width: 380px;
}

.toast {
  background: var(--surface-dark);
  color: white;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  box-shadow: var(--shadow-xl);
  font-size: 0.88rem;
  animation: toastPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 4px solid var(--primary);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

.toast-text {
  flex: 1;
  word-break: break-word;
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: 1.5px solid var(--sitm-crimson);
  color: var(--sitm-crimson);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  transition: all 0.15s ease;
}

.toast-close:hover {
  background: var(--sitm-crimson);
  color: white;
}

.toast-fade-out {
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease-out;
}

@keyframes toastPop {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Dialog & Modals (SITM Warm Cream + Dark Backdrop) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 35, 0.72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top, 0px));
  padding-bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 90;
}

.modal-dialog {
  background: var(--surface-cream);
  border-radius: var(--radius-xl);
  max-width: 520px;
  width: 100%;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(11, 19, 35, 0.45);
  border: 1px solid var(--border-medium);
  overflow: hidden;
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-cream);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-body {
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.modal-footer {
  padding: 0.9rem 1.35rem;
  background: var(--surface-subtle);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Form System */
.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.input-container {
  position: relative;
  width: 100%;
}

.form-input {
  width: 100%;
  padding: 0.72rem 0.95rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: var(--sitm-gold);
  box-shadow: 0 0 0 3px rgba(212, 163, 70, 0.2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Tabular & Utility classes */
.tabular-nums { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.font-bold { font-weight: 700; }

/* ==========================================================================
   Mobile PWA Global Adaptations & Safe-Area Adjustments
   ========================================================================== */
button, select, a, input[type="button"], input[type="submit"], .teacher-chip, .day-tab, .mode-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Prevent iOS Safari auto-zooming into inputs & hide internal sheet tabs on mobile */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }

  #header-teacher-tab,
  #nav-teacher-tab {
    display: none !important;
  }
}

/* Small screen mobile header compaction (phones 360px - 480px) */
@media (max-width: 480px) {
  .header-container {
    padding: 0.65rem 0.85rem;
    padding-left: max(0.85rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.85rem, env(safe-area-inset-right, 0px));
    gap: 0.5rem;
  }

  .brand-group {
    gap: 0.65rem;
  }

  .brand-crest-img {
    width: 36px;
    height: 36px;
  }

  .brand-info h1 {
    font-size: 0.92rem;
  }

  .brand-info p {
    font-size: 0.68rem;
  }

  .header-actions {
    gap: 0.4rem;
  }

  .header-actions .btn,
  .btn-nav-back {
    padding: 0.38rem 0.6rem;
    font-size: 0.78rem;
    border-radius: var(--radius-xs);
  }

  .network-badge {
    display: none; /* Hide badge on very narrow phones to preserve space for buttons */
  }

  .main-container {
    padding: 1rem 0.75rem;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
  }
}

