/*
 * MessMate — style.css
 * Custom styles for Hostel & Mess Management System
 * Design: Dark sidebar, clean content, mobile-first
 * Rem scale: 1rem = 10px (html font-size: 62.5%)
 */

/* =========================================================
   1. Root & Rem Scale
   ========================================================= */

:root {
  /* Color palette */
  --mm-primary:    #6366f1;   /* Indigo-500 */
  --mm-primary-dk: #4338ca;   /* Indigo-700 */
  --mm-sidebar-bg: #0f172a;   /* Slate-900 */
  --mm-sidebar-hover: #1e293b; /* Slate-800 */
  --mm-content-bg: #f8fafc;   /* Slate-50 */
  --mm-card-bg:   #ffffff;
  --mm-danger:    #ef4444;
  --mm-success:   #22c55e;
  --mm-warning:   #f59e0b;
  --mm-text-main: #1e293b;
  --mm-text-muted: #64748b;
  --mm-border:    #e2e8f0;
  --mm-shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --mm-shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

  /* Sidebar */
  --sidebar-w: 26rem;
}

html {
  font-size: 62.5%; /* 1rem = 10px */
}

body {
  font-size: 1.5rem;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--mm-content-bg);
  color: var(--mm-text-main);
  line-height: 1.6;
}

/* =========================================================
   2. Sidebar Layout (desktop)
   ========================================================= */

.mm-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--mm-sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.mm-sidebar .sidebar-brand {
  padding: 2.4rem 2rem 1.6rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.mm-sidebar .brand-title {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.mm-sidebar .brand-subtitle {
  font-size: 1.1rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

.mm-sidebar .sidebar-nav {
  padding: 1.6rem 0;
  flex: 1;
}

.mm-sidebar .nav-section-label {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #475569;
  padding: 1rem 2rem 0.6rem;
}

.mm-sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1.1rem 2rem;
  color: #94a3b8;
  border-radius: 0;
  font-size: 1.4rem;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
  border-left: 3px solid transparent;
}

.mm-sidebar .nav-link:hover {
  background: var(--mm-sidebar-hover);
  color: #fff;
  border-left-color: var(--mm-primary);
}

.mm-sidebar .nav-link.active {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border-left-color: var(--mm-primary);
}

.mm-sidebar .nav-link .nav-icon {
  font-size: 1.6rem;
  width: 2rem;
  text-align: center;
  flex-shrink: 0;
}

.mm-sidebar .sidebar-footer {
  padding: 1.6rem 2rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 1.2rem;
  color: #475569;
}

/* Main content offset for sidebar */
.mm-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

/* Mobile: No sidebar offset */
@media (max-width: 991.98px) {
  .mm-sidebar {
    transform: translateX(-100%);
  }
  .mm-sidebar.show {
    transform: translateX(0);
  }
  .mm-main {
    margin-left: 0;
  }

  .mm-system-time-bar {
    display: none;
  }
}

/* =========================================================
   3. Top Navbar (mobile toggle bar)
   ========================================================= */

.mm-topbar {
  background: var(--mm-sidebar-bg);
  padding: 1.2rem 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: var(--mm-shadow);
}

.mm-topbar .topbar-brand {
  font-size: 1.7rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.mm-topbar .topbar-toggle {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 2.2rem;
  cursor: pointer;
  padding: 0.4rem;
  transition: color 0.2s;
}

.mm-topbar .topbar-toggle:hover {
  color: #fff;
}

/* Sidebar overlay on mobile */
.mm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1029;
}

.mm-overlay.show {
  display: block;
}

/* =========================================================
   4. Content Area
   ========================================================= */

.mm-content {
  padding: 2.4rem;
}

@media (max-width: 575.98px) {
  .mm-content {
    padding: 1.6rem 1.2rem;
  }
}

.mm-page-header {
  margin-bottom: 2.4rem;
}

.mm-page-header h1 {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--mm-text-main);
  margin: 0;
  letter-spacing: -0.02em;
}

.mm-page-header .breadcrumb {
  font-size: 1.3rem;
  margin: 0;
}

/* ── Breadcrumb nav styles ───────────────────────────────── */
.mm-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 1.3rem;
  color: var(--mm-text-muted);
  margin-top: 0.4rem;
  padding: 0;
  list-style: none;
}

.mm-breadcrumb a {
  color: var(--mm-primary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.mm-breadcrumb a:hover {
  color: var(--mm-primary-dk);
  text-decoration: underline;
}

.mm-breadcrumb .bc-sep {
  color: #cbd5e1;
  font-size: 1.1rem;
  user-select: none;
}

.mm-breadcrumb .bc-current {
  color: var(--mm-text-muted);
  font-weight: 500;
}

/* Back button — prominent on mobile, subtler on desktop */
.mm-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--mm-text-muted);
  background: white;
  border: 1px solid var(--mm-border);
  border-radius: 0.8rem;
  padding: 0.55rem 1.2rem;
  text-decoration: none;
  transition: all 0.18s ease;
  box-shadow: var(--mm-shadow);
}

