/**
 * AutoParts Pro CEO Dashboard
 * Responsive Styles
 * EDESSIS SRL - 2026
 */

/* ===== MOBILE FIRST (BASE) ===== */
/* Already defined in other files */

/* ===== SMALL PHONES (320px - 374px) ===== */
@media (max-width: 374px) {
    :root {
        --fs-xs: 8px;
        --fs-sm: 9px;
        --fs-base: 11px;
        --fs-md: 12px;
        --fs-lg: 13px;
        --fs-xl: 14px;
        --fs-2xl: 15px;
        --fs-3xl: 16px;
        --fs-4xl: 18px;
        --fs-5xl: 22px;
        --fs-6xl: 30px;
    }
    
    .page {
        padding: 0 var(--sp-4);
    }
    
    .hero {
        padding: var(--sp-8);
        border-radius: var(--radius-4xl);
    }
    
    .kpi-card {
        min-width: 130px;
        padding: var(--sp-5);
    }
    
    .kpi-value {
        font-size: var(--fs-3xl);
    }
    
    .quick-actions {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--sp-2);
    }
    
    .quick-action {
        padding: var(--sp-4) var(--sp-1);
    }
    
    .quick-action i {
        font-size: 18px;
    }
    
    .stat-grid {
        gap: var(--sp-3);
    }
    
    .stat-box {
        padding: var(--sp-5);
    }
    
    .stat-box .stat-value {
        font-size: 18px;
    }
    
    .section-header h3 {
        font-size: var(--fs-lg);
    }
    
    .card-header h4 {
        font-size: var(--fs-md);
    }
    
    .bottom-nav-center {
        width: 50px;
        height: 50px;
        font-size: 20px;
        top: -26px;
    }
}

/* ===== MEDIUM PHONES (375px - 413px) ===== */
@media (min-width: 375px) and (max-width: 413px) {
    .kpi-card {
        min-width: 140px;
    }
    
    .quick-actions {
        gap: var(--sp-3);
    }
}

/* ===== LARGE PHONES (414px - 479px) ===== */
@media (min-width: 414px) and (max-width: 479px) {
    .kpi-card {
        min-width: 155px;
    }
    
    .stat-grid {
        gap: var(--sp-4);
    }
    
    .quick-actions {
        gap: var(--sp-4);
    }
}

