/* ============================================================
   DebElectricals — Design System
   Mobile-first  |  Inter font  |  Ghana Cedi (₵)
   ============================================================ */

:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-light: #dbeafe;
    --success:       #10b981;
    --success-light: #d1fae5;
    --warning:       #f59e0b;
    --warning-light: #fef3c7;
    --danger:        #ef4444;
    --danger-light:  #fee2e2;
    --bg:            #f3f4f6;
    --card:          #ffffff;
    --text:          #111827;
    --muted:         #6b7280;
    --border:        #e5e7eb;
    --grey-50:       #f9fafb;
    --grey-100:      #f3f4f6;
    --grey-200:      #e5e7eb;
    --grey-300:      #d1d5db;
    --grey-400:      #9ca3af;
    --white:         #ffffff;
    --radius:        8px;
    --radius-lg:     12px;
    --shadow:        0 1px 3px rgba(0,0,0,.06);
    --shadow-md:     0 4px 8px rgba(0,0,0,.08);
    --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100dvh;
}

img { max-width: 100%; display: block; }
svg { flex-shrink: 0; display: inline-block; vertical-align: middle; }
a   { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.375rem; font-weight: 700; }
h2 { font-size: 1rem; font-weight: 700; }

/* ==============================================================
   LAYOUT
   ============================================================== */
.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Main content area — clears sticky header, stays above FAB + bottom nav */
.page-content {
    padding-top: 16px;
    padding-bottom: 140px; /* 60px nav + 44px FAB + 24px gap + 12px breathing */
}

/* ==============================================================
   TOP BAR — white, subtle bottom border
   ============================================================== */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--border);
}
.top-bar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
}
.top-bar-left,
.top-bar-right {
    width: 40px;
    display: flex;
    align-items: center;
}
.top-bar-right { justify-content: flex-end; }

.top-bar-title {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--text);
}
.top-bar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.top-bar-btn:active { background: var(--grey-100); }

.notif-badge { position: relative; }
.notif-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--white);
}

/* ==============================================================
   GREETING — on body bg, not in a card
   ============================================================== */
.greeting {
    padding: 20px 0 12px;
}
.greeting h1 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}
.greeting .shop-name {
    font-size: 0.875rem;
    color: var(--muted);
    margin-top: 2px;
}

/* ==============================================================
   SEARCH BAR — white pill with magnifier + filter icon
   ============================================================== */
.search-bar {
    position: relative;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
}
.search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-400);
    display: flex;
    pointer-events: none;
}
.search-bar .filter-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--grey-400);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}
.search-bar .filter-btn:active { background: var(--grey-100); }
.search-bar input {
    width: 100%;
    padding: 11px 44px 11px 40px;
    font-family: var(--font);
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--white);
    color: var(--text);
    transition: border-color .15s;
}
.search-bar input::placeholder { color: var(--grey-400); }
.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ==============================================================
   STAT CARDS — 2x2 grid
   Layout per card: icon badge → muted label → big bold number
   ============================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
}
.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.stat-icon.blue    { background: var(--primary-light); color: var(--primary); }
.stat-icon.orange  { background: var(--warning-light); color: var(--warning); }
.stat-icon.green   { background: var(--success-light); color: var(--success); }
.stat-icon.blue-alt { background: var(--primary-light); color: var(--primary); }

.stat-label {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 2px;
    line-height: 1.3;
}
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.stat-value.sm {
    font-size: 1.25rem;
}

/* ==============================================================
   SECTION HEADER — "Low Stock Overview" + "View all"
   ============================================================== */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.section-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.section-header a {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
}

/* ==============================================================
   LOW STOCK LIST — square thumbnails, white card wrapper
   ============================================================== */
.low-stock-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.low-stock-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.low-stock-item:last-child { border-bottom: none; }

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

.low-stock-info { flex: 1; min-width: 0; }
.low-stock-info .name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.low-stock-info .category {
    font-size: 0.75rem;
    color: var(--muted);
}

.low-stock-qty {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--danger);
    white-space: nowrap;
}

/* ==============================================================
   CARDS (generic)
   ============================================================== */
.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
}

