/**
 * Theme System CSS
 * Global CSS variables and theme switching support
 * Supports both dark and light themes with smooth transitions
 */

/* ========================================
   CSS Variables & Theme Configuration
   ======================================== */
:root {
    /* Database colors */
    --warna_1: <?= conf('color',2) ?>;
    --warna_2: <?= conf('color',1) ?>;
    --warna_3: <?= conf('color',3) ?>;
    --warna_4: <?= conf('color',4) ?>;
    
    /* Default dark theme */
    --bg-primary: <?= conf('color',1) ?>;
    --bg-secondary: <?= conf('color',2) ?>;
    --bg-tertiary: <?= conf('color',4) ?>;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-tertiary: rgba(255, 255, 255, 0.6);
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --primary-color: <?= conf('color',3) ?>;
    --primary-hover: <?= conf('color',4) ?>;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px var(--shadow-color);
    --shadow-md: 0 4px 15px var(--shadow-color);
    --shadow-lg: 0 8px 30px var(--shadow-color);
    --shadow-xl: 0 20px 60px var(--shadow-color);
}

/* Light theme colors */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --primary-color: <?= conf('color',3) ?>;
    --primary-hover: <?= conf('color',4) ?>;
    --shadow-sm: 0 2px 4px var(--shadow-color);
    --shadow-md: 0 4px 10px var(--shadow-color);
    --shadow-lg: 0 8px 20px var(--shadow-color);
}

/* Dark theme colors - using the configured colors */
[data-theme="dark"] {
    --bg-primary: <?= conf('color',1) ?>;
    --bg-secondary: <?= conf('color',2) ?>;
    --bg-tertiary: <?= conf('color',4) ?>;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-tertiary: rgba(255, 255, 255, 0.6);
    --border-color: rgba(255, 255, 255, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --primary-color: <?= conf('color',3) ?>;
    --primary-hover: <?= conf('color',4) ?>;
}

/* ========================================
   Global Theme Styles
   ======================================== */
* {
    transition: background-color var(--transition-base), 
                color var(--transition-base), 
                border-color var(--transition-base),
                box-shadow var(--transition-base);
}

html {
    color-scheme: light dark;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color var(--transition-base), 
                color var(--transition-base);
}

/* Ensure all text inherits theme color */
h1, h2, h3, h4, h5, h6, p, span, div, a, li, td, th, label, button {
    color: inherit;
}

/* Links with theme-aware colors */
a {
    color: var(--text-primary);
    transition: color var(--transition-base);
}

a:hover {
    color: var(--primary-color);
}

/* ========================================
   Component Styles
   ======================================== */

/* Tab Button Styles */
.tab-button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    opacity: 0.9;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-button:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    opacity: 1;
}

.tab-button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    opacity: 1;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.tab-button.active:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.tab-icon {
    color: inherit;
    transition: color 0.3s ease;
}

.tab-button:hover .tab-icon {
    color: var(--primary-color);
}

.tab-button.active .tab-icon {
    color: white;
}

/* Cards */
.card, .category-card, .trending-card-content, .news-card, .product-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.card:hover, .category-card:hover, .trending-card-content:hover, .news-card:hover, .product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Buttons */
.btn, .theme-toggle-btn, .scroll-button, .load-more-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all var(--transition-base);
}

.btn:hover, .theme-toggle-btn:hover, .scroll-button:hover, .load-more-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Inputs */
input, textarea, select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

input::placeholder, textarea::placeholder {
    color: var(--text-tertiary);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color), 0.1);
}

/* Navigation */
.navbar, .mobile-menu-container {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.desktop-nav-link, .mobile-nav-link {
    color: var(--text-primary);
}

.desktop-nav-link:hover, .mobile-nav-link:hover,
.desktop-nav-link.active, .mobile-nav-link.active {
    color: var(--primary-color);
}

/* Footer */
.footer-wrapper {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    color: var(--text-primary);
}

.footer-link {
    color: var(--text-secondary);
}

.footer-link:hover {
    color: var(--primary-color);
}

/* Text Colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--primary-color); }

/* Background Colors */
.bg-primary { background: var(--bg-primary); }
.bg-secondary { background: var(--bg-secondary); }
.bg-tertiary { background: var(--bg-tertiary); }
.bg-accent { background: var(--primary-color); }

/* Border Colors */
.border-primary { border-color: var(--border-color); }
.border-accent { border-color: var(--primary-color); }

/* Shadow Utilities */
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

/* ========================================
   Animation Utilities
   ======================================== */
.fade-in {
    animation: fadeIn var(--transition-slow);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp var(--transition-base);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Price and Discount Styles
   ======================================== */
.sale-price {
    color: var(--text-primary);
    font-weight: 600;
}

.original-price {
    color: var(--text-tertiary);
    text-decoration: line-through;
}

.discount-tag {
    color: var(--text-primary);
    font-weight: 600;
    background: var(--primary-color);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.price-info-container {
    color: var(--text-primary);
}

.price-divider {
    color: var(--text-tertiary);
    margin: 0 0.5rem;
}

/* ========================================
   Typography
   ======================================== */
.text-xs { 
    font-size: 0.75rem; 
    color: var(--text-primary);
    line-height: 1rem;
}
.text-sm { 
    font-size: 0.875rem; 
    color: var(--text-primary);
    line-height: 1.25rem;
}
.text-base { 
    font-size: 1rem; 
    color: var(--text-primary);
    line-height: 1.5rem;
}
.text-lg { 
    font-size: 1.125rem; 
    color: var(--text-primary);
    line-height: 1.75rem;
}
.text-xl { 
    font-size: 1.25rem; 
    color: var(--text-primary);
    line-height: 1.75rem;
}
.text-2xl { 
    font-size: 1.5rem; 
    color: var(--text-primary);
    line-height: 2rem;
}
.text-3xl { 
    font-size: 1.875rem; 
    color: var(--text-primary);
    line-height: 2.25rem;
}
.text-4xl { 
    font-size: 2.25rem; 
    color: var(--text-primary);
    line-height: 2.5rem;
}

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    :root {
        --spacing-md: 0.75rem;
        --spacing-lg: 1rem;
        --spacing-xl: 1.5rem;
    }
}

/* ========================================
   Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: rgba(255, 255, 255, 0.3);
    }
    
    [data-theme="light"] {
        --border-color: rgba(0, 0, 0, 0.3);
    }
}