.mm-back-btn:hover {
  color: var(--mm-primary);
  border-color: var(--mm-primary);
  box-shadow: 0 2px 8px rgba(99,102,241,.12);
  transform: translateX(-2px);
}

.mm-back-btn i {
  font-size: 1.1rem;
  transition: transform 0.18s ease;
}

.mm-back-btn:hover i {
  transform: translateX(-2px);
}


/* =========================================================
   5. Metric Cards
   ========================================================= */

.mm-metric-card {
  background: var(--mm-card-bg);
  border-radius: 1.2rem;
  padding: 2rem 2.4rem;
  box-shadow: var(--mm-shadow);
  border: 1px solid var(--mm-border);
  transition: box-shadow 0.2s, transform 0.2s;
}

.mm-metric-card:hover {
  box-shadow: var(--mm-shadow-md);
  transform: translateY(-1px);
}

.mm-metric-card .metric-icon {
  font-size: 2.8rem;
  width: 5.6rem;
  height: 5.6rem;
  border-radius: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mm-metric-card .metric-value {
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.mm-metric-card .metric-label {
  font-size: 1.3rem;
  color: var(--mm-text-muted);
  font-weight: 500;
  margin-top: 0.3rem;
}

/* =========================================================
   6. Student Cards (mobile view)
   ========================================================= */

.mm-student-card {
  background: var(--mm-card-bg);
  border-radius: 1.2rem;
  border: 1px solid var(--mm-border);
  box-shadow: var(--mm-shadow);
  padding: 1.8rem;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
}

.mm-student-card:hover {
  box-shadow: var(--mm-shadow-md);
  transform: translateY(-1px);
}

.mm-student-card .student-room-badge {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.3rem 0.8rem;
  border-radius: 0.6rem;
  background: var(--mm-primary);
  color: white;
}

.mm-student-card .student-name {
  font-size: 1.7rem;
  font-weight: 600;
  margin: 0;
}

.mm-student-card .student-meta {
  font-size: 1.2rem;
  color: var(--mm-text-muted);
}

.mm-student-card .balance-amount {
  font-size: 2rem;
  font-weight: 700;
}

.mm-student-card .action-buttons {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

/* Leave pill indicator */
.leave-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: 2rem;
  background: rgba(245, 158, 11, 0.12);
  color: var(--mm-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* =========================================================
   7. Tables
   ========================================================= */

.mm-table-wrap {
  background: var(--mm-card-bg);
  border-radius: 1.2rem;
  border: 1px solid var(--mm-border);
  box-shadow: var(--mm-shadow);
  overflow: hidden;
}

.mm-table {
  font-size: 1.4rem;
  margin: 0;
}

.mm-table th {
  background: #f1f5f9;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mm-text-muted);
  border-bottom: 2px solid var(--mm-border);
  padding: 1.2rem 1.6rem;
  white-space: nowrap;
}

.mm-table td {
  padding: 1.2rem 1.6rem;
  vertical-align: middle;
  border-color: var(--mm-border);
}

.mm-table tbody tr:hover {
  background: #f8fafc;
}

/* Balance in tables */
.balance-due   { color: var(--mm-danger); font-weight: 700; }
.balance-credit { color: var(--mm-success); font-weight: 700; }
.balance-zero  { color: var(--mm-text-muted); }

/* =========================================================
   8. Forms & Cards
   ========================================================= */

.mm-card {
  background: var(--mm-card-bg);
  border-radius: 1.2rem;
  border: 1px solid var(--mm-border);
  box-shadow: var(--mm-shadow);
}

.mm-card .card-header {
  background: linear-gradient(135deg, var(--mm-primary), var(--mm-primary-dk));
  color: white;
  border-radius: 1.2rem 1.2rem 0 0;
  padding: 1.6rem 2.4rem;
  border: none;
}

.mm-card .card-header h2,
.mm-card .card-header h3 {
  margin: 0;
  font-weight: 600;
}

.mm-card .card-body {
  padding: 2.4rem;
}

/* Form labels */
.form-label {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--mm-text-main);
  margin-bottom: 0.5rem;
}

.form-control, .form-select {
  font-size: 1.4rem;
  border-radius: 0.8rem;
  border-color: var(--mm-border);
  padding: 0.9rem 1.2rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--mm-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* =========================================================
   9. Buttons
   ========================================================= */

.btn {
  font-size: 1.4rem;
  font-weight: 500;
  border-radius: 0.8rem;
  padding: 0.75rem 1.6rem;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--mm-primary);
  border-color: var(--mm-primary);
}
.btn-primary:hover {
  background: var(--mm-primary-dk);
  border-color: var(--mm-primary-dk);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-sm {
  font-size: 1.2rem;
  padding: 0.5rem 1rem;
  border-radius: 0.6rem;
}

/* ── Unified Leave Toggle Button ─────────────────────────
   Two visual states controlled by JS via data-on-leave attr.
   --------------------------------------------------------- */

/* IDLE state: student is present — subtle, doesn't draw attention */
.btn-leave-toggle {
  background: rgba(100, 116, 139, 0.08);
  color: #64748b;
  border: 1px solid rgba(100, 116, 139, 0.25);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.btn-leave-toggle:hover {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.4);
}

/* ACTIVE state: student is on leave — amber highlight, pulsing glow */
.btn-leave-toggle.btn-leave-active {
  background: #f59e0b;
  color: white;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
  animation: leaveGlow 2.5s ease-in-out infinite;
  font-weight: 600;
}

.btn-leave-toggle.btn-leave-active:hover {
  background: #d97706;
  border-color: #d97706;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.35);
}

/* Subtle pulsing glow animation for the active state */
@keyframes leaveGlow {
  0%, 100% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25); }
  50%       { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.10); }
}

/* Label text inside the button (hidden on very small desktop action column) */
.leave-btn-label {
  display: inline;
}


/* =========================================================
   10. Toast Notifications
   ========================================================= */

.mm-toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  max-width: 36rem;
}

