/* style.css */
:root {
    --primary: #2563EB;
    --primary-light: #EFF6FF;
    --text-main: #111827;
    --text-sub: #6B7280;
    --bg: #F9FAFB;
    --white: #FFFFFF;
    --border: #E5E7EB;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', system-ui, sans-serif; }

body { background: var(--bg); color: var(--text-main); min-height: 100vh; }

/* Disable scrolling when menu is active on mobile */
.no-scroll {
    overflow: hidden !important;
    height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 1100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.close-sidebar {
    display: none;
    position: absolute;
    right: 20px;
    top: 25px;
    background: var(--bg);
    border: none;
    padding: 5px;
    border-radius: 6px;
    cursor: pointer;
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.logo-box { background: var(--primary); color: white; padding: 6px 12px; border-radius: 8px; font-weight: 800; }
.brand-name { font-size: 1.2rem; font-weight: 700; color: var(--text-main); }

.side-nav { flex: 1; }
.side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    color: var(--text-sub);
    text-decoration: none;
    font-weight: 500;
    border-radius: 8px;
    margin-bottom: 4px;
    transition: 0.2s;
}
.side-link i { width: 18px; height: 18px; }
.side-link.active, .side-link:hover { background: var(--primary-light); color: var(--primary); }
hr { border: 0; border-top: 1px solid var(--border); margin: 15px 0; }

.user-card { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg); border-radius: 12px; }
.avatar { width: 40px; height: 40px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; }

/* --- CONTENT --- */
/* --- FIXED CONTENT BLOCK --- */
.content { 
    margin-left: 260px; /* This matches your sidebar width */
    padding: 40px; 
    transition: 0.3s;
    display: block; /* Ensures it doesn't inherit flex behavior */
    width: auto;    /* Allows it to fill the remaining space naturally */
}

/* Fix for the header to ensure it stays wide inside the content */
.header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 30px; 
    width: 100%; 
}
.header h1 { font-size: 1.75rem; font-weight: 800; }
.header p { color: var(--text-sub); }
.header-right { display: flex; gap: 15px; align-items: center; }

.menu-toggle {
    display: none;
    background: var(--white);
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    margin-right: 10px;
}

.btn { padding: 10px 20px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.icon-btn { padding: 8px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-sub); cursor: pointer; }

/* --- GRIDS & CARDS --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--white); padding: 24px; border-radius: 16px; border: 1px solid var(--border); }
.stat-label { color: var(--text-sub); font-size: 0.85rem; margin-bottom: 8px; }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.stat-trend { font-size: 0.75rem; font-weight: 600; }
.stat-trend.positive { color: var(--success); }
.stat-trend.negative { color: var(--error); }

.main-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.card { background: var(--white); padding: 24px; border-radius: 16px; border: 1px solid var(--border); }
.card-header { margin-bottom: 20px; }
.full-width { grid-column: span 2; }

/* Chart Bars */
.chart-container { height: 200px; display: flex; align-items: flex-end; padding-top: 20px; }
.bar-chart { display: flex; width: 100%; height: 100%; justify-content: space-around; align-items: flex-end; border-bottom: 1px solid var(--border); }
.bar { width: 40px; background: var(--primary-light); border-radius: 6px 6px 0 0; position: relative; }
.bar::after { content: attr(data-name); position: absolute; bottom: -25px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--text-sub); }
.bar.active { background: var(--primary); }

/* Projects List */
.project-list { display: flex; flex-direction: column; gap: 15px; }
.proj-info { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 5px; font-weight: 500; }
.proj-bar { height: 8px; background: var(--bg); border-radius: 10px; overflow: hidden; }
.fill { height: 100%; background: var(--primary); }
.fill.warning { background: var(--warning); }

/* Table */
.table-scroll { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 500px; }
.table th { text-align: left; padding: 12px; color: var(--text-sub); font-size: 0.8rem; border-bottom: 1px solid var(--border); text-transform: uppercase; }
.table td { padding: 16px 12px; font-size: 0.9rem; border-bottom: 1px solid var(--border); }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: #DCFCE7; color: var(--success); }
.badge-pending { background: #FEF3C7; color: var(--warning); }
.badge-error { background: #FEE2E2; color: var(--error); }

/* Overlay */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
    z-index: 1050;
}

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
    .main-grid { grid-template-columns: 1fr; }
    .full-width { grid-column: span 1; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); box-shadow: 10px 0 40px rgba(0,0,0,0.1); }
    .close-sidebar { display: block; }
    .content { margin-left: 0; padding: 20px; }
    .menu-toggle { display: block; }
    .overlay.active { display: block; }
    .header { flex-direction: column; align-items: flex-start; gap: 15px; }
    .header-right { width: 100%; justify-content: flex-start; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .bar { width: 25px; }
}