/* ==============================================================
   BOTTOM NAV — 60px, white, top border, 4 equal tabs
   ============================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 60px;
    background: var(--white);
    border-top: 1px solid var(--border);
    display: flex;
    max-width: 480px;
    margin: 0 auto;
}
@media (min-width: 481px) {
    .bottom-nav {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--grey-400);
    text-decoration: none;
    transition: color .15s;
    padding-top: 2px;
}
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a.active { color: var(--primary); }

/* ==============================================================
   QUICK SALE FAB — small blue pill, constrained
   ============================================================== */
.fab-quick-sale {
    position: fixed;
    bottom: 76px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    max-width: 160px;
    height: 44px;
    max-height: 44px;
    padding: 0 22px;
    background: var(--primary);
    color: var(--white);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    border: none;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(37,99,235,.3);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    transition: background .15s;
}
.fab-quick-sale:hover { background: var(--primary-dark); text-decoration: none; }
.fab-quick-sale:active { transform: translateX(-50%) scale(0.97); }

/* ==============================================================
   SIDE MENU
   ============================================================== */
.side-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}
.side-menu-backdrop.open { opacity: 1; pointer-events: auto; }

.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 201;
    width: 280px;
    max-width: 80vw;
    background: var(--white);
    transform: translateX(-100%);
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.side-menu.open { transform: translateX(0); }

.side-menu-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
}
.side-menu-header .shop {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
}
.side-menu-header .user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-top: 6px;
}
.side-menu-header .user-email {
    font-size: 0.75rem;
    color: var(--muted);
}

.side-menu-nav { padding: 8px 0; flex: 1; }
.side-menu-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    transition: background .1s;
}
.side-menu-nav a:hover { background: var(--grey-50); text-decoration: none; }
.side-menu-nav a.active { color: var(--primary); background: var(--primary-light); }
.side-menu-nav .divider { height: 1px; background: var(--border); margin: 6px 0; }
.side-menu-nav a.sign-out { color: var(--danger); }

/* ==============================================================
   BUTTONS
   ============================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s, transform .1s;
    width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--grey-300);
    color: #374151;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

/* ==============================================================
   FORMS
   ============================================================== */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 4px;
}
.form-control {
    width: 100%;
    padding: 10px 12px;
    font-family: var(--font);
    font-size: 0.9375rem;
    border: 1.5px solid var(--grey-300);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    transition: border-color .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* ==============================================================
   ALERTS
   ============================================================== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.alert-danger  { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--success-light); color: #065f46; }
.alert-warning { background: var(--warning-light); color: #92400e; }

/* ==============================================================
   AUTH PAGES (login, setup)
   ============================================================== */
.auth-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 24px 16px;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card .logo { text-align: center; margin-bottom: 24px; }
.auth-card .logo h1 { color: var(--primary); font-size: 1.5rem; }
.auth-card .logo p { color: var(--muted); font-size: 0.8125rem; margin-top: 4px; }

/* ==============================================================
   PLACEHOLDER PAGES
   ============================================================== */
.placeholder-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 1rem;
}
.placeholder-page svg { color: var(--grey-300); margin-bottom: 1rem; }
.placeholder-page h2 { color: var(--text); margin-bottom: 4px; }
.placeholder-page p { color: var(--muted); font-size: 0.875rem; }

/* ==============================================================
   PRODUCTS PAGE
   ============================================================== */

/* Toolbar: search + add button */
.products-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 16px;
    margin-bottom: 12px;
}
.add-product-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: var(--white);
    text-decoration: none;
}
.add-product-btn:hover { background: var(--primary-dark); text-decoration: none; }

/* Filter panel */
.filter-panel {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 12px;
}
.filter-section { margin-bottom: 10px; }
.filter-section:last-child { margin-bottom: 0; }
.filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
    display: block;
}
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chip {
    display: inline-block;
    padding: 5px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--white);
    text-decoration: none;
    transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.chip.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

/* Product count */
.product-count {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 10px;
}

