/* ─── Variables ──────────────────────────────────────────── */
:root {
  --sidebar-w: 255px;
  --topbar-h: 64px;
  --primary: #1e3a8a;
  --primary-hover: #1d4ed8;
  --accent: #3b82f6;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --success-bg: #dcfce7; --success-text: #166534; --success-border: #86efac;
  --danger-bg: #fee2e2;  --danger-text: #991b1b;  --danger-border: #fca5a5;
  --warning-bg: #fef3c7; --warning-text: #92400e; --warning-border: #fcd34d;
  --info-bg: #dbeafe;    --info-text: #1e40af;    --info-border: #93c5fd;
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
a { text-decoration: none; }

/* ─── Layout ─────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.main-wrapper { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--primary);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column; z-index: 200; overflow-y: auto;
}
.sidebar-logo {
  padding: 22px 18px 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo-icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white; font-weight: 800; letter-spacing: -1px;
}
.sidebar-logo-title  { color: #fff; font-size: 17px; font-weight: 700; }
.sidebar-logo-sub    { color: rgba(255,255,255,.45); font-size: 10px; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 14px 10px; }
.nav-section-label {
  color: rgba(255,255,255,.35); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  padding: 12px 10px 5px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px;
  color: rgba(255,255,255,.72); font-size: 13.5px; font-weight: 500;
  transition: all .15s; margin-bottom: 1px; position: relative;
}
.sidebar-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-link.active { background: rgba(255,255,255,.15); color: #fff; }
.sidebar-link.active::before {
  content: ''; position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; background: #60a5fa; border-radius: 0 3px 3px 0;
}
.sidebar-link i { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: #ef4444; color: white;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
}

.sidebar-footer { padding: 14px 10px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
}
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-user-name { color: #fff; font-size: 13px; font-weight: 600; line-height: 1.3; }
.sidebar-user-role { color: rgba(255,255,255,.45); font-size: 11px; }
.sidebar-logout {
  display: flex; align-items: center; gap: 8px; margin-top: 4px;
  color: rgba(255,255,255,.55); padding: 8px 12px; border-radius: 8px;
  font-size: 13px; transition: all .15s;
}
.sidebar-logout:hover { background: rgba(255,255,255,.08); color: #fca5a5; }

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  background: var(--card); height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.topbar-greeting strong { font-size: 18px; font-weight: 700; }
.topbar-greeting small  { display: block; color: var(--text-muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ─── Content area ───────────────────────────────────────── */
.content-area { padding: 28px; flex: 1; }
.page-header  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-title   { font-size: 20px; font-weight: 700; }
.breadcrumb   { color: var(--text-muted); font-size: 12px; }
.breadcrumb span { color: var(--text); font-weight: 500; }

/* ─── Stat cards ─────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: 12px; border: 1px solid var(--border); padding: 20px; display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.si-blue   { background: #dbeafe; color: #1d4ed8; }
.si-green  { background: #dcfce7; color: #15803d; }
.si-yellow { background: #fef3c7; color: #b45309; }
.si-purple { background: #ede9fe; color: #6d28d9; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 3px; }

/* ─── Card ───────────────────────────────────────────────── */
.card { background: var(--card); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: #fff;
}
.card-header-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: #f8fafc; }

/* ─── Table ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.dtable { width: 100%; border-collapse: collapse; }
.dtable th {
  padding: 11px 16px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted); border-bottom: 1px solid var(--border); background: #f8fafc;
  white-space: nowrap;
}
.dtable td { padding: 13px 16px; border-bottom: 1px solid #f1f5f9; font-size: 13.5px; }
.dtable tbody tr:last-child td { border-bottom: none; }
.dtable tbody tr:hover td { background: #f8fafc; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
}
.b-success { background: var(--success-bg); color: var(--success-text); }
.b-danger  { background: var(--danger-bg);  color: var(--danger-text); }
.b-warning { background: var(--warning-bg); color: var(--warning-text); }
.b-gray    { background: #f1f5f9; color: #475569; }
.b-blue    { background: var(--info-bg); color: var(--info-text); }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  border: none; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-danger:hover  { background: #b91c1c; color: #fff; }
.btn-outline { background: #fff; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 7px; border: 1.5px solid var(--border);
  background: #fff; color: var(--text-muted); cursor: pointer; transition: all .15s;
}
.btn-icon:hover        { background: var(--bg); color: var(--text); }
.btn-icon.edit:hover   { border-color: #93c5fd; color: #1d4ed8; background: #dbeafe; }
.btn-icon.danger:hover { border-color: #fca5a5; color: #dc2626; background: #fee2e2; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group   { margin-bottom: 16px; }
.form-label   { display: block; font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 13.5px; color: var(--text);
  outline: none; transition: border-color .15s; background: var(--card);
}
.form-control:focus { border-color: var(--accent); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; }

/* ─── Search ─────────────────────────────────────────────── */
.search-wrap { position: relative; display: inline-flex; align-items: center; }
.search-wrap input {
  padding: 8px 12px 8px 36px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 13px; outline: none;
  width: 270px; transition: border-color .15s; background: var(--bg);
}
.search-wrap input:focus { border-color: var(--accent); background: #fff; }
.search-wrap .si { position: absolute; left: 10px; color: var(--text-muted); pointer-events: none; font-size: 14px; }

/* ─── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 11px 15px; border-radius: 8px; font-size: 13px; font-weight: 500;
  margin-bottom: 18px; display: flex; align-items: flex-start; gap: 9px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.alert-info    { background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-border); }
.alert-close   { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; opacity: .6; font-size: 16px; line-height: 1; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--card); border-radius: 14px; width: 100%; max-width: 460px;
  padding: 28px; transform: translateY(16px); transition: transform .2s;
  box-shadow: 0 20px 60px rgba(0,0,0,.18); margin: 16px;
}
.modal-overlay.open .modal-box { transform: none; }
.modal-title  { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.modal-sub    { color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ─── Cart ───────────────────────────────────────────────── */
.cart-panel { background: var(--card); border-radius: 12px; border: 1px solid var(--border); position: sticky; top: 80px; }
.cart-item  { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid #f1f5f9; gap: 8px; }
.cart-item:last-child { border-bottom: none; }
.cart-item-name { font-size: 13px; font-weight: 500; line-height: 1.3; }
.cart-item-qty  { font-size: 12px; color: var(--text-muted); }

/* ─── Empty ──────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 52px 24px; color: var(--text-muted); }
.empty-state i { font-size: 44px; margin-bottom: 12px; display: block; opacity: .3; }
.empty-state p { font-size: 14px; }

/* ─── Login ──────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; }
.login-left {
  flex: 1; background: var(--primary); display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 48px; text-align: center;
}
.login-left-icon { width: 72px; height: 72px; background: rgba(255,255,255,.15); border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 34px; color: #fff; margin: 0 auto 20px; }
.login-left h1 { color: #fff; font-size: 32px; font-weight: 800; margin-bottom: 8px; }
.login-left p  { color: rgba(255,255,255,.6); font-size: 15px; max-width: 280px; }
.login-right { width: 460px; display: flex; flex-direction: column; justify-content: center; padding: 56px 48px; background: var(--card); }
@media (max-width: 768px) { .login-left { display: none; } .login-right { width: 100%; padding: 40px 24px; } }
.login-right h2 { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.login-right .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 32px; }
.input-icon-wrap { position: relative; }
.input-icon-wrap i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 15px; pointer-events: none; }
.input-icon-wrap .form-control { padding-left: 36px; }

/* ─── Pagination ─────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; border: 1.5px solid var(--border); font-size: 13px; font-weight: 500;
  color: var(--text); transition: all .15s;
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Qty input ──────────────────────────────────────────── */
.qty-input { width: 76px; padding: 6px 8px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 13px; text-align: center; outline: none; }
.qty-input:focus { border-color: var(--accent); }

/* ─── Divider ────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; }
  .main-wrapper { margin-left: 0; }
  .cart-panel { position: static; }
}
