/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w:   220px;
  --header-h:    56px;
  --color-bg:    #f5f5f5;
  --color-surface: #ffffff;
  --color-sidebar: #1a1a1a;
  --color-sidebar-text: #c8c8c8;
  --color-sidebar-active: #ffffff;
  --color-primary: #c8a96e;
  --color-primary-dark: #a88a50;
  --color-danger:  #dc3545;
  --color-success: #198754;
  --color-warning: #ffc107;
  --color-text:    #1a1a1a;
  --color-muted:   #6c757d;
  --color-border:  #dee2e6;
  --radius:        6px;
  --shadow:        0 1px 3px rgba(0,0,0,.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor;
      stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Login Page ───────────────────────────────────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--color-bg);
}
.login-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo img { max-height: 60px; margin-bottom: 12px; }
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p  { color: var(--color-muted); font-size: 13px; }

/* ── Admin Layout ─────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand img { max-height: 32px; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  color: var(--color-sidebar-text);
  font-size: 13.5px;
  transition: background .15s, color .15s;
  border-radius: 0;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: rgba(255,255,255,.12); color: var(--color-sidebar-active); }
.sidebar-nav hr { border: none; border-top: 1px solid rgba(255,255,255,.08); margin: 8px 0; }
.sidebar-nav a.logout { color: #ff6b6b; }

.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}
.admin-header {
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-header h1 { font-size: 18px; font-weight: 600; }
.admin-content { padding: 24px; }

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-right: 12px;
  border: none;
  background: none;
  border-radius: var(--radius);
  color: var(--color-text);
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--color-bg); }
.sidebar-toggle svg { width: 22px; height: 22px; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 90;
}

/* ── Panels ───────────────────────────────────────────────────────────────── */
.panel {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
}
.panel-header h2 { font-size: 15px; font-weight: 600; }
.panel > table { margin: 0; border-radius: 0; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-outline { border-color: var(--color-border); background: #fff; color: var(--color-text); }
.btn-outline:hover { background: var(--color-bg); }
.btn-ghost  { background: transparent; color: var(--color-muted); }
.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-block  { display: flex; width: 100%; justify-content: center; margin-bottom: 8px; }
.btn-sm     { padding: 4px 10px; font-size: 12px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { padding: 14px 20px; border-bottom: 1px solid var(--color-border); }
.form-group:last-child { border-bottom: none; }
.panel > .form-group:first-of-type { padding-top: 16px; }
label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
input[type=text], input[type=email], input[type=number], input[type=password],
input[type=search], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(200,169,110,.18);
}
textarea { resize: vertical; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span {
  padding: 8px 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--color-muted);
  font-size: 13.5px;
  white-space: nowrap;
}
.input-prefix input {
  border-radius: 0 var(--radius) var(--radius) 0;
  flex: 1;
}
.hint   { font-size: 12px; color: var(--color-muted); margin-top: 4px; }
.required { color: var(--color-danger); }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; }
.form-actions { padding: 16px 20px; }

/* ── Form grid (product add/edit) ─────────────────────────────────────────── */
.form-grid { display: flex; gap: 20px; align-items: flex-start; }
.form-col-main { flex: 1; min-width: 0; }
.form-col-side { width: 260px; flex-shrink: 0; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.5px;
}
.alert-success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.alert-error   { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.alert-warning { background: #fff3cd; color: #664d03; border: 1px solid #ffecb5; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-pending    { background: #fff3cd; color: #664d03; }
.badge-processing { background: #cfe2ff; color: #084298; }
.badge-shipped    { background: #d1e7dd; color: #0f5132; }
.badge-completed  { background: #d1e7dd; color: #0f5132; }
.badge-cancelled  { background: #f8d7da; color: #842029; }
.badge-error      { background: #f8d7da; color: #842029; }
.badge-warning    { background: #fff3cd; color: #664d03; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafafa; }
.data-table tfoot td { background: var(--color-bg); font-weight: 500; }
.data-table .total-row td { font-size: 15px; }
.text-right { text-align: right; }

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.search-form { display: flex; gap: 8px; align-items: center; flex: 1; }
.search-form input[type=search] { max-width: 240px; }
.search-form select { max-width: 180px; }

/* ── Filter tabs ──────────────────────────────────────────────────────────── */
.filter-tabs { display: flex; gap: 4px; }
.filter-tabs a {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--color-muted);
  border: 1px solid transparent;
}
.filter-tabs a:hover { background: var(--color-bg); text-decoration: none; }
.filter-tabs a.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ── Dashboard stats ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}
.stat-card.stat-alert { border-left: 3px solid var(--color-warning); }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--color-muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.stat-link  { display: block; font-size: 12px; margin-top: 8px; color: var(--color-primary); }

.dashboard-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
@media (max-width: 900px) { .dashboard-cols { grid-template-columns: 1fr; } }

.quick-actions { padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }

/* ── Products table ───────────────────────────────────────────────────────── */
.product-thumb img { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; }
.no-image { width: 48px; height: 48px; background: var(--color-bg); border-radius: 4px;
            display: flex; align-items: center; justify-content: center; font-size: 10px;
            color: var(--color-muted); text-align: center; }
.strikethrough { text-decoration: line-through; color: var(--color-muted); }
.actions { display: flex; gap: 6px; align-items: center; }
.actions form { margin: 0; }

/* ── Image preview ────────────────────────────────────────────────────────── */
.image-preview-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.image-preview-grid img { width: 80px; height: 80px; object-fit: cover; border-radius: 4px; border: 1px solid var(--color-border); }
.existing-images { padding: 14px 20px; border-bottom: 1px solid var(--color-border); }
.image-preview-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.image-keep { font-size: 11px; display: flex; align-items: center; gap: 4px; font-weight: 400; }

/* ── Order detail ─────────────────────────────────────────────────────────── */
.order-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.order-col-side {}
@media (max-width: 900px) { .order-grid { grid-template-columns: 1fr; } }
.info-list { padding: 16px 20px; }
.info-list dt { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); margin-top: 12px; }
.info-list dt:first-child { margin-top: 0; }
.info-list dd { margin-left: 0; }
address { padding: 16px 20px; font-style: normal; line-height: 1.7; }
.note-list { list-style: none; padding: 8px 20px; }
.note-list li { padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.note-list li:last-child { border-bottom: none; }
.note-text { display: block; }
.note-meta { font-size: 11px; color: var(--color-muted); }

/* ── Settings ─────────────────────────────────────────────────────────────── */
.settings-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.settings-cols .panel { margin-bottom: 0; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.empty { padding: 32px; text-align: center; color: var(--color-muted); }
.text-muted { color: var(--color-muted); }
code { font-size: 12px; background: var(--color-bg); padding: 2px 6px; border-radius: 3px; }

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .2s;
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .sidebar-backdrop.open { display: block; }
  .form-grid { flex-direction: column; }
  .form-col-side { width: 100%; }
}
