/* =====================================================
   SUMMER HAMMOCK — Backend / Admin Stylesheet
   Matches frontend palette: Pine + Terracotta/Saffron
   ===================================================== */
:root {
  --bg: #f6f4ea;
  --surface: #ffffff;
  --ink: #123527;
  --ink-soft: #3d5a4d;
  --muted: #6d7f6e;
  --line: #e2e5cf;
  --line-strong: #cfd6bd;
  --accent: #e4572e;
  --accent-dark: #c2441f;
  --accent-soft: #fbe7db;
  --gold: #f3a712;
  --leaf: #1f8a5f;
  --leaf-soft: #e3ecd9;
  --palm: #0d3b2a;
  --palm-light: #1d6b50;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --error: #dc2626;
  --error-soft: #fee2e2;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --info: #1f8a5f;
  --info-soft: #e3ecd9;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.06);
  --shadow: 0 4px 14px rgba(15,23,42,0.07);
  --shadow-lg: 0 14px 36px rgba(15,23,42,0.12);
  --sidebar-w: 250px;
  /* Shared with storefront: Inter 400–800 — one readable sans for all UI */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent); }
img, svg { max-width: 100%; display: block; }
button, input, textarea, select { font-family: inherit; font-size: inherit; }

/* ========== LOGIN PAGE ========== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(243,167,18,0.22), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(31,138,95,0.2), transparent 50%),
    linear-gradient(135deg, #0d3b2a 0%, #123527 100%);
  padding: 24px;
}
.login-card {
  background: #fff; border-radius: var(--radius-lg); padding: 44px 40px;
  width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; justify-content: center; margin-bottom: 24px; }
.login-logo img { height: 84px; width: auto; }
.login-card h1 { font-family: var(--font-sans); font-size: 28px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 28px; font-size: 14px; }

/* ========== LAYOUT ========== */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: var(--palm); color: #cbd5e1;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 10;
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-brand { padding: 22px 22px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-row img { height: 44px; width: 44px; object-fit: contain; background: #fff; border-radius: 12px; padding: 5px; }
.brand-name { font-family: var(--font-sans); color: #fff; font-size: 16px; font-weight: 700; line-height: 1.15; }
.sidebar-brand .tag { font-size: 11px; color: var(--accent); letter-spacing: 2px; text-transform: uppercase; margin-top: 6px; font-weight: 600; }
.sidebar-brand { position: relative; }
.sidebar-close { display: none; }
.admin-scrim { display: none; }

.sidebar-nav { padding: 14px 12px; flex: 1; }
.sidebar-nav .nav-label {
  font-size: 10px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 1.5px;
  padding: 16px 12px 8px;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 8px;
  color: #cbd5e1; font-size: 14px; font-weight: 500; margin-bottom: 2px; transition: all .2s;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.active { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(228,87,46,0.3); }
.sidebar-nav a .badge-ml { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 100px; font-weight: 700; }
.sidebar-nav a.active .badge-ml { background: #fff; color: var(--accent); }

.sidebar-footer {
  padding: 16px 22px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: #64748b;
}
.sidebar-footer .user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-footer .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13px;
}
.sidebar-footer .uname { color: #fff; font-weight: 600; font-size: 13px; }
.sidebar-footer .urole { color: #94a3b8; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: #fff; padding: 18px 30px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-family: var(--font-sans); font-size: 22px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-right form { display: flex; align-items: center; position: relative; }
.topbar-icon-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--bg); border: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-soft); position: relative;
  transition: all .2s;
}
.topbar-icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.topbar-icon-btn svg { width: 18px; height: 18px; }
.topbar-icon-btn .dot {
  position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; border: 2px solid #fff;
}
.logout-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 100px;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 600; border: none; cursor: pointer; transition: all .2s;
}
.logout-btn:hover { background: var(--accent); }

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

/* ========== CARDS / SHARED ========== */
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.card-title { font-family: var(--font-sans); font-size: 20px; font-weight: 700; }
.card-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 8px;
  border: none; font-weight: 600; font-size: 13px; cursor: pointer; transition: all .2s;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent); color: #fff; transform: translateY(-1px); box-shadow: 0 6px 14px rgba(228,87,46,0.25); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); }
.btn-outline:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 7px 14px; font-size: 12px; }

