/* 
 * DaydreamWithSunshine Store CSS Library
 * Comprehensive styling system for all store pages
 * Version: 2.0
 */

/* ============================================
   CSS VARIABLES & DESIGN TOKENS
   ============================================ */
:root {
    /* Brand Colors */
    --primary-purple: #8B5CF6;
    --primary-purple-dark: #7C3AED;
    --primary-purple-light: #A78BFA;
    --secondary-pink: #EC4899;
    --secondary-pink-dark: #DB2777;
    --accent-yellow: #F59E0B;
    --accent-teal: #14B8A6;
    
    /* Semantic Colors */
    --success-green: #10B981;
    --success-green-light: #34D399;
    --warning-orange: #F59E0B;
    --error-red: #EF4444;
    --error-red-light: #F87171;
    --info-blue: #3B82F6;
    
    /* Neutral Palette */
    --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;
    
    /* Backgrounds */
    --bg-primary: #FFFFFF;
    --bg-secondary: var(--gray-50);
    --bg-tertiary: var(--gray-100);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--primary-purple), var(--secondary-pink));
    --gradient-secondary: linear-gradient(135deg, var(--accent-teal), var(--info-blue));
    --gradient-subtle: linear-gradient(135deg, var(--gray-50), var(--gray-100));
    --gradient-overlay: linear-gradient(180deg, rgba(0,0,0,0.1), rgba(0,0,0,0.3));
    
    /* Typography Scale */
    --font-xs: 0.75rem;     /* 12px */
    --font-sm: 0.875rem;    /* 14px */
    --font-base: 1rem;      /* 16px */
    --font-lg: 1.125rem;    /* 18px */
    --font-xl: 1.25rem;     /* 20px */
    --font-2xl: 1.5rem;     /* 24px */
    --font-3xl: 1.875rem;   /* 30px */
    --font-4xl: 2.25rem;    /* 36px */
    --font-5xl: 3rem;       /* 48px */
    
    /* Line Heights */
    --leading-none: 1;
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    --leading-loose: 2;
    
    /* Letter Spacing */
    --tracking-tighter: -0.05em;
    --tracking-tight: -0.025em;
    --tracking-normal: 0;
    --tracking-wide: 0.025em;
    --tracking-wider: 0.05em;
    --tracking-widest: 0.1em;
    
    /* Spacing Scale */
    --space-0: 0;
    --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 */
    
    /* Border Radius */
    --radius-none: 0;
    --radius-sm: 0.125rem;  /* 2px */
    --radius-base: 0.25rem; /* 4px */
    --radius-md: 0.375rem;  /* 6px */
    --radius-lg: 0.5rem;    /* 8px */
    --radius-xl: 0.75rem;   /* 12px */
    --radius-2xl: 1rem;     /* 16px */
    --radius-3xl: 1.5rem;   /* 24px */
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-xs: 0 0 0 1px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-base: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    --transition-slower: 500ms ease;
    
    /* Z-Index Scale */
    --z-0: 0;
    --z-10: 10;
    --z-20: 20;
    --z-30: 30;
    --z-40: 40;
    --z-50: 50;
    --z-modal: 100;
    --z-overlay: 200;
    --z-toast: 300;
    --z-tooltip: 400;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: var(--font-base);
    line-height: var(--leading-normal);
    color: var(--gray-900);
    background: var(--bg-secondary);
    min-height: 100vh;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    color: var(--gray-900);
}

h1 { font-size: var(--font-5xl); }
h2 { font-size: var(--font-4xl); }
h3 { font-size: var(--font-3xl); }
h4 { font-size: var(--font-2xl); }
h5 { font-size: var(--font-xl); }
h6 { font-size: var(--font-lg); }

p {
    margin-bottom: var(--space-4);
    line-height: var(--leading-relaxed);
}

a {
    color: var(--primary-purple);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--primary-purple-dark);
}

/* ============================================
   LAYOUT CONTAINERS
   ============================================ */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.container-sm { max-width: 640px; }
.container-md { max-width: 768px; }
.container-lg { max-width: 1024px; }
.container-xl { max-width: 1280px; }
.container-2xl { max-width: 1536px; }

/* ============================================
   HEADER STYLES
   ============================================ */
.store-header {
    background: var(--gradient-primary);
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: var(--z-40);
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    gap: var(--space-4);
    flex-wrap: wrap;
}

.store-logo {
    font-size: var(--font-2xl);
    font-weight: 800;
    color: white;
    text-decoration: none;
    letter-spacing: var(--tracking-tight);
    transition: transform var(--transition-base);
}

.store-logo:hover {
    transform: scale(1.05);
    color: white;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* ============================================
   BUTTON SYSTEM
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-base);
    font-weight: 600;
    line-height: 1;
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--primary-purple);
    color: var(--primary-purple);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: var(--success-green);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-green-light);
    transform: translateY(-2px);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--gray-100);
    color: var(--gray-900);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-lg);
}

/* Cart Button Special */
.cart-button {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

.cart-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    color: white;
}

