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

:root {
  --primary: #4d7c0f;
  --primary-light: #65a30d;
  --primary-lighter: #84cc16;
  --primary-bg: #f0fdf4;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --sidebar-w: 240px;
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
}

.sidebar-brand {
  display: block;
  padding: 1.75rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand .logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
}
.sidebar-brand .logo span { color: var(--primary-lighter); }
.sidebar-brand .sub {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #94a3b8;
  margin-top: 0.25rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: #94a3b8;
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition);
}
.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}
.sidebar-nav a.active {
  background: rgba(101,163,13,0.15);
  color: var(--primary-lighter);
  font-weight: 600;
}
.sidebar-nav .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  stroke-width: 2;
}

.sidebar-nav .spacer { flex: 1; }

.sidebar-nav a.logout-link {
  color: #f87171;
  margin-top: auto;
}
.sidebar-nav a.logout-link:hover {
  background: rgba(248,113,113,0.1);
}

/* ── Mobile Header ── */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 150;
  background: var(--surface);
  padding: 0.875rem 1.25rem;
  border-bottom: 3px solid var(--primary-light);
  box-shadow: var(--shadow);
}
.mobile-header .brand {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  text-align: center;
}
.mobile-header .brand span { color: var(--primary-light); }

/* --- Header & Mobile --- */
.mobile-header { display: none; }
.mobile-sidebar { display: none; }
.mobile-sidebar-overlay { display: none; }

/* ── Bottom Nav ── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0;
  width: 100%;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 8px rgba(0,0,0,0.04);
  z-index: 200;
  padding: 0.4rem 0;
}
.bottom-nav-links {
  display: flex;
  justify-content: space-around;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0.4rem 0.5rem;
  transition: var(--transition);
}
.bottom-nav a.active { color: var(--primary); }
.bottom-nav .nav-icon { width: 22px; height: 22px; stroke-width: 2; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 2rem 2.5rem;
}

/* ── Page Title ── */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--primary-light);
  display: inline-block;
}

/* ── Section ── */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}
.stat-card .stat-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-top: 0.4rem;
}

/* ── Order Card ── */
.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.order-card:hover { box-shadow: var(--shadow-md); }

.order-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.order-card-head .order-id {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.order-card-head .order-meta {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.order-card-head .order-customer {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.order-items-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.order-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.order-item-row .item-name {
  font-weight: 600;
  color: var(--text);
}
.order-item-row .item-unit {
  color: var(--text-secondary);
  font-size: 0.82rem;
  margin-left: 0.5rem;
}
.order-item-row .item-qty {
  font-weight: 700;
  color: var(--text);
  text-align: right;
  white-space: nowrap;
}
.order-item-row .item-qty small {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.75rem;
  display: block;
}

.order-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ── Tables (for catalogue, admin catalogue, view_order) ── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: #f8fafc;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}
tbody tr { transition: var(--transition); }
tbody tr:hover { background: var(--primary-bg); }
tbody tr:last-child td { border-bottom: none; }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
}
input[type="text"], input[type="number"], input[type="password"], input[type="email"], select, textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  background: #fafbfc;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  border-radius: 8px;
  transition: var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(101,163,13,0.12);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary-light);
  color: #fff;
  box-shadow: 0 2px 4px rgba(101,163,13,0.2);
}
.btn-primary:hover {
  background: var(--primary);
  box-shadow: 0 4px 8px rgba(101,163,13,0.25);
  transform: translateY(-1px);
}
.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}
.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-accepted { background: #dbeafe; color: #1e40af; }
.badge-dispatched { background: #fce7f3; color: #9d174d; }
.badge-delivered  { background: #dcfce7; color: #166534; }

/* ── Alerts ── */
.alert {
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  border-left: 4px solid;
}
.alert-success { background: #f0fdf4; border-color: #16a34a; color: #15803d; }
.alert-error   { background: #fef2f2; border-color: #dc2626; color: #b91c1c; }

/* ── Utilities ── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ── Auth Pages ── */
.auth-wrap {
  max-width: 420px;
  margin: 3rem auto;
}

/* ══════════════════════════════════════════════
   RESPONSIVE — max-width: 768px
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem; }
  .bottom-nav { display: block; }
  .menu-toggle { display: block; cursor: pointer; color: var(--text); }
  .menu-toggle svg { width: 24px; height: 24px; }
  
  .mobile-sidebar {
    position: fixed;
    top: 0; left: -280px;
    width: 260px;
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 300;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .mobile-sidebar.open { left: 0; }
  .mobile-sidebar-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 250;
    display: none;
  }
  .mobile-sidebar-overlay.open { display: block; }

  .main-content {
    margin-left: 0;
    padding: 1rem 1rem 5rem 1rem;
  }

  .stats-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .section { padding: 1rem; }

  .auth-wrap { margin: 1.5rem auto; max-width: 100%; }

  .page-title { font-size: 1.25rem; }

  /* Catalogue table on mobile */
  .table-wrap { border: none; overflow-x: hidden; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody,
  .table-wrap th, .table-wrap td, .table-wrap tr { display: block; }
  .table-wrap thead tr { display: none; }
  .table-wrap tr {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .table-wrap td {
    border: none;
    border-bottom: 1px solid #f1f5f9;
    padding: 0.6rem 0.75rem 0.6rem 42%;
    position: relative;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 38px;
  }
  .table-wrap td::before {
    content: attr(data-label);
    position: absolute;
    left: 0.75rem;
    width: 38%;
    text-align: left;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-secondary);
  }
  .table-wrap td:last-child { border-bottom: none; }
}
/* --- E-Commerce Additions --- */
.product-card { display: flex; flex-direction: column; justify-content: space-between; padding: 1.5rem; text-align: center; }
.product-title { font-size: 1.2rem; font-weight: 700; color: var(--primary); margin-bottom: 0.5rem; }
.product-price { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.25rem; }
.product-meta { font-size: 0.85rem; color: #64748b; margin-bottom: 1.5rem; }
.product-action { border-top: 1px solid var(--border); padding-top: 1rem; }
.qty-label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; color: #475569; }
.qty-input { width: 100%; text-align: center; font-size: 1.1rem; padding: 0.5rem; border: 2px solid var(--border); border-radius: 6px; }
.qty-input:focus { border-color: var(--primary); outline: none; }
