/* ============================================================
   StyleHub Admin — admin.css
   Palette: cream bg, ink, terracotta accent (SPEC §4)
   ============================================================ */
:root {
    --bg: #faf6f0;
    --surface: #ffffff;
    --ink: #221d18;
    --muted: #8a7f72;
    --accent: #c4552e;
    --accent-dark: #a03f1f;
    --gold: #b98a2f;
    --success: #2e7d4f;
    --danger: #b3331f;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(34, 29, 24, .08);
    --sidebar-w: 230px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 14px; font-family: Georgia, serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--ink);
    color: #f3ece4;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    font-family: Georgia, serif;
    font-size: 19px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-nav { padding: 12px 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    color: #d9cfc2;
    font-size: 15px;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.sidebar-nav a.active {
    background: var(--accent);
    color: #fff;
    border-radius: 0 24px 24px 0;
    margin-right: 12px;
}
.nav-icon { width: 22px; text-align: center; }

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 60;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 20px;
    padding: 8px 13px;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(34, 29, 24, .45);
    z-index: 35;
}
.sidebar-backdrop.show { display: block; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--surface);
    border-bottom: 1px solid #eee3d6;
    padding: 16px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar-user { color: var(--muted); font-size: 14px; }
.admin-content { padding: 24px 26px 60px; }

