/* ==========================================================================
   Nelum Foods — Management System
   Shared stylesheet
   ========================================================================== */

:root {
  --color-primary: #ff6b35;
  --color-primary-dark: #e2551f;
  --color-primary-light: #fff1ea;
  --color-secondary: #2e7d32;
  --color-secondary-light: #e8f5e9;
  --color-accent: #ffb703;
  --color-dark: #22252b;
  --color-bg: #f6f5f2;
  --color-card: #ffffff;
  --color-border: #ece8e2;
  --color-text: #2f3136;
  --color-muted: #7c8089;
  --color-danger: #e14848;
  --color-danger-light: #fdeaea;
  --color-success: #1f9d55;
  --color-success-light: #e7f8ee;
  --color-info: #2b7de9;
  --color-info-light: #eaf2fd;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(34, 25, 10, 0.06);
  --shadow: 0 6px 20px rgba(34, 25, 10, 0.08);
  --shadow-lg: 0 12px 34px rgba(34, 25, 10, 0.14);
  --sidebar-w: 250px;
  --topbar-h: 66px;
  --bottomnav-h: 68px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Inter', 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

h1, h2, h3, h4 {
  font-family: 'Poppins', 'Inter', sans-serif;
  margin: 0 0 6px;
  color: var(--color-dark);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; }
img { max-width: 100%; display: block; }

/* ---------------------------------------------------------------------- */
/* App shell layout                                                       */
/* ---------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar (desktop) */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #22252b 0%, #2b2f38 100%);
  color: #f2f0ec;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  padding: 22px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
}

.brand-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.brand-name {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  line-height: 1.1;
}
.brand-tag {
  font-size: 11.5px;
  color: #b7bac0;
  letter-spacing: .03em;
}

.side-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px;
}

.side-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: #cfd1d6;
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: 4px;
  transition: background .15s, color .15s;
}
.side-nav .nav-link i { width: 20px; text-align: center; font-size: 16px; color: #9a9da4; }
.side-nav .nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.side-nav .nav-link.active {
  background: var(--color-primary);
  color: #fff;
}
.side-nav .nav-link.active i { color: #fff; }

.sidebar-footer {
  padding: 14px 22px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: #8d9096;
}

/* Main content area */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding-bottom: calc(var(--bottomnav-h) + 24px);
}

/* Top bar */
.topbar {
  height: var(--topbar-h);
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 16px;
}
.topbar-title h1 { font-size: 20px; margin: 0; }
.topbar-title p { margin: 0; font-size: 12.5px; color: var(--color-muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-date {
  font-size: 13px;
  color: var(--color-muted);
  background: var(--color-bg);
  padding: 8px 14px;
  border-radius: 30px;
  display: none;
}
@media (min-width: 640px) {
  .topbar-date { display: inline-block; }
}

.page-wrap {
  padding: 22px;
  max-width: 1200px;
}

/* ---------------------------------------------------------------------- */
/* Bottom nav (mobile)                                                    */
/* ---------------------------------------------------------------------- */
.bottom-nav {
  display: none;
}

@media (max-width: 899px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding-bottom: calc(var(--bottomnav-h) + 20px); }
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--bottomnav-h);
    background: var(--color-card);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -6px 20px rgba(0,0,0,0.06);
    z-index: 50;
    justify-content: space-around;
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    color: var(--color-muted);
    font-weight: 500;
  }
  .bottom-nav a i { font-size: 18px; }
  .bottom-nav a.active { color: var(--color-primary); }
  .bottom-nav a.fab-link {
    position: relative;
    top: -14px;
  }
  .bottom-nav a.fab-link .fab-circle {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 2px;
  }
}

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

.grid { display: grid; gap: 16px; }
.stat-grid {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 720px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--color-muted); font-weight: 500; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; font-family: 'Poppins', sans-serif; margin-top: 2px; color: var(--color-dark); }
.stat-card .stat-sub { font-size: 12px; margin-top: 6px; font-weight: 600; }
.stat-card .stat-sub.up { color: var(--color-success); }
.stat-card .stat-sub.down { color: var(--color-danger); }

