/* ============================================
   BASE STYLES — Cremniy Design System v2
   Reset, Design Tokens, Typography, Utilities
   ============================================ */

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

html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
    /* Colors — Dark Theme (Default) */
    --bg-primary: #09090B;
    --bg-secondary: #0F0F12;
    --bg-tertiary: #17171C;
    --bg-elevated: #1C1C22;
    --text-primary: #FAFAFA;
    --text-secondary: #A1A1AA;
    --text-muted: #71717A;
    --accent: #FAFAFA;
    --accent-hover: #D4D4D8;
    --accent-color: #6366F1;
    --accent-color-hover: #4F46E5;
    --accent-color-subtle: rgba(99, 102, 241, 0.12);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-subtle: rgba(255, 255, 255, 0.04);

    /* Light Theme values */
    --light-bg-primary: #FFFFFF;
    --light-bg-secondary: #FAFAFA;
    --light-bg-tertiary: #F4F4F5;
    --light-bg-elevated: #FFFFFF;
    --light-text-primary: #09090B;
    --light-text-secondary: #71717A;
    --light-text-muted: #A1A1AA;
    --light-accent: #09090B;
    --light-accent-hover: #27272A;
    --light-accent-color: #6366F1;
    --light-accent-color-hover: #4F46E5;
    --light-accent-color-subtle: rgba(99, 102, 241, 0.08);
    --light-border-color: rgba(0, 0, 0, 0.06);
    --light-border-hover: rgba(0, 0, 0, 0.12);
    --light-border-subtle: rgba(0, 0, 0, 0.03);

    /* Semantic Colors */
    --color-success: #22C55E;
    --color-success-subtle: rgba(34, 197, 94, 0.12);
    --color-warning: #EAB308;
    --color-warning-subtle: rgba(234, 179, 8, 0.12);
    --color-error: #EF4444;
    --color-error-subtle: rgba(239, 68, 68, 0.12);
    --color-info: #6366F1;
    --color-info-subtle: rgba(99, 102, 241, 0.12);

    /* Spacing — 4px base rhythm */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */
    --space-20: 5rem;     /* 80px */

    /* Legacy spacing aliases (for compatibility) */
    --space-xs: var(--space-2);
    --space-sm: var(--space-4);
    --space-md: var(--space-8);
    --space-lg: var(--space-6);
    --space-xl: var(--space-12);

    /* Typography Scale */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.8125rem;
    --font-size-base: 0.875rem;
    --font-size-lg: 1rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    --font-size-4xl: 2.5rem;
    --font-size-5xl: 3rem;

    /* Radius Scale */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadow Scale */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3), 0 4px 8px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.35), 0 8px 16px rgba(0, 0, 0, 0.25);

    /* Transitions */
    --transition-fast: 0.12s cubic-bezier(0.22, 1, 0.36, 1);
    --transition-base: 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    --transition-slow: 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Light Theme Override */
[data-theme="light"] {
    --bg-primary: var(--light-bg-primary);
    --bg-secondary: var(--light-bg-secondary);
    --bg-tertiary: var(--light-bg-tertiary);
    --bg-elevated: var(--light-bg-elevated);
    --text-primary: var(--light-text-primary);
    --text-secondary: var(--light-text-secondary);
    --text-muted: var(--light-text-muted);
    --accent: var(--light-accent);
    --accent-hover: var(--light-accent-hover);
    --accent-color: var(--light-accent-color);
    --accent-color-hover: var(--light-accent-color-hover);
    --accent-color-subtle: var(--light-accent-color-subtle);
    --border-color: var(--light-border-color);
    --border-hover: var(--light-border-hover);
    --border-subtle: var(--light-border-subtle);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.06);
}

/* ============================================
   BASE STYLES
   ============================================ */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.55;
    font-size: var(--font-size-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color var(--transition-base), color var(--transition-base);
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-6);
    overflow-x: hidden;
    width: 100%;
}

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

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

button {
    font-family: inherit;
}

/* ============================================
   UTILITIES
   ============================================ */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-20) 0;
    gap: var(--space-4);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.spin {
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.loading-spinner p {
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.no-products {
    text-align: center;
    padding: var(--space-20) 0;
    color: var(--text-secondary);
}

.no-products i {
    font-size: var(--font-size-3xl);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
    display: block;
}

.no-products h3 {
    font-size: var(--font-size-xl);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.no-products p {
    font-size: var(--font-size-base);
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* ============================================
   NOTIFICATION TOAST (non-blocking)
   ============================================ */
.notification-gate {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.notification-gate.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.notification-gate.notification-gate--fallback {
    align-items: flex-end;
    justify-content: flex-end;
    background: transparent;
    padding: var(--space-4);
    pointer-events: none;
}
.notification-gate__content {
    text-align: center;
    max-width: 380px;
    padding: var(--space-10);
    background: transparent;
}
.notification-gate__icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-6);
    background: var(--accent-color-subtle);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.25rem;
    color: var(--accent-color);
}
.notification-gate__title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    letter-spacing: -0.02em;
}
.notification-gate__text {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-8);
}
.notification-gate__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    background: var(--accent-color);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: var(--font-size-base);
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.notification-gate__btn:hover {
    background: var(--accent-color-hover);
}
.notification-gate__btn:active {
    transform: scale(0.98);
}
.notification-gate__hint {
    margin-top: var(--space-4);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    min-height: 20px;
}
.notification-gate__hint.error {
    color: var(--color-error);
}
.notification-gate--fallback .notification-gate__content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--space-6);
    width: min(400px, 100%);
    pointer-events: auto;
}
.notification-gate--fallback .notification-gate__icon {
    display: none;
}
.notification-gate--fallback .notification-gate__title {
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-2);
}
.notification-gate--fallback .notification-gate__text {
    margin-bottom: var(--space-4);
}
.notification-gate--fallback .notification-gate__btn {
    width: 100%;
    justify-content: center;
}

/* ============================================
   TOAST NOTIFICATIONS (JS uses these classes)
   ============================================ */
.notification {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 100000;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    max-width: 360px;
}
.notification-success { border-left: 3px solid var(--color-success); }
.notification-error { border-left: 3px solid var(--color-error); }
.notification-warning { border-left: 3px solid var(--color-warning); }
.notification-info { border-left: 3px solid var(--color-info); }

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