/* ===== PHABLETS (480px - 599px) ===== */
@media (min-width: 480px) {
    :root {
        --topbar-height: 64px;
        --bottomnav-height: 70px;
    }
    
    .page {
        padding: 0 var(--sp-8);
    }
    
    .hero {
        padding: var(--sp-10) var(--sp-9);
    }
    
    .kpi-scroll {
        margin: 0;
        padding: 0 0 var(--sp-3);
    }
    
    .kpi-card {
        min-width: 160px;
        padding: var(--sp-8);
    }
    
    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .sales-summary {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== TABLETS PORTRAIT (600px - 767px) ===== */
@media (min-width: 600px) {
    :root {
        --fs-xs: 10px;
        --fs-sm: 11px;
        --fs-base: 13px;
        --fs-md: 14px;
        --fs-lg: 15px;
        --fs-xl: 16px;
        --fs-2xl: 18px;
        --fs-3xl: 20px;
        --fs-4xl: 24px;
        --fs-5xl: 28px;
        --fs-6xl: 40px;
        
        --sp-6: 16px;
        --sp-7: 18px;
        --sp-8: 20px;
        --sp-9: 24px;
        --sp-10: 28px;
    }
    
    .container {
        max-width: 580px;
    }
    
    .kpi-scroll {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: var(--sp-4);
        overflow: visible;
    }
    
    .kpi-card {
        min-width: unset;
    }
    
    .quick-actions {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .invoice-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--sp-4);
    }
    
    .report-card {
        display: flex;
        align-items: center;
    }
    
    .report-card-header {
        flex: 1;
        margin-bottom: 0;
    }
    
    .settings-card {
        max-width: 500px;
        margin: 0 auto;
    }
}

/* ===== TABLETS LANDSCAPE (768px - 1023px) ===== */
@media (min-width: 768px) {
    :root {
        --sidebar-width: 300px;
        --max-content-width: 720px;
    }
    
    .page-wrapper {
        padding-bottom: var(--sp-10);
    }
    
    /* Show sidebar by default on tablets */
    .sidebar {
        transform: translateX(0);
        position: fixed;
    }
    
    .sidebar-overlay {
        display: none;
    }
    
    /* Adjust main content */
    .main-content {
        margin-left: var(--sidebar-width);
    }
    
    /* Hide bottom nav on tablets */
    .bottom-nav {
        display: none;
    }
    
    /* Adjust topbar */
    .topbar {
        left: var(--sidebar-width);
    }
    
    .topbar-btn.menu-toggle {
        display: none;
    }
    
    .kpi-scroll {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .invoice-list {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .report-card-content {
        gap: var(--sp-6);
    }
    
    .profile-stats {
        max-width: 400px;
        margin: var(--sp-6) auto;
    }
}

/* ===== SMALL DESKTOPS (1024px - 1279px) ===== */
@media (min-width: 1024px) {
    :root {
        --max-content-width: 960px;
        --sidebar-width: 280px;
    }
    
    .container {
        max-width: 900px;
    }
    
    .kpi-scroll {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .invoice-list {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .dashboard-grid {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: var(--sp-6);
    }
    
    .dashboard-main {
        grid-column: 1;
    }
    
    .dashboard-sidebar {
        grid-column: 2;
    }
}

/* ===== LARGE DESKTOPS (1280px+) ===== */
@media (min-width: 1280px) {
    :root {
        --max-content-width: 1200px;
    }
    
    .container {
        max-width: 1140px;
    }
    
    .product-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .invoice-list {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .topbar-btn,
    .bottom-nav-item,
    .sidebar-item,
    .filter-btn,
    .chip,
    .tab {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Disable hover effects on touch */
    .card:hover,
    .product-card:hover,
    .invoice-item:hover,
    .settings-item:hover {
        transform: none;
    }
    
    /* Active states for touch */
    .card:active,
    .product-card:active,
    .invoice-item:active,
    .settings-item:active {
        transform: scale(0.98);
        opacity: 0.9;
    }
}

/* ===== HOVER DEVICE OPTIMIZATIONS ===== */
@media (hover: hover) and (pointer: fine) {
    .topbar-btn:hover {
        background: var(--p);
        color: #fff;
    }
    
    .card:hover {
        border-color: var(--p);
    }
    
    .product-card:hover,
    .invoice-item:hover,
    .report-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }
    
    .settings-item:hover {
        background: var(--bg3);
    }
    
    .filter-btn:hover:not(.active) {
        background: var(--bg4);
        color: var(--tx);
    }
    
    .quick-action:hover {
        transform: translateY(-3px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    }
}

/* ===== LANDSCAPE ORIENTATION ===== */
@media (orientation: landscape) and (max-height: 500px) {
    .page-wrapper {
        padding-top: calc(var(--topbar-height) + var(--sp-2));
    }
    
    .hero {
        padding: var(--sp-6);
    }
    
    .section-header {
        margin: var(--sp-6) 0 var(--sp-4);
    }
    
    .kpi-scroll {
        gap: var(--sp-3);
    }
    
    .kpi-card {
        padding: var(--sp-5);
    }
}

/* ===== HIGH RESOLUTION SCREENS ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper borders */
    .card,
    .kpi-card,
    .product-card,
    .settings-card {
        border-width: 0.5px;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .page {
        animation: none;
    }
    
    .sidebar,
    .notif-panel {
        transition: none;
    }
}

/* ===== DARK MODE SYSTEM PREFERENCE ===== */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        /* Apply dark theme variables when no theme is set */
        color-scheme: dark;
    }
}

/* ===== LIGHT MODE SYSTEM PREFERENCE ===== */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        color-scheme: light;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .topbar,
    .sidebar,
    .bottom-nav,
    .notif-panel,
    .sidebar-overlay,
    .notif-panel-overlay {
        display: none !important;
    }
    
    .page-wrapper {
        padding: 0;
    }
    
    .page {
        display: block !important;
        padding: 0;
    }
    
    .card,
    .kpi-card,
    .product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    body {
        background: #fff;
        color: #000;
    }
    
    a {
        text-decoration: underline;
    }
}

/* ===== SAFE AREAS (NOTCHED DEVICES) ===== */
@supports (padding-top: env(safe-area-inset-top)) {
    .topbar {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--topbar-height) + env(safe-area-inset-top));
    }
    
    .page-wrapper {
        padding-top: calc(var(--topbar-height) + env(safe-area-inset-top) + var(--sp-3));
    }
    
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--bottomnav-height) + env(safe-area-inset-bottom));
    }
    
    .sidebar {
        padding-top: env(safe-area-inset-top);
    }
}