/* ==========================================================================
   GLOBAL PREMIUM THEME ENGINE - AQ & AR cinemAS
   STRICT 3-COLOR LUXURY PALETTE (MOBILE & TAB OPTIMIZED)
   ========================================================================== */

:root {
    /* PREMIUM AURA UI PALETTE */
    --primary: #4F46E5 !important;            /* Vibrant Indigo - Primary Action */
    --primary-hover: #4338CA !important;      
    --secondary: #8B5CF6 !important;          /* Soft Violet - Accents */
    
    /* Background & Surfaces */
    --bg-base: #F8FAFC !important;            /* Very light slate background */
    --surface: #FFFFFF !important;            /* Pure white cards/modals */
    --surface-hover: #F1F5F9 !important;      /* Subtle hover states */
    --chalk-bg: rgba(255, 255, 255, 0.8) !important; 

    /* Text & Typography */
    --text-primary: #0F172A !important;       /* Deep slate for strong contrast */
    --text-on-surface: #1E293B !important; 
    --text-muted: #64748B !important;         /* Cool gray for secondary text */
    --text-inverse: #FFFFFF !important;       /* White text on dark buttons */

    /* Functional Mapping */
    --accent: var(--primary) !important;
    --success: #10B981 !important;            /* Emerald */
    --warning: #F59E0B !important;            /* Amber */
    --danger: #E11D48 !important;             /* Rose */

    /* Legacy Fallbacks (To prevent breaking old classes) */
    --amaranth: var(--primary) !important;          
    --thulian-pink: var(--secondary) !important; 
    --brook-green: var(--success) !important; 
    --pomelo-olive: var(--warning) !important; 
    --chalk: var(--surface) !important;    

    /* Borders & Shadows */
    --border-light: rgba(15, 23, 42, 0.08) !important;
    --border-strong: rgba(15, 23, 42, 0.15) !important;
    --shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.04) !important; 
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
    --shadow-lg: 0 20px 40px rgba(79, 70, 229, 0.15) !important; /* Premium colored shadow */
}

/* =========================================
   GLOBAL RESET & MOBILE VIEWPORT SCROLL FIX
   ========================================= */
html {
    -webkit-text-size-adjust: none !important;
    text-size-adjust: none !important;
    height: 100%;
    overflow-x: hidden !important;
    scroll-behavior: smooth;
}

body {
    -webkit-text-size-adjust: none !important;
    text-size-adjust: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;

    height: auto !important;
    min-height: 100dvh !important; /* 'dvh' fixes mobile URL bar jumping */
    background: transparent !important; 
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Montserrat', sans-serif !important;
    -webkit-tap-highlight-color: transparent !important; /* Removes blue tap flash */
    -webkit-overflow-scrolling: touch !important; /* CRITICAL: Enables smooth scroll on iOS/Tablets */
}

/* Premium Weight Enforcement */
body, button, input, select, textarea, .btn, .tab-btn, .item-name, .item-price, .form-label {
    font-weight: 900 !important;
}

/* Universal Content Wrapper */
.main-content {
    overflow-y: visible !important;
    height: auto !important;
    padding: 25px 3vw 80px 3vw !important; 
    width: 100% !important;
    max-width: 1600px !important;
    margin: 0 auto !important;
    position: relative;
    z-index: 10;
}

/* =========================================
   BACKGROUND VIDEO & OVERLAYS
   ========================================= */
.video-bg-wrapper {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    z-index: -10 !important;
    overflow: hidden !important;
    background: var(--text-primary) !important; 
}
#bg-video {
    min-width: 100% !important;
    min-height: 100% !important;
    object-fit: cover !important;
    opacity: 0.5 !important; 
    filter: grayscale(40%) sepia(20%) hue-rotate(90deg) !important; 
    display: block !important;
}
.video-overlay {
    position: absolute !important;
    top: 0 !important; left: 0 !important;
    width: 100% !important; height: 100% !important;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.8) 0%, rgba(241, 245, 249, 0.95) 100%) !important; 
    z-index: 1 !important;
}

/* =========================================
   HEADER & BRANDING
   ========================================= */
.theatre-logo {
    max-height: 52px !important;
    width: auto !important;
    object-fit: contain !important;
}

.stage-header {
    background: var(--surface) !important;
    border-bottom: 4px solid var(--primary) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 15px 3vw !important;
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; 
    gap: 15px;
}