/* Product list card */
.product-list-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 16px;
}
.product-row {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.product-row:last-child { border-bottom: none; }

.product-row-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.product-thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    background: var(--grey-100);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info { flex: 1; min-width: 0; }
.product-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-qty {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 2px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}
.badge-success {
    background: var(--success-light);
    color: var(--success);
}
.badge-warning {
    background: var(--warning-light);
    color: #b45309;
}

/* Add/Remove stock buttons */
.product-row-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.btn-stock {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 0;
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s;
    border: 1.5px solid;
    background: transparent;
}
.btn-stock-add {
    color: var(--success);
    border-color: var(--success);
}
.btn-stock-add:hover { background: var(--success-light); }
.btn-stock-remove {
    color: var(--danger);
    border-color: var(--danger);
}
.btn-stock-remove:hover { background: var(--danger-light); }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}
.pagination-btn {
    padding: 8px 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    background: var(--white);
}
.pagination-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-info {
    font-size: 0.8125rem;
    color: var(--muted);
}

/* ==============================================================
   PRODUCT ROW LINK (tappable)
   ============================================================== */
.product-row-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.product-row-link:hover { text-decoration: none; }

/* ==============================================================
   PRODUCT FORM (add / edit)
   ============================================================== */
.product-form {
    padding-top: 16px;
}

/* Image upload card */
.image-upload-card {
    position: relative;
    width: 100%;
    min-height: 180px;
    border-radius: var(--radius-lg);
    background: var(--primary-light);
    margin-bottom: 20px;
    cursor: pointer;
    overflow: hidden;
}
.image-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 180px;
    color: var(--primary);
}
.upload-title {
    font-size: 0.9375rem;
    font-weight: 600;
}
.upload-subtitle {
    font-size: 0.8125rem;
    opacity: 0.7;
}

.image-upload-preview {
    position: relative;
    width: 100%;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--grey-100);
}
.image-upload-preview img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius-lg);
}
.preview-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,.6);
    color: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preview-remove:hover { background: rgba(0,0,0,.8); }

/* Two-column form row */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Select styling */
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Helper text under field */
.form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 4px;
}

/* Large button variant */
.btn-lg {
    padding: 14px 20px;
    font-size: 0.9375rem;
    margin-top: 8px;
}

/* Delete button */
.delete-form {
    margin-top: 12px;
    margin-bottom: 24px;
}
.btn-outline-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 600;
    border: 1.5px solid var(--danger);
    border-radius: var(--radius);
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    transition: background .15s;
}
.btn-outline-danger:hover { background: var(--danger-light); }

/* ==============================================================
   MODAL
   ============================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 380px;
    transform: translateY(20px);
    transition: transform .2s;
}
.modal-backdrop.open .modal { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 0;
}
.modal-header h2 {
    font-size: 1.0625rem;
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--muted);
    display: flex;
    border-radius: var(--radius);
}
.modal-close:hover { background: var(--grey-100); }

.modal-body { padding: 12px 16px 0; }
.modal-subtitle {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.modal-current {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-bottom: 12px;
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px 16px;
}

/* Success button for modal */
.btn-success {
    background: var(--success);
    color: var(--white);
}
.btn-success:hover { background: #059669; }

/* ==============================================================
   TOAST
   ============================================================== */
.toast {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    z-index: 400;
    background: var(--text);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s, transform .3s;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==============================================================
   QUICK SALE
   ============================================================== */
.qs-container { position: relative; padding-top: 12px; }

/* State transitions */
.qs-state {
    display: none;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease;
}
.qs-state.qs-active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Search bar (reuse search-bar pattern) */
.qs-search-bar {
    position: relative;
    margin-bottom: 16px;
}
.qs-search-bar .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--grey-400);
    display: flex;
    pointer-events: none;
}
.qs-search-bar input {
    width: 100%;
    padding: 11px 12px 11px 40px;
    font-family: var(--font);
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--white);
    color: var(--text);
}
.qs-search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.qs-section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 8px;
}

/* Product rows in search */
.qs-product-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: var(--white);
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-align: left;
    font-family: var(--font);
    transition: background .1s;
}
.qs-product-row:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.qs-product-row:last-child  { border-radius: 0 0 var(--radius-lg) var(--radius-lg); border-bottom: none; }
.qs-product-row:only-child  { border-radius: var(--radius-lg); }
.qs-product-row:active { background: var(--grey-50); }

