:root { 
    --main-color: #A32226;
    --secondary-color: #2D3436;
    --bg-body: #f0f2f5;
    --glass: rgba(255, 255, 255, 0.95);
    --shadow-sm: 0 4px 6px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 30px rgba(0,0,0,0.08);
    --radius: 12px;
}
body { 
    background: var(--bg-body); 
    font-family: 'Outfit', sans-serif; 
    font-size: 0.9rem; 
    color: #2D3436;
}

/* Sidebar Glassmorphism */
.config-panel { 
    background: var(--glass); 
    backdrop-filter: blur(10px);
    padding: 24px; 
    border-radius: var(--radius); 
    box-shadow: var(--shadow-md); 
    height: calc(100vh - 40px); 
    overflow-y: auto; 
    position: sticky; 
    top: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

@media (max-width: 1200px) {
    .config-panel {
        position: static;
        height: auto;
        margin-bottom: 20px;
    }
}

.section-title { 
    font-size: 0.7rem; 
    font-weight: 800; 
    color: #636e72; 
    text-transform: uppercase; 
    letter-spacing: 1px;
    border-bottom: 2px solid #f1f2f6; 
    margin-bottom: 20px; 
    padding-bottom: 8px; 
}

/* Inputs refined */
.form-control, .form-select {
    border: 1px solid #dfe6e9;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.form-control:focus {
    border-color: var(--main-color);
    box-shadow: 0 0 0 3px rgba(163, 34, 38, 0.1);
}

/* Page de Devis (A4) */
.preview-page { 
    background: white; 
    width: 210mm; 
    min-height: 297mm; 
    padding: 20mm; 
    margin: auto; 
    box-shadow: var(--shadow-md); 
    color: #2d3436; 
    border-radius: 4px;
    transform-origin: top center;
}

@media (max-width: 992px) {
    .preview-page {
        margin-top: 20px;
        /* Approximation du redimensionnement pour tablettes/mobiles */
        zoom: 0.8; 
    }
}

@media (max-width: 768px) {
    .preview-page {
        zoom: 0.45;
        padding: 10mm;
    }
}

@media (max-width: 480px) {
    .preview-page {
        zoom: 0.38;
    }
}
.invoice-header { 
    border-bottom: 4px solid var(--main-color); 
    padding-bottom: 20px; 
    margin-bottom: 40px; 
}

/* Table Styles */
.table-devis { border-radius: 8px; overflow: hidden; border: none; }
.table-devis thead { background: #f8f9fa; border-bottom: 2px solid #eee; }
.table-devis th { 
    text-transform: uppercase; 
    font-size: 0.7rem; 
    letter-spacing: 0.5px; 
    color: #636e72; 
    border: none;
    padding: 15px;
}
.table-devis td { border: none; border-bottom: 1px solid #f1f2f6; padding: 15px; }

@media (max-width: 768px) {
    .table-devis th, .table-devis td { padding: 8px 5px; font-size: 0.8rem; }
}

/* Totaux Box */
.totals-box { width: 300px; float: right; margin-top: 30px; }
.total-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f1f2f6; }
.total-final { 
    background: var(--main-color); 
    color: white; 
    padding: 20px; 
    margin-top: 10px; 
    border-radius: 8px; 
    box-shadow: 0 4px 15px rgba(163, 34, 38, 0.2);
}

.logo-placeholder { 
    width: 90px; height: 90px; 
    border: 2px dashed #dfe6e9; 
    display: flex; align-items: center; justify-content: center; 
    cursor: pointer; border-radius: 12px; 
    overflow: hidden; background: #fff;
    transition: all 0.2s;
}
.logo-placeholder:hover { border-color: var(--main-color); background: #fcfcfc; }
.logo-placeholder img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Autocomplete UI */
.autocomplete-container { position: relative; }
.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dfe6e9;
    border-top: none;
    z-index: 1000;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow-sm);
    max-height: 200px;
    overflow-y: auto;
    display: none;
}
.autocomplete-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid #f1f2f6;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #f8f9fa; color: var(--main-color); }

.btn-primary { background: var(--main-color); border: none; padding: 10px 20px; border-radius: 8px; }
.btn-primary:hover { background: #8a1d20; }

.btn-primary:hover { background: #8a1d20; }

/* Micro-ajustements pour iPhone SE / Mobiles étroits */
@media (max-width: 480px) {
    .config-panel .d-flex.justify-content-between {
        flex-wrap: wrap;
    }
    .config-panel h5 {
        width: 100%;
        margin-bottom: 10px !important;
    }
    .config-panel .small.text-muted {
        width: 100%;
        margin-bottom: 15px;
        order: 3;
    }
    
    /* Identité émetteur : Logo au dessus du nom sur mobile */
    .config-panel .row.mb-3 .col-4, 
    .config-panel .row.mb-3 .col-8 {
        width: 100%;
        text-align: center;
    }
    .logo-placeholder {
        margin: 0 auto 15px auto;
    }
}

@media print { .no-print { display: none; } .preview-page { margin: 0; box-shadow: none; width: 100%; } }
