/**
 * Sales Application - Modern Theme System
 * Supports: Light/Dark Modes, RTL/LTR, Responsive Design
 */

/* ============================================
   ROOT VARIABLES & THEME DEFINITIONS
   ============================================ */

:root {
    /* Spacing Scale */
    --spacing-1: 0.25rem;
    --spacing-2: 0.5rem;
    --spacing-3: 0.75rem;
    --spacing-4: 1rem;
    --spacing-5: 1.25rem;
    --spacing-6: 1.5rem;
    --spacing-8: 2rem;
    --spacing-12: 3rem;

    /* Typography */
    --font-sans: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --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);

    /* Z-Index Scale */
    --z-base: 1;
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
}

/* ============================================
   LIGHT THEME (DEFAULT)
   ============================================ */

:root,
[data-theme="light"] {
    /* Primary Colors (Kids Arena Blue) */
    --color-primary-50: #f0f9ff;
    --color-primary-100: #e0f2fe;
    --color-primary-200: #bae6fd;
    --color-primary-300: #7dd3fc;
    --color-primary-400: #38bdf8;
    --color-primary-500: #3DA5D9;
    --color-primary-600: #0284c7;
    --color-primary-700: #0369a1;
    --color-primary-800: #075985;
    --color-primary-900: #0c4a6e;

    /* Slate/Neutral Colors */
    --color-slate-50: #f8fafc;
    --color-slate-100: #f1f5f9;
    --color-slate-200: #e2e8f0;
    --color-slate-300: #cbd5e1;
    --color-slate-400: #94a3b8;
    --color-slate-500: #64748b;
    --color-slate-600: #475569;
    --color-slate-700: #334155;
    --color-slate-800: #1e293b;
    --color-slate-900: #0f172a;

    /* Semantic Colors */
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;

    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;

    /* Border Colors */
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    /* Component Specific */
    --navbar-bg: #ffffff;
    --sidebar-bg: linear-gradient(180deg, #3DA5D9, #E31E24);
    --sidebar-border: rgba(255,255,255,0.1);
}

/* ============================================
   DARK THEME
   ============================================ */

[data-theme="dark"] {
    /* Primary Colors (adjusted for dark mode) */
    --color-primary-50: #831843;
    --color-primary-100: #9d174d;
    --color-primary-200: #be185d;
    --color-primary-300: #db2777;
    --color-primary-400: #ec4899;
    --color-primary-500: #f472b6;
    --color-primary-600: #f9a8d4;
    --color-primary-700: #fbcfe8;
    --color-primary-800: #fce7f3;
    --color-primary-900: #fdf2f8;

    /* Slate Colors (inverted) */
    --color-slate-50: #0f172a;
    --color-slate-100: #1e293b;
    --color-slate-200: #334155;
    --color-slate-300: #475569;
    --color-slate-400: #64748b;
    --color-slate-500: #94a3b8;
    --color-slate-600: #cbd5e1;
    --color-slate-700: #e2e8f0;
    --color-slate-800: #f1f5f9;
    --color-slate-900: #f8fafc;

    /* Semantic Colors (darker variants) */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #dc2626;
    --color-info: #2563eb;

    /* Background Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --bg-active: #475569;

    /* Border Colors */
    --border-color: #334155;
    --border-hover: #475569;

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-inverse: #0f172a;

    /* Component Specific */
    --navbar-bg: #1e293b;
    --sidebar-bg: #1e293b;
    --sidebar-border: #334155;

    /* Adjusted Shadows for Dark Mode */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
    box-sizing: border-box;
}

html {
    transition: background-color var(--transition-normal);
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
    margin: 0;
    padding: 0;
}

/* ============================================
   APP LAYOUT STRUCTURE
   ============================================ */

.app-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-secondary);
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: visible;
    /* Important for sticky */
}

.page-content {
    flex: 1;
    padding: var(--spacing-6);
    overflow-y: auto;
    /* Content scrolls, not wrapper */
}

@media (max-width: 767px) {
    .page-content {
        padding: var(--spacing-4);
    }
}

/* ============================================
   RTL SUPPORT
   ============================================ */

[dir="rtl"] {
    direction: rtl;
}

[dir="ltr"] {
    direction: ltr;
}

/* RTL-aware positioning utilities */
.rtl-flip {
    transform: scaleX(-1);
}

[dir="rtl"] .rtl-mirror {
    transform: scaleX(-1);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Layout */
.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: var(--spacing-2);
}

.gap-3 {
    gap: var(--spacing-3);
}

.gap-4 {
    gap: var(--spacing-4);
}

/* Text */
.text-muted {
    color: var(--text-muted);
}

.text-danger {
    color: var(--color-danger);
}

.font-bold {
    font-weight: 600;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* Stat Cards */
.stat-card {
    padding: var(--spacing-6);
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-hover) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--spacing-2);
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-top: var(--spacing-2);
}

.stat-icon {
    font-size: 2rem;
    color: var(--color-primary-600);
    opacity: 0.8;
}

/* Highlight Card */
.card-highlight {
    background: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-primary-700) 100%);
    color: white;
    border: none;
    box-shadow: var(--shadow-xl);
    transition: all var(--transition-normal);
}

.card-highlight:hover {
    transform: translateY(-4px);
    box-shadow: 0 25px 50px -12px rgba(236, 72, 153, 0.5);
}

/* Lists */
.list-group {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list-item {
    display: flex;
    align-items: center;
    padding: var(--spacing-4);
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background-color: var(--bg-hover);
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    object-fit: cover;
    margin-inline-end: var(--spacing-4);
}

/* Badges */
.badge-pill {
    display: inline-block;
    padding: var(--spacing-1) var(--spacing-3);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background-color: rgba(34, 197, 94, 0.1);
    color: var(--color-success);
}

.badge-primary {
    background-color: rgba(236, 72, 153, 0.1);
    color: var(--color-primary-600);
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

/* Mobile First Breakpoints */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .show-mobile {
        display: none !important;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hide-tablet {
        display: none !important;
    }
}

@media (min-width: 1024px) {
    .hide-desktop {
        display: none !important;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Visible */
*:focus-visible {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-fadeIn {
    animation: fadeIn var(--transition-normal);
}

.animate-slideInRight {
    animation: slideInRight var(--transition-normal);
}

.animate-slideInLeft {
    animation: slideInLeft var(--transition-normal);
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--color-slate-400);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-slate-500);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--color-slate-600);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--color-slate-500);
}