.qs-row-thumb {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    background: var(--grey-100);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.qs-row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.qs-row-info { flex: 1; min-width: 0; }
.qs-row-name { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.qs-row-stock { font-size: 0.75rem; color: var(--muted); }

/* Recent sales in search state */
.qs-sale-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.qs-sale-row:last-child { border-bottom: none; }
.qs-sale-thumb {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    background: var(--grey-100);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.qs-sale-thumb img { width: 100%; height: 100%; object-fit: cover; }
.qs-sale-info { flex: 1; min-width: 0; }
.qs-sale-name { font-size: 0.8125rem; font-weight: 600; color: var(--text); }
.qs-sale-time { font-size: 0.6875rem; color: var(--muted); }
.qs-sale-qty { font-size: 0.8125rem; font-weight: 600; color: var(--danger); white-space: nowrap; }

.qs-view-all {
    display: block;
    text-align: center;
    padding: 14px 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
}

/* STATE 2: Product detail */
.qs-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 0;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 12px;
}
.qs-back:hover { color: var(--text); }

.qs-product-detail {
    text-align: center;
    margin-bottom: 24px;
}
.qs-product-img {
    width: 120px; height: 120px;
    border-radius: var(--radius-lg);
    background: var(--grey-100);
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.qs-product-img img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-lg); }

.qs-detail-stock {
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 4px;
}
.qs-detail-stock.ok { color: var(--success); }
.qs-detail-stock.danger { color: var(--danger); }

/* Quantity selector */
.qs-qty-section {
    margin-bottom: 20px;
}
.qs-qty-label {
    display: block;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 10px;
}
.qs-qty-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.qs-qty-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    transition: border-color .15s, background .15s;
}
.qs-qty-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); }
.qs-qty-btn:disabled { opacity: .35; cursor: not-allowed; }

.qs-qty-input {
    width: 72px;
    height: 56px;
    text-align: center;
    font-family: var(--font);
    font-size: 1.75rem;
    font-weight: 700;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    background: var(--white);
    -moz-appearance: textfield;
}
.qs-qty-input::-webkit-inner-spin-button,
.qs-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qs-qty-input:focus { outline: none; border-color: var(--primary); }

.qs-qty-warning {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--warning);
    margin-top: 6px;
}

/* STATE 3: Success */
.qs-success-content {
    text-align: center;
    padding: 3rem 0 2rem;
}
.qs-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--success-light);
    color: var(--success);
    margin-bottom: 16px;
    animation: qs-pop .35s ease;
}
@keyframes qs-pop {
    0%   { transform: scale(0.5); opacity: 0; }
    70%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
.qs-success-content h2 {
    font-size: 1.25rem;
    margin-bottom: 4px;
}
.qs-success-detail {
    font-size: 0.9375rem;
    color: var(--text);
    font-weight: 500;
}
.qs-success-newstock {
    font-size: 0.8125rem;
    color: var(--muted);
    margin-top: 4px;
}

.qs-close-link {
    display: block;
    text-align: center;
    margin-top: 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
}

/* ==============================================================
   SALES HISTORY
   ============================================================== */
.sh-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.sh-summary-label {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 500;
}
.sh-summary-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
}

.sh-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 14px 0 12px;
    flex-wrap: wrap;
}
.sh-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--white);
    text-decoration: none;
    white-space: nowrap;
}
.sh-export-btn:hover { background: var(--primary-dark); text-decoration: none; }

.sh-date-header {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--muted);
    margin: 16px 0 6px;
}

.sh-day-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 8px;
}

.sh-sale-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.sh-sale-row:last-of-type { border-bottom: none; }

.sh-sale-thumb {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    background: var(--grey-100);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.sh-sale-thumb img { width: 100%; height: 100%; object-fit: cover; }

.sh-sale-info { flex: 1; min-width: 0; }
.sh-sale-name { font-size: 0.8125rem; font-weight: 600; color: var(--text); }
.sh-sale-meta { font-size: 0.6875rem; color: var(--muted); }

.sh-sale-right { text-align: right; flex-shrink: 0; }
.sh-sale-qty { font-size: 0.8125rem; font-weight: 600; color: var(--danger); }
.sh-sale-amount { font-size: 0.75rem; color: var(--muted); }

.sh-day-total {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--grey-50);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text);
    border-top: 1px solid var(--border);
}

/* ==============================================================
   UTILITIES
   ============================================================== */
.text-center { text-align: center; }
.text-muted  { color: var(--muted); }
.text-sm     { font-size: 0.8125rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }

@media (min-width: 481px) {
    .container { max-width: 480px; }
}
