/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #94a3b8;
    --accent-color: #fbbf24;
    --success-color: #10b981;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
    --info-color: #3b82f6;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-on-primary: #ffffff;
    
    --border-color: #334155;
    --border-dark: #475569;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3);
}

/* Color Themes */
[data-color-theme="blue"] {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --accent-color: #06b6d4;
}

[data-color-theme="purple"] {
    --primary-color: #8b5cf6;
    --primary-dark: #7c3aed;
    --accent-color: #a855f7;
}

[data-color-theme="green"] {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --accent-color: #14b8a6;
}

[data-color-theme="red"] {
    --primary-color: #ef4444;
    --primary-dark: #dc2626;
    --accent-color: #f87171;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-primary: #000000;
        --bg-primary: #ffffff;
        --shadow-sm: 0 0 0 1px #000000;
        --shadow-md: 0 0 0 2px #000000;
        --shadow-lg: 0 0 0 3px #000000;
    }
    
    [data-theme="dark"] {
        --border-color: #ffffff;
        --text-primary: #ffffff;
        --bg-primary: #000000;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Auto Dark Mode Detection */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --primary-color: #3b82f6;
        --primary-dark: #2563eb;
        --secondary-color: #94a3b8;
        --accent-color: #fbbf24;
        --success-color: #10b981;
        --danger-color: #f87171;
        --warning-color: #fbbf24;
        --info-color: #3b82f6;
        
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-tertiary: #334155;
        --bg-card: #1e293b;
        
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --text-on-primary: #ffffff;
        
        --border-color: #334155;
        --border-dark: #475569;
        
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);
        --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3);
    }
}

/* Print Styles */
@media print {
    .app-header,
    .sidebar,
    .modal-overlay,
    .offline-queue,
    .toast-container,
    .btn {
        display: none !important;
    }
    
    .app-container {
        height: auto;
    }
    
    .main-content {
        display: block;
    }
    
    .content-area {
        padding: 0;
        overflow: visible;
    }
    
    .pos-container {
        display: block;
        height: auto;
    }
    
    .product-grid-container {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .order-panel {
        border: none;
        box-shadow: none;
        page-break-inside: avoid;
    }
}

/* Accessibility */
.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;
}

/* Focus Visible for All Interactive Elements */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High DPI Screen Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .border {
        border-width: 0.5px;
    }
}

/* Keyboard Navigation */
:focus-within {
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

/* Skip Links */
.skip-links {
    position: absolute;
    top: -40px;
    left: 0;
    z-index: var(--z-popover);
}

.skip-links a {
    display: block;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    margin: 0 0 5px 0;
}

.skip-links a:focus {
    top: 0;
}
