/**
 * reToDo v2 - Unified Design System & Multi-Theme Architecture
 * File: /static/css/app.css
 * 
 * Provides:
 *  1. CSS Custom Properties / Design Tokens for light & dark modes
 *  2. Multi-theme definitions (teal, blue, emerald, purple, amber, rose)
 *  3. Standardized UI components (.btn, .form-input, .card, .badge, .table, etc.)
 *  4. Page-specific integrated styles (inventory 3D racks, custom scrollbars, etc.)
 *  5. Seamless extensibility for new custom themes
 */

/* ==========================================================================
   1. CSS VARIABLES & THEME PRESETS
   ========================================================================== */

:root {
    /* Brand & Accent Defaults (Teal / Signature) */
    --theme-name: "teal";
    --color-accent: #2dd4bf;
    --color-accent-rgb: 45, 212, 191;
    --color-accent-hover: #14b8a6;
    --color-accent-light: rgba(45, 212, 191, 0.12);
    --color-accent-contrast: #0f172a;

    --color-primary: #0d9488;
    --color-primary-rgb: 13, 148, 136;
    --color-primary-hover: #0f766e;
    --color-primary-light: rgba(13, 148, 136, 0.1);

    /* Light Mode Neutrals */
    --color-bg-body: #f8fafc;
    --color-bg-surface: #ffffff;
    --color-bg-card: #ffffff;
    --color-bg-card-subtle: #f1f5f9;
    --color-bg-sidebar: #0f172a;
    --color-bg-sidebar-active: rgba(255, 255, 255, 0.1);
    --color-bg-modal: #ffffff;
    --color-bg-input: #ffffff;

    --color-text-main: #0f172a;
    --color-text-muted: #64748b;
    --color-text-subtle: #94a3b8;
    --color-text-inverted: #ffffff;

    --color-border-main: #e2e8f0;
    --color-border-subtle: #f1f5f9;
    --color-border-focus: var(--color-accent);

    /* Status Colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;

    /* Radii & Shadows */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 9999px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
    --shadow-glow: 0 0 20px -3px rgba(var(--color-accent-rgb), 0.35);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Overrides (Default / Teal) */
.dark,
html[class~="dark"] {
    --color-bg-body: #0b1120;
    --color-bg-surface: #0f172a;
    --color-bg-card: #0f172a;
    --color-bg-card-subtle: #1e293b;
    --color-bg-sidebar: #090d16;
    --color-bg-sidebar-active: rgba(255, 255, 255, 0.08);
    --color-bg-modal: #0f172a;
    --color-bg-input: #0b1120;

    --color-text-main: #f8fafc;
    --color-text-muted: #94a3b8;
    --color-text-subtle: #64748b;
    --color-text-inverted: #0f172a;

    --color-border-main: #1e293b;
    --color-border-subtle: #172033;

    --shadow-card: 0 8px 30px -4px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 25px -2px rgba(var(--color-accent-rgb), 0.45);
}

/* --------------------------------------------------------------------------
   PRESET 2: OCEAN BLUE (Okyanus / Kurumsal Mavi)
   -------------------------------------------------------------------------- */
[data-theme="blue"] {
    --theme-name: "blue";
    --color-accent: #38bdf8;
    --color-accent-rgb: 56, 189, 248;
    --color-accent-hover: #0284c7;
    --color-accent-light: rgba(56, 189, 248, 0.12);
    --color-accent-contrast: #ffffff;

    --color-primary: #2563eb;
    --color-primary-rgb: 37, 99, 235;
    --color-primary-hover: #1d4ed8;
    --color-primary-light: rgba(37, 99, 235, 0.12);
}

/* --------------------------------------------------------------------------
   PRESET 3: EMERALD (Zümrüt Yeşili / Finans & Doğa)
   -------------------------------------------------------------------------- */
[data-theme="emerald"] {
    --theme-name: "emerald";
    --color-accent: #34d399;
    --color-accent-rgb: 52, 211, 153;
    --color-accent-hover: #059669;
    --color-accent-light: rgba(52, 211, 153, 0.12);
    --color-accent-contrast: #0f172a;

    --color-primary: #10b981;
    --color-primary-rgb: 16, 185, 129;
    --color-primary-hover: #047857;
    --color-primary-light: rgba(16, 185, 129, 0.12);
}

/* --------------------------------------------------------------------------
   PRESET 4: PURPLE / VIOLET (Lavanta & Mor / Modern Royal)
   -------------------------------------------------------------------------- */
[data-theme="purple"] {
    --theme-name: "purple";
    --color-accent: #c084fc;
    --color-accent-rgb: 192, 132, 252;
    --color-accent-hover: #9333ea;
    --color-accent-light: rgba(192, 132, 252, 0.14);
    --color-accent-contrast: #ffffff;

    --color-primary: #8b5cf6;
    --color-primary-rgb: 139, 92, 246;
    --color-primary-hover: #7c3aed;
    --color-primary-light: rgba(139, 92, 246, 0.12);
}

/* --------------------------------------------------------------------------
   PRESET 5: AMBER / SUNSET (Kehribar / Gün Batımı)
   -------------------------------------------------------------------------- */
[data-theme="amber"] {
    --theme-name: "amber";
    --color-accent: #fbbf24;
    --color-accent-rgb: 251, 191, 36;
    --color-accent-hover: #d97706;
    --color-accent-light: rgba(251, 191, 36, 0.15);
    --color-accent-contrast: #1e1b4b;

    --color-primary: #f59e0b;
    --color-primary-rgb: 245, 158, 11;
    --color-primary-hover: #b45309;
    --color-primary-light: rgba(245, 158, 11, 0.12);
}

/* --------------------------------------------------------------------------
   PRESET 6: ROSE / CRIMSON (Yakut & Gül / Dinamik)
   -------------------------------------------------------------------------- */
[data-theme="rose"] {
    --theme-name: "rose";
    --color-accent: #fb7185;
    --color-accent-rgb: 251, 113, 133;
    --color-accent-hover: #e11d48;
    --color-accent-light: rgba(251, 113, 133, 0.15);
    --color-accent-contrast: #ffffff;

    --color-primary: #f43f5e;
    --color-primary-rgb: 244, 63, 94;
    --color-primary-hover: #be123c;
    --color-primary-light: rgba(244, 63, 94, 0.12);
}


/* ==========================================================================
   2. CORE BASE STYLES & TYPOGRAPHY
   ========================================================================== */

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--color-text-main);
    background-color: var(--color-bg-body);
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Material Icons Alignment */
.material-icons-round,
.material-symbols-outlined {
    vertical-align: middle;
    font-display: block;
}


