/* ==========================================================================
   Hill Bread — Admin Portal
   Design tokens extracted from Figma (file dBR2wE87l7lbNwKJFSYDjN)
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #f8f5f2;
  --surface: #fffbff;
  --surface-alt: #fdfcfa;
  --panel-muted: #f4f0eb;
  --avatar-pill: #eee0cf;

  /* Sidebar */
  --sidebar: #1e1709;
  --sidebar-header: #130e05;
  --sidebar-card: #2d2211;
  --sidebar-text: #c7baab;
  --sidebar-text-strong: #e5ded1;

  /* Brand */
  --gold: #7b5800;
  --gold-hover: #6a4c00;
  --cream: #ffdea5;

  /* Text */
  --text: #1c1b1e;
  --text-muted: #4e4539;

  /* Lines */
  --border: #cbbfb3;
  --border-soft: #e6ddd2;

  /* Status badges */
  --green-bg: #eaf0ea;
  --green-text: #2e5c2e;
  --amber-bg: #f2eee8;
  --amber-text: #705424;
  --red-bg: #f2eaea;
  --red-text: #8c2e2e;
  --neutral-bg: #f4f0eb;

  /* Misc */
  --shadow-card: 0 1px 6px 0 rgba(0, 0, 0, 0.06);
  --radius-card: 16px;
  --radius-pill: 999px;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --content-max: 1180px;

  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ==========================================================================
   App shell
   ========================================================================== */

.app {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar ----------------------------------------------------------- */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  z-index: 30;
}

.sidebar__brand {
  background: var(--sidebar-header);
  height: 68px;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.sidebar__brand-name {
  color: var(--cream);
  font-size: 17px;
  font-weight: 700;
}

.sidebar__brand-sub {
  color: var(--sidebar-text);
  font-size: 10px;
}

.sidebar__nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  color: var(--sidebar-text);
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item .nav-icon {
  width: 16px;
  text-align: center;
  font-size: 14px;
  line-height: 1;
}

.nav-item:hover {
  background: rgba(123, 88, 0, 0.25);
  color: #fff;
}

.nav-item.is-active {
  background: var(--gold);
  color: #fff;
  font-weight: 500;
}

.sidebar__user {
  margin: 12px;
  background: var(--sidebar-card);
  border-radius: 12px;
  height: 52px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar__user .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--gold);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar__user .name {
  color: var(--sidebar-text-strong);
  font-size: 12px;
  font-weight: 500;
}

.sidebar__user .role {
  color: var(--sidebar-text);
  font-size: 10px;
}

/* ----- Main / topbar ----------------------------------------------------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.topbar__spacer {
  flex: 1;
}

.topbar__search {
  width: 220px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--panel-muted);
  border: none;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar__search::placeholder {
  color: var(--text-muted);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--panel-muted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.icon-btn--avatar {
  background: var(--avatar-pill);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
}

.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--panel-muted);
  border-radius: 10px;
  font-size: 16px;
}

.content {
  padding: 24px;
  flex: 1;
}

/* ==========================================================================
   Reusable pieces
   ========================================================================== */

.panel {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.panel__title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.muted {
  color: var(--text-muted);
}

/* Buttons */
.btn {
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--panel-muted);
}

.btn--primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}

.btn--primary:hover {
  background: var(--gold-hover);
  border-color: var(--gold-hover);
}

.btn--sm {
  height: 24px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  height: 24px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 11px;
  background: var(--neutral-bg);
  color: var(--text);
}

.badge--new {
  background: var(--green-bg);
  color: var(--green-text);
}
.badge--processing {
  background: var(--amber-bg);
  color: var(--amber-text);
}
.badge--ready {
  background: var(--neutral-bg);
  color: var(--text);
}
.badge--delivered {
  background: var(--neutral-bg);
  color: var(--text-muted);
}
.badge--cancelled {
  background: var(--red-bg);
  color: var(--red-text);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 28px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 0;
}

.tab {
  position: relative;
  padding: 4px 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: none;
}

.tab.is-active {
  color: var(--text);
  font-weight: 600;
}

.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--text);
}

/* ==========================================================================
   Dashboard
   ========================================================================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--panel-muted);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 14px 16px 16px;
}

.stat-card__label {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.stat-card__value {
  font-size: 30px;
  font-weight: 700;
  margin: 0 0 8px;
  line-height: 1;
}

.stat-card__sub {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 248px;
  gap: 16px;
  align-items: start;
}

/* Order table (dashboard + orders) */
.table-panel {
  padding: 16px 20px 8px;
}

.table-panel .panel__title {
  margin-bottom: 16px;
}

.order-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.order-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--panel-muted);
  padding: 12px;
  white-space: nowrap;
}

.order-table th:first-child {
  border-radius: 8px 0 0 8px;
}
.order-table th:last-child {
  border-radius: 0 8px 8px 0;
}

.order-table td {
  font-size: 12px;
  padding: 16px 12px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

.order-table tbody tr:hover td {
  background: var(--surface-alt);
}

.order-table .col-id,
.order-table .col-total {
  font-weight: 500;
}

.order-table .col-action {
  text-align: right;
}

/* Right column cards */
.side-card {
  padding: 16px;
  margin-bottom: 16px;
}

.side-card .panel__title {
  font-size: 14px;
  margin-bottom: 14px;
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-list .btn {
  width: 100%;
}

.lowstock-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lowstock-item {
  background: var(--panel-muted);
  border-radius: 8px;
  height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.lowstock-item .warn {
  color: var(--amber-text);
  font-weight: 700;
}

/* ==========================================================================
   Products
   ========================================================================== */

.filter-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-search {
  flex: 1;
  min-width: 220px;
  max-width: 298px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 16px;
  font-size: 14px;
  color: var(--text);
}

.filter-select {
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0 16px;
  font-size: 14px;
  color: var(--text);
}

.filter-bar .btn {
  height: 44px;
}

.filter-bar__spacer {
  flex: 1;
}

.result-count {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.product-card__media {
  position: relative;
  height: 92px;
  background: var(--panel-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.product-card__badge {
  position: absolute;
  top: 8px;
  left: 8px;
  height: 20px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
}

.product-card__body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.product-card__name {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
}

.product-card__cat {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.product-card__price {
  font-size: 19px;
  font-weight: 600;
  margin: 4px 0 0;
}

.product-card__actions {
  display: flex;
  gap: 8px;
  padding: 0 16px 16px;
}

.product-card__actions .btn {
  flex: 1;
}

/* status pill colors reused for product badges */
.pill--in {
  background: var(--green-bg);
  color: var(--green-text);
}
.pill--low {
  background: var(--amber-bg);
  color: var(--amber-text);
}
.pill--out {
  background: var(--red-bg);
  color: var(--red-text);
}

/* ==========================================================================
   Orders summary card
   ========================================================================== */

.summary-card {
  padding: 16px;
}

.summary-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.summary-item {
  background: var(--panel-muted);
  border-radius: 10px;
  padding: 10px 14px;
}

.summary-item__label {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.summary-item__value {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  line-height: 1;
}

/* ==========================================================================
   Empty state (placeholder pages)
   ========================================================================== */

.empty-state {
  padding: 80px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state__icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state__title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 8px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

.sidebar__backdrop {
  display: none;
}

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
  }
  .app.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .app.sidebar-open .sidebar__backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 25;
  }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .topbar__search {
    display: none;
  }
  .order-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .product-grid {
    grid-template-columns: 1fr;
  }
}
