/* ═══════════════════════════════════════════════
   RestockHQ — Dashboard Styles
   Font: General Sans (body), Instrument Serif (display)
   Theme: Dark sidebar, warm content area
   ═══════════════════════════════════════════════ */

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

:root {
  --bg: #f5f3ef;
  --bg-alt: #edeae4;
  --surface: #ffffff;
  --surface-hover: #faf9f7;
  --sidebar: #111318;
  --sidebar-hover: #1c1e25;
  --sidebar-active: #252830;
  --ink: #1a1d26;
  --ink-secondary: #5a5d6a;
  --ink-muted: #8b8e9a;
  --ink-light: rgba(255,255,255,0.55);
  --ink-white: rgba(255,255,255,0.9);
  --accent: #e85d26;
  --accent-hover: #d14f1c;
  --accent-soft: rgba(232, 93, 38, 0.08);
  --accent-glow: rgba(232, 93, 38, 0.15);
  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.08);
  --yellow: #d97706;
  --yellow-soft: rgba(217, 119, 6, 0.08);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.08);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.08);
  --border: #e5e2dc;
  --border-light: #f0ede8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
  --radius: 10px;
  --radius-lg: 14px;
  --transition: 0.2s ease;
}

html { font-size: 15px; }
body {
  font-family: 'General Sans', -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ─── Auth Layout ─────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(175deg, #111318 0%, #1a1d26 50%, #2a1f15 100%);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 20px;
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  font-family: 'Instrument Serif', serif;
  font-size: 28px;
  font-weight: 400;
  margin-bottom: 8px;
  color: var(--ink);
}

.auth-logo span { color: var(--accent); }

.auth-subtitle {
  color: var(--ink-muted);
  font-size: 14px;
  margin-bottom: 36px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-input::placeholder { color: var(--ink-muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }

.btn-secondary {
  background: var(--bg);
  color: var(--ink);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-alt); border-color: var(--ink-muted); }

.btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
  padding: 8px 12px;
}

.btn-ghost:hover { background: var(--bg); color: var(--ink); }

.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }

.btn-success { background: var(--green-soft); color: var(--green); }
.btn-success:hover { background: var(--green); color: white; }

.auth-toggle {
  text-align: center;
  margin-top: 24px;
  font-size: 13px;
  color: var(--ink-muted);
}

.auth-toggle a {
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.auth-toggle a:hover { text-decoration: underline; }

.auth-error {
  background: var(--red-soft);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 20px;
  display: none;
}

/* ─── Dashboard Layout ────────────────────────── */
.dashboard {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  padding: 24px 12px;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  color: var(--ink-white);
  padding: 0 12px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 16px;
}

.sidebar-logo span { color: var(--accent); }

.nav-section {
  margin-bottom: 8px;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 12px 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink-light);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--ink-white);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: white;
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.6;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-light);
  font-size: 13px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.logout-btn {
  display: block;
  margin-top: 12px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
}

.logout-btn:hover { color: rgba(255,255,255,0.7); }

/* ─── Main Content ────────────────────────────── */
.main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  padding: 32px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-family: 'Instrument Serif', serif;
  font-size: 28px;
  font-weight: 400;
  color: var(--ink);
}

.page-subtitle {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* ─── Stats Cards ─────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.stat-card-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 6px;
}

.stat-card.warning { border-left: 3px solid var(--yellow); }
.stat-card.danger { border-left: 3px solid var(--red); }
.stat-card.success { border-left: 3px solid var(--green); }
.stat-card.info { border-left: 3px solid var(--blue); }

/* ─── Tables ──────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 24px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
}

td {
  padding: 14px 24px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--ink);
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--surface-hover); }

/* ─── Status Badges ───────────────────────────── */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.badge-pending { background: var(--yellow-soft); color: var(--yellow); }
.badge-confirmed { background: var(--blue-soft); color: var(--blue); }
.badge-processing { background: var(--blue-soft); color: var(--blue); }
.badge-shipped { background: var(--accent-soft); color: var(--accent); }
.badge-delivered { background: var(--green-soft); color: var(--green); }
.badge-cancelled { background: var(--red-soft); color: var(--red); }
.badge-draft { background: var(--yellow-soft); color: var(--yellow); }
.badge-sent { background: var(--blue-soft); color: var(--blue); }
.badge-received { background: var(--green-soft); color: var(--green); }
.badge-incoming { background: var(--green-soft); color: var(--green); }
.badge-outgoing { background: var(--accent-soft); color: var(--accent); }

.badge-stock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.badge-stock.low { background: var(--red-soft); color: var(--red); }
.badge-stock.ok { background: var(--green-soft); color: var(--green); }
.badge-stock.warning { background: var(--yellow-soft); color: var(--yellow); }

/* ─── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: var(--bg);
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
}

.modal-close:hover { background: var(--bg-alt); color: var(--ink); }

.modal-body { padding: 24px 28px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 18px 28px;
  border-top: 1px solid var(--border-light);
}

/* ─── Filters ─────────────────────────────────── */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-input {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  min-width: 180px;
  outline: none;
  transition: border-color var(--transition);
}

.filter-input:focus { border-color: var(--accent); }

.filter-select {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238b8e9a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ─── Form grid ───────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.form-full { grid-column: 1 / -1; }

/* ─── Order Items ─────────────────────────────── */
.item-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}

.item-row select, .item-row input {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  outline: none;
}

.item-row select { flex: 2; }
.item-row input { flex: 1; min-width: 70px; }

.remove-item-btn {
  padding: 9px;
  border: none;
  background: var(--red-soft);
  color: var(--red);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}

.remove-item-btn:hover { background: var(--red); color: white; }

.add-item-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  margin-top: 4px;
}

.add-item-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Empty State ─────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--ink-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.empty-state-desc { font-size: 13px; }

/* ─── Toast ───────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--sidebar);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Auto-reorder alert ──────────────────────── */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
}

.alert-warning {
  background: var(--yellow-soft);
  color: var(--yellow);
  border: 1px solid rgba(217, 119, 6, 0.15);
}

.alert-success {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(22, 163, 74, 0.15);
}

/* ─── Mobile ──────────────────────────────────── */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 101;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--sidebar);
  color: white;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px 16px; padding-top: 64px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .filters { flex-direction: column; }
  .filter-input, .filter-select { width: 100%; min-width: unset; }
}

/* ─── Scrollbar ───────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

/* ─── PO Detail ───────────────────────────────── */
.po-items-list {
  margin-top: 12px;
}

.po-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}

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

.auto-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
}

/* ─── Skeleton ────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg) 25%, var(--bg-alt) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  height: 20px;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ─── Action dropdown ─────────────────────────── */
.action-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.action-btn:hover { background: var(--bg); border-color: var(--ink-muted); }

select.action-btn {
  appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238b8e9a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