/* ==========================================================================
   3. REUSABLE UI COMPONENTS (STANDARDS)
   ========================================================================== */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-accent-contrast);
    border-color: transparent;
}

.btn-primary:hover {
    background-color: var(--color-accent-hover);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background-color: var(--color-bg-card-subtle);
    color: var(--color-text-main);
    border-color: var(--color-border-main);
}

.btn-secondary:hover {
    background-color: var(--color-border-main);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--color-border-main);
    color: var(--color-text-main);
}

.btn-outline:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background-color: var(--color-accent-light);
}

.btn-ghost {
    background-color: transparent;
    color: var(--color-text-muted);
}

.btn-ghost:hover {
    background-color: var(--color-bg-card-subtle);
    color: var(--color-text-main);
}

.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 0 15px -3px rgba(239, 68, 68, 0.4);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-md);
}

/* Form Controls */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--color-border-main);
    background-color: var(--color-bg-input);
    color: var(--color-text-main);
    padding: 0.65rem 0.9rem;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-light);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--color-text-subtle);
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 0.35rem;
}

/* Cards */
.card-flat {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-main);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.card-accent {
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border-main);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
}

.card-accent:hover {
    border-color: rgba(var(--color-accent-rgb), 0.4);
}

.dark .card-accent {
    border-color: var(--color-border-main);
    box-shadow: var(--shadow-card);
}

.dark .card-accent:hover {
    border-color: rgba(var(--color-accent-rgb), 0.4);
    box-shadow: 0 0 20px -5px rgba(var(--color-accent-rgb), 0.25);
}

/* Badges & Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    line-height: 1;
    border: 1px solid transparent;
}

.badge-theme {
    background-color: var(--color-accent-light);
    color: var(--color-accent);
    border-color: rgba(var(--color-accent-rgb), 0.2);
}

/* Modals */
.modal-backdrop {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}


/* ==========================================================================
   4. LAYOUT & SIDEBAR NAVIGATION
   ========================================================================== */

.sidebar-item {
    transition: all var(--transition-fast);
}

.sidebar-item:hover {
    background-color: var(--color-bg-sidebar-active);
}

.sidebar-item-active {
    background-color: var(--color-bg-sidebar-active) !important;
    border-left: 4px solid var(--color-accent) !important;
    color: #ffffff !important;
}

.sidebar-item-active .material-icons-round {
    color: var(--color-accent) !important;
}

#desktop-sidebar-toggle:checked ~ aside {
    width: 80px;
}

#desktop-sidebar-toggle:checked ~ aside .nav-text,
#desktop-sidebar-toggle:checked ~ aside .logo-text,
#desktop-sidebar-toggle:checked ~ aside .footer-text {
    display: none;
}

#desktop-sidebar-toggle:checked ~ aside .sidebar-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

#desktop-sidebar-toggle:checked ~ aside .sidebar-item-active {
    border-left-width: 0 !important;
    border-bottom: 3px solid var(--color-accent) !important;
    border-radius: 0;
}

#desktop-sidebar-toggle:checked ~ aside .collapse-icon {
    transform: rotate(180deg);
}

#mobile-menu-toggle:checked ~ .mobile-overlay {
    display: block;
}