.stat-card.income .stat-icon { background: var(--color-success-light); color: var(--color-success); }
.stat-card.expense .stat-icon { background: var(--color-danger-light); color: var(--color-danger); }
.stat-card.profit .stat-icon { background: var(--color-primary-light); color: var(--color-primary-dark); }
.stat-card.packs .stat-icon { background: var(--color-info-light); color: var(--color-info); }

.section-row {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 960px) {
  .section-row.cols-2 { grid-template-columns: 1.4fr 1fr; }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.card-header h3 { font-size: 15.5px; margin: 0; }
.card-header .muted { font-size: 12px; color: var(--color-muted); }

/* ---------------------------------------------------------------------- */
/* Buttons                                                                */
/* ---------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: transform .08s ease, box-shadow .15s, background .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: 0 4px 12px rgba(255,107,53,0.28); }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary-dark); }
.btn-ghost { background: var(--color-bg); color: var(--color-text); }
.btn-danger { background: var(--color-danger-light); color: var(--color-danger); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; border-radius: 8px; }

/* ---------------------------------------------------------------------- */
/* Forms                                                                  */
/* ---------------------------------------------------------------------- */
.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
@media (min-width: 620px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--color-muted); }
.field input, .field select, .field textarea {
  padding: 11px 13px;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  font-size: 14.5px;
  background: #fdfcfb;
  color: var(--color-text);
  font-family: inherit;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  background: #fff;
}
.field .hint { font-size: 11.5px; color: var(--color-muted); }
.field-inline { display: flex; align-items: center; gap: 8px; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------- */
/* Tables                                                                 */
/* ---------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 560px;
}
table.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-muted);
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--color-border);
  white-space: nowrap;
}
table.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
table.data-table tbody tr:hover { background: #fbfaf8; }
table.data-table tbody tr:last-child td { border-bottom: none; }
.cell-strong { font-weight: 600; color: var(--color-dark); }
.cell-actions { display: flex; gap: 6px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 30px;
}
.badge-lunch { background: #fff4e0; color: #b5750a; }
.badge-dinner { background: #eaeafc; color: #4a4fc9; }
.badge-paid { background: var(--color-success-light); color: var(--color-success); }
.badge-pending { background: #fff4e0; color: #b5750a; }
.badge-income { background: var(--color-success-light); color: var(--color-success); }
.badge-expense { background: var(--color-danger-light); color: var(--color-danger); }

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--color-muted);
}
.empty-state i { font-size: 34px; margin-bottom: 10px; color: var(--color-border); }

/* ---------------------------------------------------------------------- */
/* Chips / filters                                                       */
/* ---------------------------------------------------------------------- */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 15px;
  border-radius: 30px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  color: var(--color-muted);
}
.chip.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ---------------------------------------------------------------------- */
/* Modal                                                                  */
/* ---------------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 16, 10, 0.5);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal-overlay.open { display: flex; }
@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 20px; }
}
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .22s ease;
}
@media (min-width: 640px) {
  .modal-box { border-radius: var(--radius-lg); }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-close { background: var(--color-bg); border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 15px; color: var(--color-muted); }

/* ---------------------------------------------------------------------- */
/* Toast                                                                  */
/* ---------------------------------------------------------------------- */
#toast-container {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 380px);
}
@media (min-width: 900px) {
  #toast-container { bottom: 24px; }
}
.toast {
  background: var(--color-dark);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn .2s ease;
}
.toast i { font-size: 16px; }
.toast.success i { color: #4ade80; }
.toast.error i { color: #f87171; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------------- */
/* Misc utilities                                                        */
/* ---------------------------------------------------------------------- */
.text-muted { color: var(--color-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.divider { height: 1px; background: var(--color-border); margin: 16px 0; }
.scroll-x { overflow-x: auto; }

.legend-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--color-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.page-title-row h2 { font-size: 22px; margin-bottom: 4px; }
.page-title-row p { margin: 0; color: var(--color-muted); font-size: 13.5px; }

.summary-strip {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.summary-pill {
  background: var(--color-bg);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 12.5px;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.summary-pill b { display: block; font-size: 16px; color: var(--color-dark); font-family: 'Poppins', sans-serif; margin-top: 2px; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ff6b35 0%, #ffb703 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 36px 30px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

@media print {
  .sidebar, .bottom-nav, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
}
