/* ==========================================================================
   BASE & GLOBAL STYLES
   ========================================================================== */
body {
    min-height: max(884px, 100dvh);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar for Webkit */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #0a0505;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ec131e;
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #333 #0a0505;
}

/* Material Symbols Utility */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    user-select: none;
}

/* ==========================================================================
   COMPONENTS
   ========================================================================== */

/* Select Elements Fix */
/* Select Elements Fix - Dark & Frameless */
select {
    padding-left: 1rem !important;
    padding-right: 2.5rem !important;
    background-color: #050505 !important;
    color: #ffffff !important;
    border: none !important;
    outline: none !important;
    /* Remove default arrow in some browsers to use custom if needed, otherwise default is fine but dark */
}

/* POS Filters - Compact padding for tablet layout */
select#filter-make,
select#filter-category,
select#filter-subcategory {
    padding-left: 0.375rem !important;
    padding-right: 1.75rem !important;
    font-size: 0.75rem !important;
    line-height: 1rem !important;
}

select option {
    background-color: #050505 !important;
    color: #ffffff !important;
}

/* Shared Metallic UI */
.metallic-border {
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
}

.luxury-bg {
    background: radial-gradient(circle at top, #1a1a1a 0%, #0a0a0a 100%);
}

/* ==========================================================================
   PREMIUM PRELOADER (Standardized)
   ========================================================================== */
#app-preloader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}

#app-preloader.hidden-loader {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.loader-circle {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-spinner {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top: 3px solid #ec131e;
    animation: loader-spin 1.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    box-shadow: 0 -5px 15px rgba(236, 19, 30, 0.2);
}

.loader-logo-img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    opacity: 0.9;
    animation: loader-pulse-logo 3s infinite ease-in-out;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.1));
}

.loader-text-wrapper {
    text-align: center;
}

.loader-title {
    font-size: 0.75rem;
    font-weight: 900;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5em;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.loader-subtitle {
    font-size: 0.65rem;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    animation: loader-fade-text 2s infinite ease-in-out;
}

.loader-progress-bar {
    width: 150px;
    height: 2px;
    background: rgba(255, 255, 255, 0.05);
    margin-top: 2rem;
    border-radius: 1px;
    overflow: hidden;
}

.loader-progress-inner {
    width: 100%;
    height: 100%;
    background: #ec131e;
    transform: translateX(-100%);
    animation: loader-progress 3s infinite ease-in-out;
}

@keyframes loader-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes loader-pulse-logo {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

@keyframes loader-fade-text {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

@keyframes loader-progress {
    0% {
        transform: translateX(-100%);
    }

    50% {
        transform: translateX(0%);
    }

    100% {
        transform: translateX(100%);
    }
}

@keyframes glow-pulse {
    0% {
        transform: scale(0.8);
        opacity: 0.3;
    }

    100% {
        transform: scale(1.2);
        opacity: 0.6;
    }
}


/* ==========================================================================
   RESPONSIVE SIDEBAR (COLLAPSIBLE DESKTOP & MOBILE)
   ========================================================================== */

/* Hamburger Menu Button - Visible on ALL screens now */
#mobile-menu-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    width: 48px;
    height: 48px;
    background: rgba(10, 5, 5, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    /* Hidden on desktop via media query below */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

/* Move button to right when active */
#mobile-menu-toggle.active {
    left: auto;
    right: 1rem;
    background: rgba(236, 19, 30, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
}

#mobile-menu-toggle:hover {
    background: rgba(236, 19, 30, 0.2);
    border-color: rgba(236, 19, 30, 0.5);
}

#mobile-menu-toggle .material-symbols-outlined {
    color: white;
    font-size: 24px;
}

/* Hide Hamburger on Desktop */
@media (min-width: 1025px) {
    #mobile-menu-toggle {
        display: none !important;
    }
}

/* Sidebar Overlay */
#sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 90;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

#sidebar-overlay.active {
    opacity: 1;
}

