/* ============================================================
   SalesGrid — Design System & Custom Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --brand-50: #f0fdf4;
    --brand-100: #dcfce7;
    --brand-500: #22c55e;
    --brand-600: #16a34a;
    --brand-700: #15803d;
    --brand-800: #166534;
    --brand-900: #14532d;

    --accent-400: #fb923c;
    --accent-500: #f97316;
    --accent-600: #ea580c;

    --danger-500: #ef4444;
    --danger-600: #dc2626;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
}

/* ─── Mobile-first: safe area insets for notched phones ──── */
@supports (padding: env(safe-area-inset-top)) {
    body { padding-top: env(safe-area-inset-top); }
    .pb-safe { padding-bottom: env(safe-area-inset-bottom); }
    .bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
}

/* ─── Bottom navigation bar ─────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    z-index: 50;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.75rem;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.625rem;
    font-weight: 600;
    transition: all 0.15s ease;
    min-width: 3.5rem;
}

.bottom-nav a.active {
    color: var(--brand-600);
    background: var(--brand-50);
}

.bottom-nav a:active {
    transform: scale(0.92);
}

.bottom-nav svg {
    width: 1.5rem;
    height: 1.5rem;
}

/* ─── Main content area with bottom nav offset ──────────── */
.main-content {
    padding-bottom: 5rem;
    min-height: 100dvh;
}

/* ─── Touch targets: minimum 48px ───────────────────────── */
.touch-target {
    min-width: 48px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ─── Large action buttons ──────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background: var(--brand-600);
    color: white;
    font-weight: 700;
    font-size: 1.125rem;
    border-radius: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 56px;
    width: 100%;
    box-shadow: 0 4px 6px -1px rgba(22, 163, 74, 0.3);
}

.btn-primary:active {
    transform: scale(0.97);
    background: var(--brand-700);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: white;
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.9375rem;
    border-radius: 0.75rem;
    border: 1.5px solid var(--gray-200);
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 48px;
}

.btn-secondary:active {
    transform: scale(0.97);
    background: var(--gray-50);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--danger-500);
    color: white;
    font-weight: 600;
    font-size: 0.9375rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 48px;
}

.btn-danger:active {
    transform: scale(0.97);
    background: var(--danger-600);
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
    background: white;
    border-radius: 1rem;
    border: 1px solid var(--gray-200);
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* ─── Form inputs ───────────────────────────────────────── */
.form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1.5px solid var(--gray-300);
    border-radius: 0.75rem;
    font-size: 1rem;
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-height: 48px;
}

.form-input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.form-input::placeholder {
    color: var(--gray-400);
}

/* ─── Numeric keypad style input ────────────────────────── */
.numeric-input {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.1em;
    min-height: 64px;
    padding: 1rem;
}

/* ─── Stat cards (dashboard) ────────────────────────────── */
.stat-card {
    background: white;
    border-radius: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    min-width: 0;
    overflow: hidden;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.15;
    color: var(--gray-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ─── Product list item ─────────────────────────────────── */
.product-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    transition: background 0.15s;
    cursor: pointer;
    min-height: 64px;
}

.product-item:active {
    background: var(--gray-50);
}

.product-thumb {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    object-fit: cover;
    background: var(--gray-100);
    flex-shrink: 0;
}

/* ─── Badge / pill ──────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-green { background: var(--brand-100); color: var(--brand-700); }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-blue { background: #dbeafe; color: #2563eb; }

/* ─── Low stock warning ─────────────────────────────────── */
.low-stock {
    border-left: 4px solid var(--accent-500);
    background: #fff7ed;
}

.out-of-stock {
    border-left: 4px solid var(--danger-500);
    background: #fef2f2;
}

/* ─── Floating action button ────────────────────────────── */
.fab {
    position: fixed;
    bottom: 5rem;
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 9999px;
    background: var(--brand-600);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 40;
}

.fab:active {
    transform: scale(0.9);
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

/* ─── Toast notification ────────────────────────────────── */
.toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    z-index: 100;
    transition: transform 0.3s ease;
    max-width: 90vw;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast-success { background: var(--brand-600); color: white; }
.toast-error { background: var(--danger-500); color: white; }
.toast-warning { background: var(--accent-500); color: white; }

/* ─── Page transitions ──────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-enter {
    animation: fadeIn 0.2s ease-out;
}

/* ─── Empty state ───────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state svg {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    color: var(--gray-300);
}

/* ─── Scrollbar hide (for horizontal scroll) ────────────── */
.scroll-hide::-webkit-scrollbar { display: none; }
.scroll-hide { -ms-overflow-style: none; scrollbar-width: none; scroll-padding-left: 0.5rem; }

/* Scroll hint: fade gradient on the right edge */
.scroll-hint {
    position: relative;
}
.scroll-hint::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0; right: 0;
    width: 2rem;
    background: linear-gradient(to right, transparent, white);
    pointer-events: none;
    z-index: 2;
    border-radius: 0 1rem 1rem 0;
}

/* ─── Loading spinner ───────────────────────────────────── */
.spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--gray-200);
    border-top-color: var(--brand-600);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ─── Subscription expired overlay ──────────────────────── */
.expired-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.5rem;
}