.header-title {
    display: flex !important;
    align-items: center !important;
    gap: 16px !important;
    font-family: 'Playfair Display', serif !important;
    font-size: clamp(1.45rem, 2vw, 2.2rem) !important;
    font-weight: 900 !important;
    color: var(--text-primary) !important;
}

.hide-mobile {
    display: flex !important;
}

/* =========================================
   GLASS PANELS (CARDS)
   ========================================= */
.glass-panel, .kpi-card, .table-responsive {
    background: var(--surface) !important; 
    border: 3px solid var(--border-strong) !important;
    box-shadow: var(--shadow-lg) !important;
    color: var(--text-on-surface) !important; 
    border-radius: 20px !important;
    transition: transform 0.25s ease, border-color 0.25s ease !important;
    padding: 20px !important;
}

.glass-panel:hover {
    border-color: var(--text-primary) !important;
    transform: translateY(-2px);
}

.panel-title {
    color: var(--text-primary) !important;
    border-bottom: 2px dashed var(--primary) !important;
    font-family: 'Playfair Display', serif !important;
    padding-bottom: 12px !important;
    font-size: 1.4rem !important;
    font-weight: 900 !important;
}

/* =========================================
   PREMIUM TYPOGRAPHY
   ========================================= */
.kpi-label { 
    color: var(--text-primary) !important; 
    font-weight: 900 !important; 
    letter-spacing: 1px !important;
    text-transform: uppercase !important;
}

.kpi-value, .total-amt, .qty, .heavy-num {
    font-size: clamp(1.8rem, 2.5vw, 2.8rem) !important;
    color: var(--primary) !important; 
    font-family: 'Playfair Display', serif !important;
    font-weight: 900 !important;
    -webkit-text-stroke: 1px var(--text-primary) !important; 
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.2) !important; 
}

/* =========================================
   MOBILE OPTIMIZED TABLES (SWIPEABLE)
   ========================================= */
.table-responsive {
    width: 100%;
    overflow-x: auto !important; /* Enables horizontal scroll on mobile */
    -webkit-overflow-scrolling: touch !important;
}

table.data-table th {
    font-size: 1rem !important;
    background: var(--primary) !important;
    color: var(--text-inverse) !important;
    border-bottom: 3px solid var(--text-primary) !important;
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    padding: 12px !important;
    white-space: nowrap;
}

table.data-table td {
    font-size: 1rem !important;
    border-bottom: 2px dashed var(--primary) !important;
    color: var(--text-primary) !important;
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 800 !important;
    padding: 12px !important;
}

/* =========================================
   TOUCH-OPTIMIZED BUTTONS (MIN 48PX HEIGHT)
   ========================================= */
/* =========================================
   MOTION ANIMATION ENGINE
   ========================================= */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animated-entry {
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0; /* Starts hidden */
}
@keyframes gradient-border-pan {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.btn-primary, .btn-outline {
    min-height: 48px !important; /* Mobile accessibility standard */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 900 !important;
    text-transform: uppercase !important;
    border-radius: 12px !important;
    padding: 12px 24px !important;
    transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    position: relative;
    border: 2px solid transparent !important;
    background-clip: padding-box !important;
}
.btn-primary:active, .btn-outline:active {
    transform: scale(0.96) !important;
}

.btn-primary::before, .btn-outline::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 2px; /* Border thickness */
    background: linear-gradient(90deg, #FF007A, #8B5CF6, #00F2FE, #FF007A) !important;
    background-size: 300% 100% !important;
    animation: gradient-border-pan 4s linear infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 1;
}

.btn-primary {
    background: var(--primary) !important;
    color: var(--text-inverse) !important; 
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2) !important;
}
.btn-primary:hover {
    background: var(--text-primary) !important;
    color: var(--text-inverse) !important;
    transform: translateY(-3px) !important;
}

.btn-outline {
    background: transparent !important;
    color: var(--text-primary) !important;
}
.btn-outline:hover {
    background: var(--primary) !important;
    color: var(--text-inverse) !important;
}

/* =========================================
   TOUCH-OPTIMIZED INPUTS
   ========================================= */
.input-elegant {
    min-height: 48px !important; /* Mobile touch target */
    background: rgba(255, 255, 255, 0.5) !important; 
    border: 3px solid var(--primary) !important; 
    color: var(--text-primary) !important;
    border-radius: 12px !important;
    font-weight: 900 !important;
    padding: 12px 15px !important;
    width: 100%;
}
.input-elegant::placeholder { color: var(--primary) !important; opacity: 0.8 !important; }
.input-elegant:focus { background: var(--surface-hover) !important; box-shadow: 0 0 0 5px rgba(217, 177, 93, 0.3) !important; }