/* ---------- cards ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 22px;
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { margin-bottom: 0; }
.stat-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; font-family: Georgia, serif; }
.stat-warn .stat-value { color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left;
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 8px 10px;
    border-bottom: 2px solid #f0e7da;
}
.table th a { color: var(--muted); }
.table td { padding: 10px; border-bottom: 1px solid #f5eee4; vertical-align: middle; }
.table .num, .table th.num { text-align: right; }
.table-sm td, .table-sm th { padding: 6px 8px; }
tr.order-row:hover { background: #fdf9f3; cursor: pointer; }
.detail-box { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; padding: 10px 4px; }

.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; }
.thumb-lg { width: 90px; height: 90px; margin-top: 10px; }
.monogram {
    display: inline-flex;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-family: Georgia, serif;
    font-size: 20px;
}

/* ---------- buttons / forms ---------- */
.btn {
    display: inline-block;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid #e2d5c4;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { display: block; width: 100%; margin-top: 10px; }
.btn-big { padding: 15px 20px; font-size: 17px; border-radius: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type="text"], input[type="search"], input[type="password"], input[type="number"],
input[type="date"], input[type="tel"], input[type="file"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2d5c4;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--ink);
    margin-top: 4px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
label small { display: block; font-weight: 400; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { margin-top: 6px; display: flex; gap: 10px; }
.form-card { max-width: 860px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.search-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.search-form input[type="search"] { width: 280px; margin-top: 0; }
.search-form select, .search-form input[type="date"] { width: auto; margin-top: 0; }
.search-form label { margin-bottom: 0; font-weight: 400; }
.inline-form { display: inline; }
.actions { white-space: nowrap; }

/* ---------- badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #f0e7da;
    color: var(--ink);
}
.badge-btn { border: none; cursor: pointer; font-family: inherit; }
.badge-success { background: #e2f0e8; color: var(--success); }
.badge-danger { background: #fbe7e2; color: var(--danger); }
.badge-warn { background: #fdf1dc; color: #9a6a12; }
.badge-muted { background: #efe9e0; color: var(--muted); }
.status-placed { background: #efe9e0; color: var(--ink); }
.status-paid { background: #e2f0e8; color: var(--success); }
.status-shipped { background: #fdf1dc; color: #9a6a12; }
.status-delivered { background: #e2f0e8; color: var(--success); }
.status-cancelled { background: #fbe7e2; color: var(--danger); }
.status-select { width: auto; padding: 5px 8px; font-size: 13px; }

/* ---------- alerts ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #e2f0e8; color: var(--success); }
.alert-danger { background: #fbe7e2; color: var(--danger); }

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 34px;
    width: 100%;
    max-width: 380px;
}
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo h1 { font-family: Georgia, serif; font-size: 22px; margin-top: 8px; }
.login-note { text-align: center; margin-top: 16px; font-size: 13px; }

/* ---------- stock inline adjust ---------- */
.stock-adj { display: inline-flex; align-items: center; gap: 6px; }
.stock-val { min-width: 30px; text-align: center; font-weight: 700; }
.stock-val.flash { color: var(--success); }

/* ============================================================
   POS
   ============================================================ */
.pos-app { max-width: 1100px; }
.mode-pills { display: flex; gap: 14px; margin-bottom: 18px; }
.mode-pill {
    flex: 1;
    padding: 20px;
    font-size: 20px;
    font-weight: 700;
    border-radius: 16px;
    border: 2px solid #e2d5c4;
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
    color: var(--ink);
}
.mode-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.scan-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: 14px;
    padding: 10px 16px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.scan-icon { font-size: 24px; }
#scanInput { flex: 1; border: none; font-size: 20px; padding: 10px; margin-top: 0; background: transparent; }
#scanInput:focus { outline: none; }
.scan-hint { color: var(--muted); font-size: 13px; white-space: nowrap; }

.pos-cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 22px; align-items: start; }

.qty-selector { display: flex; gap: 8px; margin-top: 6px; }
.qty-selector button {
    min-width: 54px;
    padding: 12px 0;
    font-size: 17px;
    font-weight: 700;
    border-radius: 12px;
    border: 2px solid #e2d5c4;
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
}
.qty-selector button.active { background: var(--ink); color: #fff; border-color: var(--ink); }

.scan-feed { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.scan-feed li {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 10px;
    border-bottom: 1px solid #f5eee4;
    font-size: 15px;
}
.scan-feed li .feed-stock { font-weight: 700; color: var(--success); white-space: nowrap; }
.scan-feed li.feed-error { color: var(--danger); }
.scan-feed li .feed-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

.search-results { margin-top: 10px; max-height: 300px; overflow-y: auto; }
.search-results .sr-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #f5eee4;
    cursor: pointer;
}
.search-results .sr-item:hover { background: #fdf9f3; }

.cart-card { position: sticky; top: 84px; }
.cart-table td { padding: 8px 10px; }
.cart-qty { display: inline-flex; align-items: center; gap: 8px; }
.cart-qty button {
    width: 34px; height: 34px;
    font-size: 18px; font-weight: 700;
    border-radius: 10px;
    border: 1px solid #e2d5c4;
    background: var(--surface);
    cursor: pointer;
}
.cart-remove { border: none; background: none; color: var(--danger); font-size: 18px; cursor: pointer; }
.cart-totals { border-top: 2px solid #f0e7da; margin-top: 12px; padding-top: 12px; }
.cart-totals > div { display: flex; justify-content: space-between; padding: 4px 2px; font-size: 15px; }
.cart-totals .grand { font-size: 22px; font-weight: 700; font-family: Georgia, serif; }
.btn-charge { width: 100%; margin-top: 14px; padding: 18px; font-size: 20px; border-radius: 14px; }

/* ---------- modal ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(34, 29, 24, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 18px;
}
.modal-box {
    background: var(--surface);
    border-radius: 18px;
    padding: 26px;
    width: 100%;
    max-width: 420px;
    max-height: 92vh;
    overflow-y: auto;
    text-align: center;
}
.pay-total { font-size: 36px; font-weight: 700; font-family: Georgia, serif; color: var(--accent); margin: 8px 0 14px; }
.qr-box { display: flex; justify-content: center; margin-bottom: 12px; min-height: 200px; }
.qr-box img, .qr-box canvas { border-radius: 10px; }
.cust-row { display: flex; gap: 10px; margin-top: 14px; }
.cust-row input { margin-top: 0; }

/* ---------- receipt ---------- */
.receipt { text-align: left; font-family: ui-monospace, Consolas, monospace; }
.receipt-head { text-align: center; border-bottom: 1px dashed #d9cfc2; padding-bottom: 10px; margin-bottom: 10px; }
.receipt-lines { width: 100%; border-collapse: collapse; font-size: 13px; }
.receipt-lines td { padding: 3px 0; }
.receipt-lines .num { text-align: right; }
.receipt-totals { border-top: 1px dashed #d9cfc2; margin-top: 8px; padding-top: 8px; font-size: 14px; }
.receipt-totals > div { display: flex; justify-content: space-between; }
.receipt-totals .grand { font-weight: 700; font-size: 17px; }
.receipt-thanks { text-align: center; margin: 14px 0; }

/* ---------- toasts ---------- */
.toast-wrap {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    width: min(480px, 92vw);
}
.toast {
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: toast-in .18s ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast a { color: #fff; text-decoration: underline; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
    .grid-2, .pos-cols { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .cart-card { position: static; }
}
@media (max-width: 820px) {
    .sidebar {
        position: fixed;
        left: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar.open { transform: none; }
    .sidebar-toggle { display: block; }
    .topbar { padding-left: 64px; }
    .admin-content { padding: 16px 14px 60px; }
    .mode-pill { font-size: 16px; padding: 16px 8px; }
    .detail-box { grid-template-columns: 1fr; }
    .products-table th:nth-child(3), .products-table td:nth-child(3) { display: none; }
    .table { display: block; overflow-x: auto; }
}

@media print {
    body * { visibility: hidden; }
    #receiptBox, #receiptBox * { visibility: visible; }
    #receiptBox { position: absolute; inset: 0; box-shadow: none; }
    .no-print { display: none !important; }
}
