/* L'Occhio del Padrone - Custom Styles */

:root {
    --primary: #1e3a8a;
    --secondary: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --sidebar-width: 280px;
    --mobile-header-height: 56px;
}

/* Global Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8fafc;
}

/* Layout Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar - Desktop */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary) 0%, #1e293b 100%);
    color: white;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    background-color: rgba(0, 0, 0, 0.2);
}

.sidebar-nav {
    padding-top: 1rem;
}

/* Navigation Links */
.nav-link-custom {
    color: rgba(255, 255, 255, 0.8);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.nav-link-custom:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(4px);
}

.nav-link-custom.active {
    background-color: var(--secondary);
    color: white;
    font-weight: 600;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
}

.page-content {
    padding: 2rem;
}

/* KPI Cards */
.kpi-card {
    border: none;
    border-radius: 0.75rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
}

/* Functional Area Cards */
.functional-area-card {
    border: none;
    border-radius: 0.75rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.functional-area-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(30, 58, 138, 0.2) !important;
}

.hover-lift {
    transition: transform 0.3s ease;
}

/* Mobile Header (hidden on desktop) */
.mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Hamburger menu button styling */
.mobile-header .navbar-toggler,
#mobile-menu-toggle {
    border: none;
    color: white;
    font-size: 1.5rem;
    min-height: 44px;
    min-width: 44px;
    padding: 0.5rem;
    background: transparent;
}

.mobile-header .navbar-toggler:hover,
#mobile-menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

.mobile-header .navbar-toggler:focus,
#mobile-menu-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

/* Mobile Drawer */
.offcanvas.bg-dark {
    background: linear-gradient(180deg, var(--primary) 0%, #1e293b 100%) !important;
}

/* Desktop: Hide mobile components, show sidebar */
@media (min-width: 769px) {
    .mobile-header {
        display: none !important;
    }

    .sidebar {
        display: block;
    }

    .main-content {
        margin-left: var(--sidebar-width);
    }
}

/* Mobile: Hide sidebar, show mobile header */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        display: none;
    }

    .main-content {
        margin-left: 0;
        margin-top: var(--mobile-header-height);
        width: 100%;
    }

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

    .page-content {
        padding: 1rem;
    }

    /* Stack KPI cards vertically on mobile - 1 column */
    .kpi-card {
        margin-bottom: 1rem;
        padding: 0.75rem !important;
    }

    /* Force KPI cards to full width on mobile */
    .kpi-card .col, .kpi-card [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Adjust font sizes for mobile */
    h1 {
        font-size: 1.75rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.35rem !important;
    }

    h4 {
        font-size: 1.25rem !important;
    }

    h5 {
        font-size: 1.1rem !important;
    }

    h6 {
        font-size: 1rem !important;
    }

    /* Reduce chart heights on mobile */
    .chart-container, div[id*="chart"], div[id*="graph"] {
        min-height: 300px !important;
        height: 300px !important;
    }

    /* Ensure charts fit properly */
    .js-plotly-plot {
        max-height: 300px !important;
    }

    /* Touch-friendly buttons - minimum 44x44px */
    .btn, button, .nav-link, a.btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem !important;
        font-size: 1rem;
    }

    /* Smaller padding for icon-only buttons */
    .btn-icon, .navbar-toggler {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem !important;
    }

    /* Touch-friendly dropdowns and selectors */
    .form-select, .form-control, select, input {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }

    /* Hide long breadcrumbs on mobile */
    .breadcrumb {
        display: none;
    }

    /* Hide secondary text/descriptions on mobile */
    .hide-mobile, .text-muted.small {
        display: none !important;
    }

    /* Reduce card padding on mobile */
    .card-body {
        padding: 1rem !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
    }

    /* Stack columns vertically on mobile */
    .row > [class*="col-"] {
        margin-bottom: 1rem;
    }

    /* Reduce margins between sections */
    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    /* Better table display on mobile */
    .table {
        font-size: 0.875rem;
    }

    .table thead {
        font-size: 0.75rem;
    }

    /* Smooth scrolling for mobile */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    /* Optimize performance for animations */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    /* Better spacing for alerts on mobile */
    .alert {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    /* Reduce navbar brand size on mobile */
    .navbar-brand {
        font-size: 1rem !important;
    }

    /* Navigation links touch-friendly in drawer */
    .offcanvas .nav-link-custom {
        min-height: 44px;
        padding: 0.875rem 1rem !important;
        font-size: 1rem;
    }

    /* Enable pinch-to-zoom for charts */
    .js-plotly-plot .plotly {
        touch-action: auto !important;
    }

    /* Better spacing for export buttons on mobile */
    .btn-group-vertical .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Optimize functional area cards for mobile */
    .functional-area-card {
        margin-bottom: 1rem;
    }

    .functional-area-card:hover {
        transform: translateY(-2px) !important;
    }

    /* Better visibility for hover states on touch */
    .functional-area-card:active {
        transform: translateY(0) !important;
        opacity: 0.9;
    }

    /* Ensure proper spacing for modals on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    /* Better list spacing on mobile */
    ul, ol {
        padding-left: 1.25rem;
    }

    /* Optimize tab navigation for mobile */
    .nav-tabs .nav-link {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    /* Better performance for transitions on mobile */
    .kpi-card, .functional-area-card {
        transition: transform 0.15s ease !important;
    }
}

/* Tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .page-content {
        padding: 1.5rem;
    }
}

/* Alerts */
.alert {
    border-radius: 0.5rem;
    border: none;
}

/* Cards */
.card {
    border: none;
}

.card-header {
    background-color: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: #1e40af;
    border-color: #1e40af;
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Loading states */
._dash-loading {
    opacity: 0.6;
}

/* Utility classes */
.shadow-sm {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

.text-white-50 {
    color: rgba(255, 255, 255, 0.5) !important;
}