input[type="date"]::-webkit-datetime-edit, 
input[type="date"]::-webkit-datetime-edit-text,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
    color: var(--text-primary) !important;
    font-weight: 900 !important;
    opacity: 1 !important;
}

/* =========================================
   MOBILE SWIPEABLE TABS (CRITICAL SCROLL FIX)
   ========================================= */
.tab-bar {
    display: flex !important;
    flex-wrap: nowrap !important; /* Forces a single line on mobile */
    gap: 12px !important;
    overflow-x: auto !important; /* Enables horizontal swiping */
    -webkit-overflow-scrolling: touch !important; /* Smooth iOS scroll */
    padding-bottom: 10px !important; /* Space for scrollbar */
    scrollbar-width: none; /* Hide standard scrollbar Firefox */
}
.tab-bar::-webkit-scrollbar { display: none; /* Hide standard scrollbar Chrome/Safari */ }

.tab-btn {
    background: var(--text-inverse) !important;
    border: 3px solid var(--primary) !important;
    color: var(--text-primary) !important; 
    font-weight: 900 !important;
    border-radius: 50px !important;
    padding: 12px 24px !important;
    font-size: 0.95rem !important;
    box-shadow: var(--shadow-sm) !important;
    transition: 0.2s !important;
    white-space: nowrap !important; /* Prevents text breaking on small screens */
    flex-shrink: 0 !important; /* Prevents buttons from squishing */
}
.tab-btn:hover { background: var(--surface-hover) !important; transform: translateY(-2px) !important; }
.tab-btn.active {
    background: var(--primary) !important;
    border-color: var(--text-primary) !important;
    color: var(--text-inverse) !important; 
    box-shadow: var(--shadow-lg) !important;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.3s ease; }

/* =========================================
   APP SWITCHER (DESKTOP)
   ========================================= */
.dropdown-menu {
    background: var(--surface) !important;
    border: 3px solid var(--primary) !important;
    box-shadow: var(--shadow-lg) !important;
}
.dropdown-item {
    color: var(--text-primary) !important;
    border-bottom: 2px dashed var(--primary) !important;
    font-weight: 900 !important;
    padding: 15px 20px;
    display: flex;
    align-items: center;
}
.dropdown-item:hover {
    background: var(--chalk-bg) !important;
    padding-left: 25px !important;
    color: var(--primary) !important;
}

/* =========================================
   PAYMENT MODAL FIX (RESOLVES BLUR BUG)
   ========================================= */
.modal-overlay {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    background: rgba(0, 0, 0, 0.85) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000 !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.modal-content {
    background: var(--text-primary) !important;
    border: 4px solid var(--primary) !important;
    border-radius: var(--radius-lg) !important;
    padding: 30px !important;
    width: 90% !important;
    max-width: 600px !important;
    box-shadow: var(--shadow-heavy) !important;
    max-height: 85dvh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    position: relative !important;
    z-index: 10001 !important;
    /* CRITICAL FIXES FOR VISIBILITY */
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    margin: auto !important;
}

/* Status Badges */
.badge-green { background: var(--text-primary) !important; color: var(--text-inverse) !important; border: 2px solid var(--text-primary) !important; }
.badge-orange, .badge-amber { background: var(--text-inverse) !important; color: var(--primary) !important; border: 2px solid var(--primary) !important; }
.badge-red, .badge-blue { background: var(--primary) !important; color: var(--text-inverse) !important; border: 2px solid var(--primary) !important; }

/* Dynamic Global Footer Styling */
.aq-ar-footer { text-align: center; padding: 2.5rem 1rem; margin-top: 40px !important; font-size: 0.95rem; color: var(--text-inverse) !important; font-weight: 900; letter-spacing: 1px; clear: both; }
.aq-ar-footer .brand-name { font-family: 'Playfair Display', serif; font-style: italic; font-weight: 900; color: var(--text-inverse) !important; }

/* Fluid Grids */
.main-grid { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)) !important; gap: 20px !important; }
.kpi-grid, .chart-grid, .form-grid { display: grid !important; gap: 20px !important; }
.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)) !important; }
.chart-grid { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)) !important; }

/* =========================================
   RESPONSIVE OVERRIDES (TABLETS & MOBILE)
   ========================================= */