#mobile-menu-toggle:checked ~ aside {
    transform: translateX(0);
}


/* ==========================================================================
   5. PAGE-SPECIFIC INTEGRATED STYLES (NO MORE SCATTERED <STYLE> TAGS)
   ========================================================================== */

/* Custom Scrollbars */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #334155;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent);
}

/* Hide Scrollbar */
.hide-scroll::-webkit-scrollbar,
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.hide-scroll,
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Payments filter active state */
.filter-btn.active {
    background-color: var(--color-accent-light) !important;
    border-color: var(--color-accent) !important;
    color: var(--color-accent) !important;
}

/* Inventory Warehouse 3D Shelf & Cabinet Styles */
.shelf-perspective {
    perspective: 1200px;
}

.rack-upright {
    background: linear-gradient(90deg, #94a3b8, #cbd5e1, #94a3b8);
    box-shadow: inset 1px 0 2px rgba(0, 0, 0, 0.05), 4px 0 10px rgba(0, 0, 0, 0.1);
}

.dark .rack-upright {
    background: linear-gradient(90deg, #172554, #1e40af, #172554);
    box-shadow: inset 1px 0 2px rgba(255, 255, 255, 0.1), 4px 0 10px rgba(0, 0, 0, 0.8);
}

.rack-beam {
    background: linear-gradient(180deg, #f97316, #fb923c 40%, #ea580c);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3), 0 4px 8px rgba(0, 0, 0, 0.15);
    border-top: 1px solid #fdba74;
    border-bottom: 1px solid #c2410c;
}

.dark .rack-beam {
    background: linear-gradient(180deg, #9a3412, #ea580c 40%, #7c2d12);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1), 0 4px 8px rgba(0, 0, 0, 0.6);
    border-top: 1px solid #c2410c;
    border-bottom: 1px solid #431407;
}

.shelf-slot {
    transition: all 0.2s ease;
    transform-style: preserve-3d;
    background-color: rgba(0, 0, 0, 0.02);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.dark .shelf-slot {
    background-color: rgba(255, 255, 255, 0.01);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.shelf-slot:hover,
.shelf-slot.active {
    background-color: var(--color-accent-light);
    box-shadow: 0 0 15px rgba(var(--color-accent-rgb), 0.15), inset 0 0 20px rgba(var(--color-accent-rgb), 0.05);
    z-index: 10;
    border-color: rgba(var(--color-accent-rgb), 0.4) !important;
}

.drag-scroll {
    cursor: grab;
    user-select: none;
}

.drag-scroll.dragging {
    cursor: grabbing;
}

@media (max-width: 1023px) {
    #item-detail-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 80vh;
        z-index: 50;
        border-radius: 2rem 2rem 0 0;
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 -10px 50px rgba(0, 0, 0, 0.3);
    }

    .dark #item-detail-panel {
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
    }

    #item-detail-panel.open {
        transform: translateY(0);
    }

    #mobile-panel-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(4px);
        z-index: 40;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    #mobile-panel-overlay.show {
        opacity: 1;
        pointer-events: auto;
    }
}

.wood-vertical {
    background: linear-gradient(90deg, #a1887f, #d7ccc8, #a1887f);
    box-shadow: inset 2px 0 5px rgba(0, 0, 0, 0.1), 5px 0 15px rgba(0, 0, 0, 0.1);
}

.dark .wood-vertical {
    background: linear-gradient(90deg, #8d6e63, #bcaaa4, #8d6e63);
    box-shadow: inset 2px 0 5px rgba(0, 0, 0, 0.3), 5px 0 15px rgba(0, 0, 0, 0.6);
}

.wood-shelf {
    background: linear-gradient(180deg, #bcaaa4, #a1887f);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
    border-bottom: 2px solid #8d6e63;
}

.dark .wood-shelf {
    background: linear-gradient(180deg, #a1887f, #8d6e63);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    border-bottom: 2px solid #5d4037;
}

.wood-shelf-top {
    background: linear-gradient(180deg, #efebe9, #d7ccc8);
}

.dark .wood-shelf-top {
    background: linear-gradient(180deg, #d7ccc8, #bcaaa4);
}

.cabinet-cell {
    transition: all 0.2s ease;
    position: relative;
    background-color: rgba(0, 0, 0, 0.04);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.dark .cabinet-cell {
    background-color: rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.cabinet-cell:hover {
    background-color: var(--color-accent-light);
    box-shadow: inset 0 0 20px rgba(var(--color-accent-rgb), 0.15);
    z-index: 10;
}


/* ==========================================================================
   6. THEME SWITCHER UI STYLES
   ========================================================================== */

.theme-swatch {
    width: 24px;
    height: 24px;
    border-radius: 9999px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.theme-swatch:hover {
    transform: scale(1.18);
}

.theme-swatch.active {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px var(--color-text-main);
    transform: scale(1.15);
}