/* ========== STATS DASHBOARD ========== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card {
  background: #fff; padding: 22px 24px; border-radius: var(--radius-lg);
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.stat-card::before { content:''; position:absolute; top:0; left:0; width:4px; height:100%; background:var(--accent); }
.stat-card:nth-child(2)::before { background: var(--info); }
.stat-card:nth-child(3)::before { background: var(--success); }
.stat-card:nth-child(4)::before { background: var(--gold); }
.stat-card:nth-child(5)::before { background: var(--accent); }
.stat-card:nth-child(6)::before { background: var(--error); }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.stat-value { font-family: var(--font-sans); font-size: 30px; font-weight: 800; line-height: 1.1; margin-bottom: 6px; }
.stat-trend { font-size: 12px; color: var(--success); font-weight: 600; }
.stat-trend.down { color: var(--error); }
.stat-icon { position: absolute; top: 18px; right: 20px; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-card:nth-child(2) .stat-icon { background: var(--info-soft); color: var(--info); }
.stat-card:nth-child(3) .stat-icon { background: var(--success-soft); color: var(--success); }
.stat-card:nth-child(4) .stat-icon { background: var(--warn-soft); color: var(--warn); }
.stat-card:nth-child(5) .stat-icon { background: var(--accent-soft); color: var(--accent); }
.stat-card:nth-child(6) .stat-icon { background: var(--error-soft); color: var(--error); }

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-bottom: 28px; }

/* ========== TABLES ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; padding: 14px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); font-weight: 700; background: var(--bg); border-bottom: 1px solid var(--line);
}
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: #f6f8ef; }
tbody tr:last-child td { border-bottom: none; }
.order-id { font-weight: 700; color: var(--ink); font-family: monospace; font-size: 13px; }
.cust-name { font-weight: 600; }
.cust-email { font-size: 12px; color: var(--muted); }
.amount { font-weight: 700; font-size: 14px; }

.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 100px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: #92400e; }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #eef2e6; color: var(--muted); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.row-actions { display: flex; gap: 6px; }
.row-actions a, .row-actions button {
  width: 32px; height: 32px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--ink-soft); border: 1px solid transparent; cursor: pointer; transition: all .2s;
}
.row-actions a:hover { background: var(--info-soft); color: var(--info); }
.row-actions button:hover { background: var(--error-soft); color: var(--error); }
.row-actions svg { width: 14px; height: 14px; }

.thumb-mini { width: 48px; height: 48px; border-radius: 8px; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb-mini img { width: 100%; height: 100%; object-fit: cover; }

/* ========== FORMS (BACKEND) ========== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); margin-bottom: 7px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; outline: none; transition: all .2s; background: #fff;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(228,87,46,0.1);
}
.form-group textarea { resize: vertical; min-height: 100px; font-family: inherit; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--error); margin-top: 5px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.checkbox-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.checkbox-row label { margin: 0; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 14px; color: var(--ink); cursor: pointer; }

.image-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; }
.image-pick {
  border: 2px solid var(--line); border-radius: 10px; padding: 8px; cursor: pointer; transition: all .2s; background: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.image-pick img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.image-pick span { font-size: 11px; color: var(--muted); }
.image-pick input { display: none; }
.image-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.image-pick:hover { border-color: var(--accent); }

.form-actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ========== ALERTS ========== */
.alert { padding: 14px 18px; border-radius: var(--radius); margin-bottom: 22px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.alert-success { background: var(--success-soft); color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: var(--error-soft); color: #991b1b; border: 1px solid #fecaca; }

/* ========== LOGIN FORM ELEMENTS ========== */
.form-field { margin-bottom: 18px; }
.form-field label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); margin-bottom: 7px; }
.form-field input {
  width: 100%; padding: 13px 16px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; outline: none; transition: all .2s;
}
.form-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(228,87,46,0.1); }
.btn-block { width: 100%; justify-content: center; padding: 14px 20px; font-size: 14px; }

/* ========== DETAIL VIEW ========== */
.detail-grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 28px; }
.detail-image { background: var(--bg); border-radius: var(--radius); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.detail-image img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }
.kv-list { display: grid; gap: 0; }
.kv-row { display: grid; grid-template-columns: 160px 1fr; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv-row:last-child { border: none; }
.kv-row .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; align-self: center; }
.kv-row .v { font-weight: 500; }
.order-items-table { margin-top: 20px; }