@media (max-width: 900px) {
    .hide-mobile { display: none !important; }
    
    .kpi-grid, .chart-grid, .form-grid, .main-grid {
        grid-template-columns: 1fr !important; 
    }
    
    .stage-header {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }

    /* APP SWITCHER MOBILE FIX */
    .dropdown-menu {
        min-width: 280px !important;
        width: max-content !important;
        right: 0 !important;
        left: auto !important;
        border-radius: 16px !important;
    }
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Premium PDF Print View Tweaks */
@media print {
    body * { visibility: hidden !important; }
    .print-section, .print-section * { visibility: visible !important; color: var(--text-primary) !important; background: var(--text-inverse) !important; box-shadow: none !important;}
    .print-section { position: absolute; left: 0; top: 0; width: 100%; }
    table.data-table { width: 100% !important; border-collapse: collapse !important; }
    table.data-table th, table.data-table td { border: 2px solid var(--text-primary) !important; padding: 8px !important; color: var(--text-primary) !important;}
    table.data-table th { background: var(--primary) !important; color: var(--text-inverse) !important; }
    .tab-bar, .stage-header, button, .no-print, .aq-ar-footer, .video-bg-wrapper { display: none !important; }
}

/* =========================================
   PHASE 3: DESIGN ELEVATION
   Premium Features: Skeletons, Micro-animations, Glass Pro
   ========================================= */

/* 1. SKELETON LOADERS */
@keyframes skeletonShimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}
.skeleton-box {
    background: #e2e8f0;
    background-image: linear-gradient(90deg, #e2e8f0 0px, #f8fafc 100px, #e2e8f0 200px);
    background-size: 2000px 100%;
    animation: skeletonShimmer 2s infinite linear;
    border-radius: var(--radius);
    opacity: 0.6;
}
.skeleton-text {
    height: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    background: #e2e8f0;
    background-image: linear-gradient(90deg, #e2e8f0 0px, #f8fafc 100px, #e2e8f0 200px);
    background-size: 2000px 100%;
    animation: skeletonShimmer 2s infinite linear;
}

/* 2. MICRO-ANIMATIONS */
.tap-bounce {
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.tap-bounce:active {
    transform: scale(0.96) !important;
}
.hover-lift {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease !important;
}
.hover-lift:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important;
}

/* 3. GLASSMORPHISM PRO */
.glass-panel-pro {
    background: rgba(255, 255, 255, 0.75) !important;
    backdrop-filter: blur(30px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(30px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    box-shadow: 
        0 4px 6px rgba(0,0,0,0.02),
        0 15px 35px rgba(0,0,0,0.05),
        inset 0 1px 0 rgba(255,255,255,0.6) !important;
    border-radius: 24px !important;
}

/* Toast Container Upgrade */
#toast-container {
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
}
.toast-pro {
    animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: top right;
}
@keyframes toastSlideIn {
    0% { transform: translateX(120%) scale(0.95); opacity: 0; }
    100% { transform: translateX(0) scale(1); opacity: 1; }
}
/* =========================================
   STAGGERED CASCADING ENTRANCES
   ========================================= */
.data-table tbody tr, .item-card-pro, .shift-audit-card {
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}
.data-table tbody tr:nth-child(1), .item-card-pro:nth-child(1), .shift-audit-card:nth-child(1) { animation-delay: 0.05s; }
.data-table tbody tr:nth-child(2), .item-card-pro:nth-child(2), .shift-audit-card:nth-child(2) { animation-delay: 0.10s; }
.data-table tbody tr:nth-child(3), .item-card-pro:nth-child(3), .shift-audit-card:nth-child(3) { animation-delay: 0.15s; }
.data-table tbody tr:nth-child(4), .item-card-pro:nth-child(4), .shift-audit-card:nth-child(4) { animation-delay: 0.20s; }
.data-table tbody tr:nth-child(5), .item-card-pro:nth-child(5), .shift-audit-card:nth-child(5) { animation-delay: 0.25s; }
.data-table tbody tr:nth-child(6), .item-card-pro:nth-child(6), .shift-audit-card:nth-child(6) { animation-delay: 0.30s; }
.data-table tbody tr:nth-child(7), .item-card-pro:nth-child(7), .shift-audit-card:nth-child(7) { animation-delay: 0.35s; }
.data-table tbody tr:nth-child(n+8), .item-card-pro:nth-child(n+8), .shift-audit-card:nth-child(n+8) { animation-delay: 0.40s; }

/* Tactile Physics */
.item-card-pro:hover, .shift-audit-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 25px rgba(0,0,0,0.1) !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