.mm-toast {
  background: var(--mm-sidebar-bg);
  color: white;
  padding: 1.4rem 1.8rem;
  border-radius: 1rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  font-size: 1.4rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  animation: toastIn 0.3s ease;
  border-left: 4px solid var(--mm-primary);
}

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

.mm-toast .toast-icon { font-size: 1.8rem; flex-shrink: 0; }
.mm-toast .toast-msg  { flex: 1; line-height: 1.4; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(2rem); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(2rem); }
}

/* =========================================================
   11. Invoice Styles
   ========================================================= */

.invoice-wrapper {
  max-width: 72rem;
  margin: 0 auto;
  background: white;
  border-radius: 1.2rem;
  box-shadow: var(--mm-shadow-md);
  overflow: hidden;
}

.invoice-header {
  background: linear-gradient(135deg, var(--mm-primary), var(--mm-primary-dk));
  color: white;
  padding: 3.2rem;
}

.invoice-header h1 {
  font-size: 2.8rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.03em;
}

.invoice-body {
  padding: 3.2rem;
}

.invoice-line-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--mm-border);
  font-size: 1.4rem;
}

.invoice-line-item:last-child { border-bottom: none; }

.invoice-total-row {
  background: #f8fafc;
  border-radius: 0.8rem;
  padding: 1.6rem;
  margin-top: 1.6rem;
}

.invoice-total-row .total-label {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--mm-text-muted);
}

.invoice-total-row .total-amount {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--mm-primary);
  letter-spacing: -0.03em;
}

/* =========================================================
   12. WhatsApp Ledger — No-chrome print page
   ========================================================= */

.wa-ledger-page {
  font-family: 'Inter', sans-serif;
  font-size: 1.4rem;
  padding: 2rem;
  background: white;
  color: #0f172a;
}

.wa-ledger-page h1 {
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.4rem;
}

.wa-ledger-page .wa-subtitle {
  font-size: 1.3rem;
  text-align: center;
  color: var(--mm-text-muted);
  margin-bottom: 2rem;
}

.wa-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.3rem;
}

.wa-table th {
  background: #0f172a;
  color: white;
  padding: 1rem 1.2rem;
  font-weight: 700;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wa-table td {
  padding: 0.9rem 1.2rem;
  border: 1px solid #334155;
}

.wa-table tbody tr:nth-child(even) {
  background: #f1f5f9;
}

.wa-table .col-due    { color: var(--mm-danger); font-weight: 700; }
.wa-table .col-credit { color: var(--mm-success); font-weight: 700; }

/* =========================================================
   13. Badges & Pills
   ========================================================= */

.sub-badge {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: 0.5rem;
}

/* =========================================================
   14. Utility
   ========================================================= */

.section-divider {
  border: none;
  border-top: 1px solid var(--mm-border);
  margin: 2.4rem 0;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--mm-text-muted);
}

.empty-state .empty-icon {
  font-size: 4.8rem;
  margin-bottom: 1.2rem;
  opacity: 0.4;
}

/* =========================================================
   15. Print Styles
   ========================================================= */

@media print {
  /* Force background colors to print */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide everything navigation/ui related */
  .mm-sidebar,
  .mm-topbar,
  .mm-overlay,
  .no-print,
  .btn,
  .navbar,
  nav {
    display: none !important;
  }

  /* Invoice: full width, A4 layout */
  body {
    font-size: 12pt;
    background: white;
  }

  html { font-size: 62.5%; }

  .mm-main { margin-left: 0 !important; }

  .invoice-wrapper {
    max-width: 100%;
    box-shadow: none;
    border-radius: 0;
  }

  .invoice-header {
    background: var(--mm-primary) !important;
    color: white !important;
  }

  /* WhatsApp ledger print */
  .wa-ledger-page {
    padding: 0;
  }

  .wa-table th {
    background: #0f172a !important;
    color: white !important;
  }

  @page {
    size: A4 portrait;
    margin: 1.5cm;
  }
}
