/* =============================================================
   Crafio Inventory — theme.css  v1.3
   ============================================================= */

/* ---- Theme Variables ---- */
:root {
  --brand:    #D4507A;
  --brand-d:  #B03060;
  --brand-bg: rgba(212,80,122,.10);
  --bg:       #0C0C0E;
  --surface:  #141416;
  --surface2: #1C1C1F;
  --border:   #2A2A2E;
  --text:     #F0EDE8;
  --muted:    #888;
  --danger:   #E05050;
  --success:  #50C060;
  --shadow:   0 4px 24px rgba(0,0,0,.4);
  --topbar-h: 56px;
  --sidebar-w: 230px;
}
[data-theme="light"] {
  --bg:       #F5F4F2;
  --surface:  #FFFFFF;
  --surface2: #F0EEF0;
  --border:   #E0DCE0;
  --text:     #1A1820;
  --muted:    #777;
  --danger:   #C03030;
  --success:  #2A8A3A;
  --shadow:   0 4px 24px rgba(0,0,0,.10);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; overflow-x: hidden; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
  transition: background .2s, color .2s;
}

/* ---- Top Bar ---- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-logo { display: flex; align-items: center; text-decoration: none; flex-shrink: 0; }
.topbar-logo img { height: 30px; width: auto; display: block; }
.topbar-logo-text { font-family:'Syne',sans-serif; font-weight:800; font-size:20px; color:var(--brand); letter-spacing:-.5px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* ---- Search ---- */
.search-wrap { flex: 1; max-width: 400px; position: relative; min-width: 0; }
.search-wrap input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px 8px 34px;
  color: var(--text); font-family: inherit; font-size: 14px; outline: none;
  transition: border-color .2s;
}
.search-wrap input:focus { border-color: var(--brand); }
.search-wrap .si { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 13px; border-radius: 7px;
  font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: .15s; text-decoration: none;
  white-space: nowrap; line-height: 1;
}
.btn-primary  { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); }
.btn-ghost    { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger   { background: rgba(220,80,80,.12); color: var(--danger); border: 1px solid rgba(220,80,80,.25); }
.btn-success  { background: var(--success); color: #fff; border: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---- Theme Toggle ---- */
.theme-toggle {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 10px; cursor: pointer;
  font-size: 15px; display: flex; align-items: center; gap: 4px;
  color: var(--text); transition: .2s; flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--brand); }
.icon-sun  { display: none; }
.icon-moon { display: inline; }
[data-theme="light"] .icon-sun  { display: inline; }
[data-theme="light"] .icon-moon { display: none; }

/* ---- Hamburger ---- */
.hamburger {
  display: none; background: transparent; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 18px; cursor: pointer;
  padding: 5px 8px; flex-shrink: 0; line-height: 1;
}

/* ============================================================
   PAGE LAYOUT — sidebar + main
   ============================================================ */
.layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
  overflow-x: hidden;
  max-width: 100vw;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
  /* mobile: hidden by default, shown as overlay */
  transition: transform .25s ease;
}
.sidebar-section { padding: 0 12px; margin-bottom: 20px; }
.sidebar-label {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
  padding: 0 4px;
}
.sidebar-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--text);
  text-decoration: none; cursor: pointer; transition: background .15s;
  border: none; background: transparent; width: 100%; text-align: left;
  gap: 6px;
}
.sidebar-link:hover  { background: var(--surface2); }
.sidebar-link.active { background: var(--brand-bg); color: var(--brand); font-weight: 500; }
.sidebar-count { font-size: 11px; color: var(--muted); margin-left: auto; }

/* ---- Sidebar overlay backdrop ---- */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 89;
}
.sidebar-overlay.open { display: block; }

/* ---- Main content ---- */
.main {
  flex: 1;
  min-width: 0; /* prevent flex overflow */
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px;
}

/* ---- Cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px; margin-bottom: 18px;
  min-width: 0; max-width: 100%; overflow: hidden;
}
.card h2 {
  font-family: 'Syne', sans-serif; font-size: 11px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 16px;
}

/* ---- Form fields ---- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .7px; margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 7px; padding: 9px 12px; color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 14px; outline: none;
  transition: border-color .2s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field textarea { resize: vertical; min-height: 80px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 10px 12px;
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .7px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2); white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ---- Badges ---- */
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; display:inline-block; }
.badge-danger  { background: rgba(220,80,80,.15); color: var(--danger); }
.badge-success { background: rgba(80,192,96,.12); color: var(--success); }
.badge-brand   { background: var(--brand-bg); color: var(--brand); }
.badge-muted   { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
.role-admin { background: var(--brand-bg); color: var(--brand); }
.role-staff { background: rgba(80,192,96,.1); color: var(--success); }
.qty-low { color: var(--danger); font-weight: 600; }
.qty-ok  { color: var(--success); font-weight: 500; }

/* ---- Alerts ---- */
.alert { padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error   { background: rgba(220,80,80,.08); border: 1px solid rgba(220,80,80,.25); color: var(--danger); }
.alert-success { background: rgba(80,192,96,.08); border: 1px solid rgba(80,192,96,.25); color: var(--success); }
.alert-warn    { background: rgba(212,80,122,.08); border: 1px solid rgba(212,80,122,.25); color: var(--brand); }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 12px; border-radius: 6px; font-size: 13px;
  text-decoration: none; border: 1px solid var(--border); color: var(--text);
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination span.current { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---- Item images ---- */
.item-img { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.item-img-ph { width: 38px; height: 38px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 18px; }

/* ============================================================
   MOBILE  ≤ 768px
   ============================================================ */
@media (max-width: 768px) {

  /* Show hamburger */
  .hamburger { display: flex; }

  /* Compress search */
  .search-wrap { max-width: 160px; }

  /* Hide non-essential topbar items */
  .topbar-hide-mobile { display: none !important; }
  .btn-label-hide { display: none; }

  /* Sidebar becomes a fixed overlay panel */
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 90;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Layout stacks — main takes full width */
  .layout {
    display: block;
  }
  .main {
    padding: 14px;
    min-height: calc(100vh - var(--topbar-h));
  }

  /* Hide non-essential table columns */
  .col-hide-mobile { display: none !important; }

  /* 2-col grid on mobile */
  .grid2 { grid-template-columns: 1fr; }

  /* Page containers */
  .page { padding: 0 14px !important; }
}

@media (max-width: 480px) {
  .search-wrap { max-width: 120px; }
  .topbar { gap: 8px; padding: 0 10px; }
}