.cart-count {
    position: absolute;
    /* 
     * Adjusted positioning to keep the badge visible within button bounds
     * Small positive values ensure the badge stays inside the button
     * while maintaining the top-right corner placement
     */
    top: 1px;          /* Changed from -4px to keep it visible */
    right: 1px;        /* Changed from -4px to keep it visible */
    background: var(--accent-yellow);
    color: var(--gray-900);
    font-size: var(--font-xs);
    font-weight: 700;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
    box-shadow: var(--shadow-md);
    
    /* 
     * Additional improvements for better visibility and accessibility
     */
    z-index: 1;        /* Ensures badge appears above other elements */
    line-height: 1;    /* Prevents vertical spacing issues */
    display: flex;     /* Centers content perfectly */
    align-items: center;
    justify-content: center;
}

/* ============================================
   CARD COMPONENTS
   ============================================ */
.card {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: all var(--transition-slow);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-image {
    width: 100%;
    height: 250px;
    object-fit: cover;
    background: var(--gradient-subtle);
    position: relative;
}

.card-body {
    padding: var(--space-4);
}

.card-title {
    font-size: var(--font-lg);
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--gray-900);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-subtitle {
    font-size: var(--font-sm);
    color: var(--gray-600);
    margin-bottom: var(--space-3);
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--gray-200);
}

.card-price {
    font-size: var(--font-xl);
    font-weight: 700;
    color: var(--primary-purple);
}

.card-badge {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--font-xs);
    font-weight: 600;
    box-shadow: var(--shadow-lg);
}

/* Book Icon Fallback */
.book-icon-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-subtle);
    color: var(--gray-400);
    font-size: 4rem;
}

/* ============================================
   GRID LAYOUTS
   ============================================ */
.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-5 { grid-template-columns: repeat(5, 1fr); }
.grid-cols-6 { grid-template-columns: repeat(6, 1fr); }

.grid-auto {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* ============================================
   SECTIONS
   ============================================ */
.section {
    padding: var(--space-12) 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-8);
}

.section-title {
    font-size: var(--font-3xl);
    font-weight: 700;
    color: var(--gray-900);
}

.section-subtitle {
    font-size: var(--font-lg);
    color: var(--gray-600);
    margin-top: var(--space-2);
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
    background: white;
    padding: var(--space-16) var(--space-8);
    text-align: center;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--space-12);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: var(--gradient-primary);
}

.hero-title {
    font-size: var(--font-5xl);
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-4);
}

.hero-subtitle {
    font-size: var(--font-xl);
    color: var(--gray-600);
    max-width: 600px;
    margin: 0 auto var(--space-8);
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    gap: var(--space-4);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

.spinner-lg {
    width: 64px;
    height: 64px;
    border-width: 5px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(90deg, 
        var(--gray-200) 25%, 
        var(--gray-100) 50%, 
        var(--gray-200) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   ERROR STATES
   ============================================ */
.error-container {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    max-width: 600px;
    margin: 0 auto;
}

.error-icon {
    font-size: 4rem;
    color: var(--error-red);
    margin-bottom: var(--space-4);
}

.error-title {
    font-size: var(--font-2xl);
    color: var(--gray-900);
    margin-bottom: var(--space-3);
}

.error-message {
    font-size: var(--font-lg);
    color: var(--gray-600);
    margin-bottom: var(--space-6);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast {
    position: fixed;
    top: var(--space-8);
    right: var(--space-8);
    background: var(--success-green);
    color: white;
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-toast);
    animation: slideInRight 0.3s ease;
    max-width: 400px;
    font-weight: 500;
}

.toast.error {
    background: var(--error-red);
}

.toast.warning {
    background: var(--warning-orange);
}

.toast.info {
    background: var(--info-blue);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   BADGES & TAGS
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-sm);
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--gray-200);
    color: var(--gray-700);
}

.badge-primary {
    background: var(--primary-purple);
    color: white;
}

.badge-success {
    background: var(--success-green);
    color: white;
}

.badge-warning {
    background: var(--warning-orange);
    color: white;
}

.badge-danger {
    background: var(--error-red);
    color: white;
}

.tag {
    display: inline-block;
    padding: var(--space-2) var(--space-3);
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    font-weight: 500;
    transition: all var(--transition-base);
}

.tag:hover {
    background: var(--primary-purple);
    color: white;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--space-2);
    color: var(--gray-700);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-base);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-lg);
    background: white;
    transition: all var(--transition-base);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 1024px) {
    .container {
        padding: 0 var(--space-4);
    }
    
    .grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .hero-title {
        font-size: var(--font-4xl);
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        padding: var(--space-3);
    }
    
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .section {
        padding: var(--space-8) 0;
    }
    
    .hero {
        padding: var(--space-8) var(--space-4);
    }
    
    .hero-title {
        font-size: var(--font-3xl);
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-2);
    }
}

@media (max-width: 640px) {
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr;
    }
    
    .hero-title {
        font-size: var(--font-2xl);
    }
    
    .section-title {
        font-size: var(--font-2xl);
    }
    
    .toast {
        right: var(--space-4);
        left: var(--space-4);
        max-width: none;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .store-header,
    .btn,
    .toast {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}