/* ══════════════════════════════════════════════════════════════
   AmbouStock — Design System
   Apple / Notion / Slack inspired — clean, minimal, premium
   ══════════════════════════════════════════════════════════════ */

:root {
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    /* Colors */
    --white: #ffffff;
    --bg: #f5f5f7;
    --bg-sidebar: #fafafa;
    --border: #e8e8e8;
    --border-strong: #d0d0d0;

    --text-1: #111111;
    --text-2: #555555;
    --text-3: #999999;

    --accent: #0a84ff;
    --accent-bg: #e8f1ff;

    --low-stock-color: #e05c2a;
    --low-stock-bg: #fff4f0;

    --green: #34c759;
    --red: #ff3b30;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 6px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.1);

    /* Sidebar */
    --sidebar-w: 270px;
}

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

html, body { height: 100%; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-1);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input { font-family: inherit; }
ul, ol { list-style: none; }

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════════ */

.login-body {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 380px;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.login-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-align: center;
    color: var(--text-1);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-3);
    text-align: center;
    margin-bottom: 28px;
}

.login-error {
    background: #fff0ee;
    border: 1px solid #ffd5cc;
    color: #c0392b;
    border-radius: var(--radius-sm);
    font-size: 13px;
    padding: 10px 14px;
    margin-bottom: 20px;
}

/* Fields */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.field input {
    display: block;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-1);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10,132,255,0.12);
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 18px;
    background: var(--text-1);
    color: var(--white);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: opacity 0.15s, transform 0.1s;
    cursor: pointer;
    border: none;
    letter-spacing: -0.01em;
}

.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { transform: scale(0.98); }
.btn-full { width: 100%; margin-top: 8px; }

/* ══════════════════════════════════════════════════════════════
   DASHBOARD LAYOUT
   ══════════════════════════════════════════════════════════════ */

.dashboard-body {
    background: var(--bg);
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
#sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
}

.brand-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-1);
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
    background: var(--border);
    color: var(--text-1);
}

.icon-btn.spinning svg {
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Search */
.search-wrap {
    position: relative;
    padding: 12px 16px 8px;
}

.search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}

#search {
    width: 100%;
    height: 34px;
    padding: 0 10px 0 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-1);
    background: var(--white);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

#search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(10,132,255,0.1);
}

/* Product count label */
.sidebar-count {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 0 16px 6px;
}

/* Product list */
#product-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 8px;
}

#product-list::-webkit-scrollbar { width: 4px; }
#product-list::-webkit-scrollbar-track { background: transparent; }
#product-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

/* Skeleton loading items */
.list-skeleton {
    height: 40px;
    margin: 2px 0;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, #ebebeb 25%, #f5f5f5 50%, #ebebeb 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}

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

/* Product list items */
.product-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
    -webkit-user-select: none;
}

.product-item:hover {
    background: rgba(0,0,0,0.04);
}

.product-item.selected {
    background: var(--accent-bg);
}

.product-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.product-thumb {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--border);
    border: 1px solid var(--border);
}

.product-thumb-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    flex-shrink: 0;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
}

.product-name {
    flex: 1;
    font-size: 13px;
    font-weight: 400;
    color: var(--text-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-item.selected .product-name {
    font-weight: 500;
    color: var(--accent);
}

/* No results */
.no-results {
    padding: 20px 8px;
    font-size: 13px;
    color: var(--text-3);
    text-align: center;
}

/* Sidebar footer */
#sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.footer-user {
    color: var(--text-2);
    display: flex;
    align-items: center;
}

.footer-logout {
    color: var(--text-3);
    font-size: 12px;
    transition: color 0.15s;
}

.footer-logout:hover { color: var(--red); }

/* ── Main ──────────────────────────────────────────────────── */
#main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

#main::-webkit-scrollbar { width: 6px; }
#main::-webkit-scrollbar-track { background: transparent; }
#main::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* Error banner */
.error-banner {
    background: #fff0ee;
    border: 1px solid #ffd5cc;
    color: #c0392b;
    border-radius: var(--radius-sm);
    font-size: 13px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.hidden { display: none !important; }

/* Empty state */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 60px 24px;
    text-align: center;
}

.empty-icon {
    margin-bottom: 8px;
    opacity: 0.5;
}

.empty-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-2);
}