/* ========== MESSAGES ========== */
.msg-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 16px; border-bottom: 1px solid var(--line); align-items: center; transition: background .2s; cursor: pointer; }
.msg-row:hover { background: #f6f8ef; }
.msg-row.unread { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.msg-sender { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.msg-subject { font-size: 13px; color: var(--ink-soft); }
.msg-preview { font-size: 12px; color: var(--muted); margin-top: 4px; max-width: 600px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-date { font-size: 12px; color: var(--muted); text-align: right; }

.msg-thread { background: var(--bg); padding: 24px; border-radius: var(--radius); margin-top: 16px; }
.msg-thread .meta { display: flex; gap: 20px; font-size: 12px; color: var(--muted); margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.msg-thread .body { font-size: 14px; line-height: 1.8; color: var(--ink-soft); white-space: pre-wrap; }

/* ========== LOW STOCK LIST ========== */
.stock-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.stock-item:last-child { border: none; }
.stock-bar { width: 80px; height: 6px; background: var(--line); border-radius: 10px; overflow: hidden; }
.stock-bar .fill { height: 100%; background: var(--error); border-radius: 10px; }

/* ========== QUICK ACTIONS ========== */
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.quick-actions .qa-site { margin-left: auto; }

/* ========== PAGINATION ========== */
.pagination { justify-content: center; display: flex; gap: 6px; }
.pagination > * { padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: #fff; }
.pagination .active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ========== RESPONSIVE ========== */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); box-shadow: 24px 0 60px rgba(0,0,0,.35); }
  .sidebar-close {
    display: flex; align-items: center; justify-content: center;
    position: absolute; top: 18px; right: 16px; width: 34px; height: 34px;
    border-radius: 8px; border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.06); color: #cbd5e1; cursor: pointer;
  }
  .sidebar-close:hover { color: #fff; background: rgba(255,255,255,.12); }
  .sidebar-close svg { width: 18px; height: 18px; }
  .admin-scrim {
    display: block; position: fixed; inset: 0; z-index: 9;
    background: rgba(10,26,20,.5); opacity: 0; pointer-events: none;
    transition: opacity .3s;
  }
  .admin-scrim.show { opacity: 1; pointer-events: auto; }
  body.nav-locked { overflow: hidden; }
  .main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 20px; }
  .topbar { padding: 14px 20px; }
  .quick-actions { flex-direction: column; gap: 10px; }
  .quick-actions .btn { width: 100%; text-align: center; justify-content: center; }
  .quick-actions .qa-site { margin-left: 0; }
}

/* ===== Gallery upload + crop modal ===== */
.img-drop {
  display: flex; align-items: center; gap: 12px; margin-top: 10px;
  padding: 18px 20px; border: 1.5px dashed var(--line-strong); border-radius: 12px;
  cursor: pointer; color: var(--muted); font-size: 13.5px;
  transition: border-color .2s, background .2s, color .2s;
}
.img-drop:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.img-drop svg { color: var(--accent); flex-shrink: 0; }
.img-stage { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.img-stage:empty { display: none; }
.img-thumb {
  position: relative; width: 88px; height: 88px;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--line);
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border: none; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
}
.img-thumb-x:hover { background: var(--accent); }
.img-existing { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.img-old { position: relative; width: 88px; cursor: pointer; }
.img-old img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
  border-radius: 10px; border: 1px solid var(--line);
}
.img-old span { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); margin-top: 5px; }
.img-old:has(input:checked) img { opacity: .35; outline: 2px solid var(--accent); outline-offset: -2px; }

.crop-modal {
  position: fixed; inset: 0; z-index: 300; padding: 20px;
  background: rgba(10,25,18,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.crop-modal[hidden] { display: none; }
.crop-dialog {
  background: #fff; border-radius: 16px; padding: 20px;
  width: min(560px, 96vw); box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.crop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.crop-head strong { font-size: 16px; color: var(--ink); }
.crop-head span { font-size: 12px; color: var(--muted); }
.crop-view { background: #0d3b2a; border-radius: 10px; overflow: hidden; }
.crop-view canvas { display: block; width: 100%; height: auto; cursor: grab; touch-action: none; }
.crop-view canvas:active { cursor: grabbing; }
.crop-controls { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.crop-zoom { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); flex: 1; min-width: 160px; }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.crop-actions { display: flex; gap: 10px; }