/* Bons de commande */
        /* --- SMOOTH MODAL & PREMIUM INPUTS --- */
        .modal {
            display: none; 
            position: fixed; 
            inset: 0; 
            background: rgba(15, 23, 42, 0.6); 
            backdrop-filter: blur(8px); 
            z-index: 2000; 
            justify-content: center; 
            align-items: center; 
            padding: 20px;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .modal.active { 
            display: flex; 
            opacity: 1;
        }

        .modal-content {
            background: #fff; 
            width: 100%; 
            max-width: 700px;
            border-radius: 24px; 
            box-shadow: 0 25px 50px -12px rgba(0,0,0,0.3);
            overflow: hidden;
            transform: scale(0.9) translateY(20px);
            transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

        .modal.active .modal-content {
            transform: scale(1) translateY(0);
        }

        .form-input {
            width: 100%; 
            padding: 14px 18px; 
            background: #fcfcfd;
            border: 1.5px solid #e2e8f0; 
            border-radius: 12px;
            font-size: 0.95rem; 
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .form-input:focus {
            outline: none; 
            border-color: #2563EB;
            background: #fff;
            box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
        }

        /* Prevent scroll when modal is open */
        .no-scroll { overflow: hidden; }
        
        /* Table and layout consistency */
        .action-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
        .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

        /* Bon de livraison */
        /* --- BL SPECIFIC STYLES --- */
.upload-zone {
    border: 2px dashed #e2e8f0;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    background: #f8fafc;
    cursor: pointer;
    transition: 0.2s;
}
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }

.comparison-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 10px;
}

.status-pill { padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; }
.status-ok { background: #dcfce7; color: #166534; }
.status-missing { background: #fee2e2; color: #991b1b; }
.status-excess { background: #fef3c7; color: #92400e; }

/* Projets */
/* --- PROJECT SPECIFIC STYLES --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }

.timeline { position: relative; padding-left: 30px; border-left: 2px solid var(--border); margin-top: 20px; }
.timeline-item { position: relative; margin-bottom: 30px; }
.timeline-item::before { 
    content: ''; position: absolute; left: -39px; top: 0; 
    width: 16px; height: 16px; border-radius: 50%; 
    background: var(--white); border: 3px solid var(--primary); 
}

.progress-container { width: 100%; background: #e2e8f0; border-radius: 10px; height: 10px; margin-top: 8px; }
.progress-bar { height: 100%; border-radius: 10px; background: var(--primary); transition: 0.3s; }

/* rapports */
        .report-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 25px; margin-top: 25px; }
        .filter-bar { display: flex; gap: 15px; background: white; padding: 20px; border-radius: 18px; border: 1px solid #e2e8f0; margin-bottom: 25px; align-items: flex-end; }
        .stat-mini-card { background: #f8fafc; padding: 15px; border-radius: 14px; border: 1px solid #e2e8f0; }
        .chart-container { position: relative; height: 300px; width: 100%; }
        
        /* Premium Features */
        .kpi-trend { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 12px; margin-left: 8px; }
        .trend-up { background: #dcfce7; color: #166534; }
        .trend-down { background: #fee2e2; color: #991b1b; }

        /* Projets */
            /* Cinematic Modal Logic */
        .modal {
            display: none; position: fixed; inset: 0; 
            background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(10px); 
            z-index: 2000; justify-content: center; align-items: center; 
            padding: 20px; opacity: 0; transition: opacity 0.3s ease;
        }
        .modal.active { display: flex; opacity: 1; }
        .modal-content {
            background: #fff; width: 100%; max-width: 750px;
            border-radius: 28px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4);
            overflow: hidden; transform: scale(0.92) translateY(30px);
            transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        }
        .modal.active .modal-content { transform: scale(1) translateY(0); }

        /* Stats & Progress */
        .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 25px; }
        .progress-container { width: 100%; background: #f1f5f9; border-radius: 10px; height: 8px; margin: 15px 0; }
        .progress-bar { height: 100%; border-radius: 10px; background: #2563EB; transition: 0.3s; }
        
        .project-card { 
            transition: all 0.3s ease; 
            cursor: pointer; 
            border: 1px solid #e2e8f0;
        }
        .project-card:hover { 
            transform: translateY(-5px); 
            box-shadow: 0 10px 20px rgba(0,0,0,0.05);
            border-color: #2563EB;
        }

        .form-label { font-weight: 700; font-size: 0.8rem; color: #475569; text-transform: uppercase; margin-bottom: 8px; display: block; }
        .no-scroll { overflow: hidden; }

        /* Fournisseurs */
                .perf-badge { padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
        .perf-good { background: #dcfce7; color: #166534; }
        .perf-warning { background: #fef3c7; color: #92400e; }
        .perf-risk { background: #fee2e2; color: #991b1b; }
        
        .contact-pill { background: #f1f5f9; color: #475569; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; margin-right: 4px; border: 1px solid #e2e8f0; }

        /* fournisseur */
                /* Specific Detail Styles */
        .detail-header {
            background: white;
            padding: 30px;
            border-radius: 24px;
            border: 1px solid #e2e8f0;
            margin-bottom: 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .kpi-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 20px;
            margin-bottom: 30px;
        }

        .kpi-card {
            background: white;
            padding: 24px;
            border-radius: 20px;
            border: 1px solid #e2e8f0;
            position: relative;
            overflow: hidden;
        }

        .kpi-card::after {
            content: '';
            position: absolute;
            top: 0; left: 0; width: 4px; height: 100%;
        }

        .kpi-success::after { background: #10b981; }
        .kpi-warning::after { background: #f59e0b; }
        .kpi-danger::after { background: #ef4444; }
        .kpi-primary::after { background: #1F4FD8; }

        .main-layout {
            display: grid;
            grid-template-columns: 350px 1fr;
            gap: 30px;
        }

        .contact-item {
            padding: 16px;
            border-radius: 12px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            margin-bottom: 12px;
        }

        .contact-item.primary {
            border-color: #1F4FD8;
            background: #f0f4ff;
        }

        .status-dot {
            height: 8px; width: 8px; border-radius: 50%; display: inline-block; margin-right: 6px;
        }

        /* Tabs for History */
        .history-tabs {
            display: flex;
            gap: 20px;
            border-bottom: 1px solid #e2e8f0;
            margin-bottom: 20px;
        }
        .tab-link {
            padding: 12px 0;
            font-weight: 700;
            color: #64748b;
            cursor: pointer;
            border-bottom: 2px solid transparent;
        }
        .tab-link.active {
            color: #1F4FD8;
            border-color: #1F4FD8;
        }

        /* Couts */
                :root {
            --primary: #1F4FD8;
            --danger: #ef4444;
            --warning: #f59e0b;
            --success: #10b981;
            --text-main: #0f172a;
            --text-sub: #64748b;
            --border: #e2e8f0;
        }

body { 
    background: var(--bg); 
    color: var(--text-main); 
    min-height: 100vh;
    display: block !important; /* Force it to NOT be flex */
    width: 100%;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    /* 1. Move the sidebar off-screen */
    .sidebar {
        transform: translateX(-100%);
        width: 280px; /* Slightly wider for better touch targets */
    }

    /* 2. When sidebar has the 'active' class, slide it in */
    .sidebar.active {
        transform: translateX(0);
    }

    /* 3. REMOVE the margin so content takes the full screen */
    .content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 20px; /* Less padding for small screens */
    }

    /* 4. Stack the stats-grid in 1 column instead of 4 */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* 5. Stack the main-grid (Chart + Project list) */
    .main-grid {
        grid-template-columns: 1fr !important;
    }

    /* 6. Make the header stack vertically */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

        /* --- LAYOUT --- */
        .main-container { margin-left: 280px; padding: 40px; }
        .header-flex { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; }
        
        /* --- KPI CARDS --- */
        .kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 30px; }
        .kpi-card { background: white; padding: 24px; border-radius: 20px; border: 1px solid var(--border); position: relative; }
        .kpi-card label { font-size: 0.8rem; font-weight: 600; color: var(--text-sub); display: block; margin-bottom: 8px; }
        .kpi-card .value { font-size: 1.6rem; font-weight: 900; letter-spacing: -0.03em; }
        .trend { font-size: 0.75rem; font-weight: 700; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
        .trend.up { color: var(--danger); }
        .trend.down { color: var(--success); }

        /* --- SECTIONS --- */
        .dashboard-row { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-bottom: 30px; }
        .glass-card { background: white; border-radius: 24px; border: 1px solid var(--border); padding: 30px; }
        .section-title { font-size: 1rem; font-weight: 800; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }

        /* --- COST BARS --- */
        .chantier-row { margin-bottom: 20px; }
        .chantier-meta { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.9rem; }
        .progress-track { height: 10px; background: #f1f5f9; border-radius: 5px; overflow: hidden; position: relative; }
        .progress-fill { height: 100%; border-radius: 5px; }

        /* --- CEMENT LOGIC BOX --- */
        .logic-box { background: #f0f7ff; border: 1px solid #bfdbfe; border-radius: 16px; padding: 20px; margin-top: 20px; }
        .loss-calc { display: flex; justify-content: space-between; align-items: center; background: white; padding: 15px; border-radius: 12px; margin-top: 10px; border: 1px solid #dbeafe; }

        /* --- FORMS & TABLES --- */
        .filter-bar { display: flex; gap: 12px; margin-bottom: 20px; }
        .form-input { padding: 10px 15px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.9rem; width: 100%; }
        
        /* --- BADGES --- */
        .badge { padding: 4px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; }
        .badge-ok { background: #dcfce7; color: #166534; }
        .badge-warn { background: #fef3c7; color: #92400e; }
        .badge-error { background: #fee2e2; color: #991b1b; }

        /* CSS POPUP */


/* --- TOAST NOTIFICATION SYSTEM --- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    min-width: 320px;
    background: white;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 20px 25px -5px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
    transform: translateX(0);
}

.toast-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-content {
    flex-grow: 1;
}

.toast-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: #0f172a;
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.85rem;
    color: #64748b;
}

/* --- TOAST VARIANTS --- */
.toast-success .toast-icon { background: #ecfdf5; color: #10b981; }
.toast-error .toast-icon { background: #fef2f2; color: #ef4444; }
.toast-info .toast-icon { background: #eff6ff; color: #1f4fd8; }

.toast-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
}


/* --- Verify CSS --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
:root { --primary: #1F4FD8; --primary-bg: #eff6ff; --slate-900: #0f172a; --slate-500: #64748b; --slate-200: #e2e8f0; --white: #ffffff; }
* { box-sizing: border-box; transition: all 0.2s ease; }
body { margin: 0; font-family: 'Inter', sans-serif; display: grid; grid-template-columns: 1.2fr 1fr; min-height: 100vh; background: var(--white); }
.brand-side { background-color: var(--slate-900); padding: 60px; display: flex; flex-direction: column; justify-content: space-between; color: white; }
.logo-area { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.4rem; }
.logo-icon { width: 40px; height: 40px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.form-side { display: flex; align-items: center; justify-content: center; padding: 40px; background: #fcfcfd; }
.form-container { width: 100%; max-width: 480px; }
.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; color: var(--slate-900); }
.field-box { display: flex; align-items: center; background: var(--white); border: 1.5px solid var(--slate-200); border-radius: 14px; overflow: hidden; height: 52px; }
.field-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-bg); }
.icon-prefix { width: 50px; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--slate-400); background: #f8fafc; border-right: 1.5px solid var(--slate-200); }
.field-box input { flex: 1; border: none; height: 100%; padding: 0 16px; font-size: 0.95rem; outline: none; background: transparent; }
.btn-login { width: 100%; height: 56px; background: var(--primary); color: white; border: none; border-radius: 14px; font-size: 1rem; font-weight: 700; cursor: pointer; margin-top: 10px; }
.errors { color: red; margin-bottom: 15px; font-size: 0.9rem; }
@media (max-width: 1024px) { body { grid-template-columns: 1fr; } .brand-side { display: none; } }