.empty-sub {
    font-size: 13px;
    color: var(--text-3);
    max-width: 280px;
}

/* Cards container */
#cards-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Inventory Card ────────────────────────────────────────── */
.inv-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.card-product-img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.card-product-placeholder {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
}

.card-product-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-1);
}

.card-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.card-close:hover {
    background: #fff0ee;
    color: var(--red);
}

/* Color filter section */
.card-colors {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.colors-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    flex-shrink: 0;
}

.color-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.color-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    border: 1.5px solid var(--border-strong);
    background: var(--white);
    color: var(--text-2);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    white-space: nowrap;
}

.color-pill:hover {
    border-color: var(--text-2);
}

.color-pill.active {
    border-color: var(--accent);
    background: var(--accent-bg);
    color: var(--accent);
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.12);
    flex-shrink: 0;
}

/* Table */
.card-table-wrap {
    overflow-x: auto;
    padding: 0 16px 16px;
    -webkit-overflow-scrolling: touch;
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.inv-table th {
    padding: 12px 10px 8px;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.inv-table th:first-child {
    text-align: left;
    padding-left: 0;
}

.inv-table td {
    padding: 9px 10px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--text-1);
    border-bottom: 1px solid rgba(0,0,0,0.04);
    white-space: nowrap;
}

.inv-table td:first-child {
    text-align: left;
    padding-left: 0;
}

.inv-table tbody tr:last-child td {
    border-bottom: none;
}

.inv-table tbody tr:hover td {
    background: rgba(0,0,0,0.015);
}

/* Color label cell */
.color-cell {
    display: flex;
    align-items: center;
    gap: 7px;
}

.color-cell-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.12);
    flex-shrink: 0;
}

.color-cell-name {
    font-weight: 500;
    color: var(--text-2);
}

/* Traffic light indicators (guest mode) */
.traffic-light-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
}

.tl-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tl-green  { background: #34c759; box-shadow: 0 0 0 3px rgba(52,199,89,0.18); }
.tl-orange { background: #ff9500; box-shadow: 0 0 0 3px rgba(255,149,0,0.18); }
.tl-red    { background: #ff3b30; box-shadow: 0 0 0 3px rgba(255,59,48,0.18); }
.tl-grey   { background: #c7c7cc; box-shadow: 0 0 0 3px rgba(199,199,204,0.18); }

/* Quantity cell states */
.qty-empty {
    color: var(--border-strong);
    font-size: 12px;
}

.qty-low {
    color: var(--low-stock-color);
    font-weight: 600;
}

.qty-ok {
    color: var(--text-1);
}

/* All colors selected toggle */
.select-all-btn {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    flex-shrink: 0;
    margin-left: auto;
}

.select-all-btn:hover {
    background: var(--accent-bg);
}

/* ══════════════════════════════════════════════════════════════
   MOBILE — ≤ 768px
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    :root {
        --sidebar-w: 100%;
    }

    .dashboard-body {
        overflow: auto;
    }

    #app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    #sidebar {
        width: 100%;
        height: auto;
        max-height: 55vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
    }

    #product-list {
        max-height: calc(55vh - 130px);
    }

    #main {
        flex: none;
        overflow: visible;
        padding: 16px;
    }

    .card-header {
        padding: 12px 14px;
    }

    .card-colors {
        padding: 10px 14px;
    }

    .card-table-wrap {
        padding: 0 14px 14px;
    }

    .inv-table th,
    .inv-table td {
        padding: 8px 8px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 28px 20px 24px;
    }
}