/* SIDEBAR - HIDDEN BY DEFAULT ON MOBILE/TABLET ONLY */
@media (max-width: 1024px) {
    aside {
        position: fixed !important;
        /* Force fixed */
        left: -100% !important;
        top: 0;
        height: 100vh;
        z-index: 95;
        transition: left 0.3s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
        width: 280px !important;
        /* Fixed width when open */
        background-color: #0a0505;
        /* Ensure background opacity */
    }

    /* Show sidebar when active */
    aside.mobile-active {
        left: 0 !important;
    }

    /* Slide main content logic if needed - currently overlay */
}

/* Adjust main content to full width ALWAYS */
main {
    width: 100% !important;
    margin-left: 0 !important;
}

/* Add padding to top of main content for hamburger button */
main>header {
    padding-left: 4.5rem !important;
    /* Space for the button */
}

/* Mobile Responsive Styles - Keep specific overrides if needed */
@media (max-width: 768px) {
    /* No change needed, global styles cover it now */
}

/* Tablet adjustments - Remove static width logic */
@media (min-width: 769px) and (max-width: 1000px) {
    /* Reset any specific tablet width if previously set */
}

/* Vertical space optimization for low-height screens (like 1000x600 tablets) */
@media (max-height: 700px) {
    header {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    #page-title {
        font-size: 1.1rem !important;
    }

    #page-subtitle {
        display: none !important;
        /* Hide subtitle to save vertical space */
    }

    .view-section {
        padding: 0.75rem !important;
    }

    /* POS Sidebar adjustments for low height */
    #pos-main-layout>div:last-child {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    #pos-cart-items {
        gap: 0.5rem !important;
    }
}

/* ==========================================================================
   POS CART RESPONSIVE
   ========================================================================== */

/* Floating Cart Button for Mobile */
#mobile-cart-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 150;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #ec131e 0%, #c10e18 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 24px rgba(236, 19, 30, 0.4);
}

#mobile-cart-toggle:active {
    transform: scale(0.95);
}

#mobile-cart-toggle .material-symbols-outlined {
    color: white;
    font-size: 28px;
}

#mobile-cart-toggle .cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: white;
    color: #ec131e;
    font-size: 11px;
    font-weight: 900;
    min-width: 24px;
    height: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid #ec131e;
}

/* Cart Overlay for Mobile */
#cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 98;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

#cart-overlay.active {
    opacity: 1;
}

/* Mobile POS Layout */
/* Mobile POS Layout */
@media (max-width: 767px) {

    /* Show floating cart button */
    #mobile-cart-toggle {
        display: flex;
    }

    /* POS specific adjustments */
    #pos-main-layout {
        flex-direction: column !important;
    }

    /* Hide cart panel by default on mobile */
    #pos-cart-panel {
        position: fixed;
        right: -100%;
        top: 0;
        height: 100dvh;
        width: 90%;
        max-width: 400px;
        z-index: 200;
        transition: right 0.3s ease;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
        background-color: #050505;
        padding-bottom: 2rem;
    }

    /* Show cart when active */
    #pos-cart-panel.mobile-cart-active {
        right: 0;
    }

    /* Product grid takes full width */
    #pos-main-layout>div:first-child {
        width: 100% !important;
        flex: 1;
    }

    /* Adjust padding for floating button */
    #view-pos {
        padding-bottom: 6rem !important;
    }
}

/* Desktop - ensure normal layout */
@media (min-width: 768px) {

    #mobile-cart-toggle,
    #cart-overlay {
        display: none !important;
    }
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATION (Tablet/Mobile)
   ========================================================================== */
@media (max-width: 1100px) {

    /* Hide page subtitle on tablet/mobile (including 1032px) */
    #page-subtitle {
        display: none !important;
    }

    /* Disable expensive blur effects */
    * {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* Fallback backgrounds for readability where blur was used */
    header,
    #sidebar-overlay,
    #cart-overlay,
    .backdrop-blur-md,
    .backdrop-blur-lg,
    .backdrop-blur-sm,
    .bg-background-dark\/80 {
        background-color: rgba(10, 5, 5, 0.98) !important;
    }

    /* Reduce animation complexity - removed too aggressive global override */
    /* 
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
    */
}