/* ═══════════════════════════════════════════════════════════════════════════
   BazzarKaro Delivery Partner — Base Styles
   Reset, CSS Variables, Typography, Global Utilities
   ═══════════════════════════════════════════════════════════════════════════ */

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

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
    height: 100%;
}

body {
    min-height: 100%;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    touch-action: manipulation;
}

img, svg, video {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
    border: none;
    outline: none;
    background: none;
}

button {
    cursor: pointer;
    touch-action: manipulation;
}

ul, ol {
    list-style: none;
}

table {
    border-collapse: collapse;
}

/* ─── Theme Tokens ──────────────────────────────────────────────────────── */
:root {
    /* Primary palette */
    --color-primary: #16a34a;
    --color-primary-light: #22c55e;
    --color-primary-dark: #15803d;
    --color-primary-rgb: 22, 163, 74;

    /* Secondary / Accent */
    --color-secondary: #22c55e;
    --color-accent: #ff7a00;
    --color-accent-light: #ff9a33;
    --color-accent-rgb: 255, 122, 0;

    /* Semantic */
    --color-success: #16a34a;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;

    /* Surfaces */
    --color-bg: #f5f7fa;
    --color-surface: #ffffff;
    --color-surface-elevated: #ffffff;
    --color-surface-dim: #f0f2f5;

    /* Text */
    --color-text: #111827;
    --color-text-secondary: #4b5563;
    --color-muted: #6b7280;
    --color-placeholder: #9ca3af;

    /* Borders */
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;
    --color-divider: #e5e7eb;

    /* Status colors */
    --color-online: #16a34a;
    --color-offline: #ef4444;
    --color-busy: #f59e0b;

    /* Border radius */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.10);
    --shadow-xl: 0 16px 48px rgba(0,0,0,.12);

    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Typography */
    --font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Z-index layers */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-fixed: 300;
    --z-overlay: 400;
    --z-modal: 500;
    --z-toast: 600;
    --z-tooltip: 700;

    /* Safe area insets for notched devices */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);

    /* Bottom nav height */
    --bottom-nav-height: 64px;
    --app-bar-height: 56px;
}

/* ─── Dark Theme ────────────────────────────────────────────────────────── */
[data-theme="dark"] {
    --color-bg: #0f1115;
    --color-surface: #1a1d23;
    --color-surface-elevated: #22252d;
    --color-surface-dim: #14161a;

    --color-text: #f3f4f6;
    --color-text-secondary: #d1d5db;
    --color-muted: #9ca3af;
    --color-placeholder: #6b7280;

    --color-border: #2d3139;
    --color-border-light: #22252d;
    --color-divider: #2d3139;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
    --shadow-xl: 0 16px 48px rgba(0,0,0,.5);
}

/* ─── Typography ────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-semibold);
    line-height: 1.3;
    color: var(--color-text);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-bold { font-weight: var(--font-bold); }
.text-semibold { font-weight: var(--font-semibold); }
.text-medium { font-weight: var(--font-medium); }
.text-muted { color: var(--color-muted); }
.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.text-error { color: var(--color-error); }
.text-success { color: var(--color-success); }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ─── Utility Classes ───────────────────────────────────────────────────── */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.w-full { width: 100%; }

/* ─── Animations ────────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes slideInDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

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

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes countdownRing {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: 283; }
}

.animate-fade-in { animation: fadeIn var(--duration-normal) var(--ease-out); }
.animate-fade-in-up { animation: fadeInUp var(--duration-normal) var(--ease-out); }
.animate-slide-in-up { animation: slideInUp var(--duration-slow) var(--ease-out); }
.animate-scale-in { animation: scaleIn var(--duration-normal) var(--ease-out); }
.animate-bounce-in { animation: bounceIn 0.6s var(--ease-out); }

/* ─── Focus Styles (Accessibility) ──────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* ─── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-muted);
}

/* ─── Selection ─────────────────────────────────────────────────────────── */
::selection {
    background: rgba(var(--color-primary-rgb), 0.2);
    color: var(--color-text);
}
