* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    color: #1a1a1a;
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: transparent;
}

header {
    background: linear-gradient(135deg, #dc0000 0%, #a00000 100%);
    color: white;
    padding: 0;
    border-radius: 16px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(220, 0, 0, 0.25);
    overflow: hidden;
}

.header-content {
    display: flex;
    align-items: center;
    padding: 30px 40px;
    gap: 20px;
    position: relative;
}

.btn-header {
    position: absolute;
    right: 40px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
}

.btn-header:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.badge-count {
    background: #fff;
    color: #dc0000;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
    display: none;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.header-icon {
    font-size: 4em;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.header-text h1 {
    font-size: 2.8em;
    font-weight: 700;
    margin-bottom: 5px;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header-text .subtitle {
    font-size: 1.1em;
    opacity: 0.95;
    font-weight: 300;
    letter-spacing: 0.5px;
}

.form-section, .facture-section {
    background-color: #ffffff;
    border: none;
    border-radius: 16px;
    padding: 35px;
    margin-bottom: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
}

.form-section:hover, .facture-section:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.section-title {
    color: #dc0000;
    margin-bottom: 25px;
    font-size: 1.5em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section h2, .facture-section h2 {
    color: #dc0000;
    margin-bottom: 25px;
    font-size: 1.8em;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: none;
    padding-bottom: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #000000;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
    background-color: #fafafa;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #dc0000;
    box-shadow: 0 0 0 4px rgba(220, 0, 0, 0.1);
    background-color: #ffffff;
}

.form-group input[readonly] {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
    color: #dc0000;
    font-weight: 600;
    border-color: #dc0000;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
    letter-spacing: 0.3px;
}

.btn-primary {
    background: linear-gradient(135deg, #dc0000 0%, #a00000 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(220, 0, 0, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(220, 0, 0, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #333333 0%, #1a1a1a 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268 0%, #3d4349 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(108, 117, 125, 0.4);
}

.btn-save {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.btn-save:hover {
    background: linear-gradient(135deg, #34ce57 0%, #28a745 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(40, 167, 69, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
    color: white;
    padding: 10px 18px;
    font-size: 14px;
    min-width: auto;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ff0000 0%, #a00000 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.4);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#listeArticles {
    margin-bottom: 20px;
}

.empty-message {
    text-align: center;
    color: #adb5bd;
    font-style: italic;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    font-size: 1.05em;
}

.article-item {
    background: linear-gradient(135deg, #ffffff 0%, #f9f9f9 100%);
    border-left: 5px solid #dc0000;
    padding: 18px;
    margin-bottom: 12px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.article-item:hover {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
    box-shadow: 0 4px 15px rgba(220, 0, 0, 0.15);
    transform: translateX(5px);
}

.article-details {
    flex-grow: 1;
}

.article-name {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.article-info {
    color: #6c757d;
    font-size: 0.9em;
    font-weight: 400;
}

.article-prix {
    font-weight: 700;
    color: #dc0000;
    font-size: 1.3em;
    margin-right: 20px;
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
    padding: 8px 16px;
    border-radius: 8px;
}

.totaux {
    background: linear-gradient(135deg, #fafafa 0%, #f0f0f0 100%);
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 10px;
    font-size: 1.1em;
    font-weight: 500;
}

.total-final {
    background: linear-gradient(135deg, #dc0000 0%, #a00000 100%);
    color: white;
    margin: 15px -25px -25px -25px;
    padding: 20px 25px;
    font-size: 1.5em;
    font-weight: 700;
    border-radius: 0 0 14px 14px;
    box-shadow: 0 -4px 15px rgba(220, 0, 0, 0.2);
}

/* Styles pour la facture officielle */
.facture-print {
    background-color: white;
    padding: 50px;
    border: none;
    border-radius: 0;
    margin-bottom: 20px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    max-width: 210mm;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.facture-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 35px;
    margin-bottom: 40px;
    border-bottom: 3px solid #dc0000;
    position: relative;
}

.facture-header::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 150px;
    height: 3px;
    background: linear-gradient(90deg, #dc0000 0%, transparent 100%);
}

.facture-logo {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo-icon {
    font-size: 4em;
    filter: grayscale(100%);
}

.logo-text h1 {
    color: #dc0000;
    font-size: 2.8em;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: 3px;
}

.logo-subtitle {
    color: #333333;
    font-size: 0.95em;
    font-weight: 500;
    margin-bottom: 3px;
}

.logo-location {
    color: #666666;
    font-size: 0.85em;
    font-weight: 400;
}

.facture-info {
    text-align: right;
}

.facture-badge {
    background: linear-gradient(135deg, #dc0000 0%, #a00000 100%);
    color: white;
    padding: 12px 30px;
    font-size: 1.8em;
    font-weight: 700;
    letter-spacing: 3px;
    display: inline-block;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(220, 0, 0, 0.3);
}

.facture-meta {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.meta-label {
    color: #666666;
    font-size: 0.85em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.meta-value {
    color: #1a1a1a;
    font-size: 1.1em;
    font-weight: 600;
}

.facture-details {
    margin-bottom: 40px;
}

.info-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card-header {
    background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
    color: white;
    padding: 15px 25px;
    font-weight: 600;
    font-size: 1.1em;
    letter-spacing: 0.5px;
}

.card-body {
    padding: 25px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #dee2e6;
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: #666666;
    font-weight: 500;
    font-size: 0.95em;
}

.info-value {
    color: #1a1a1a;
    font-weight: 600;
    font-size: 1.05em;
}

.facture-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 40px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
}

.facture-table thead {
    background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
    color: white;
}

.facture-table th {
    padding: 18px 20px;
    text-align: left;
    font-weight: 600;
    font-size: 0.95em;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
}

.facture-table td {
    padding: 16px 20px;
    text-align: left;
    border: none;
    border-bottom: 1px solid #e9ecef;
    color: #333333;
}

.facture-table tbody tr {
    background-color: #ffffff;
    transition: all 0.2s ease;
}

.facture-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.facture-table tbody tr:hover {
    background-color: #fff5f5;
    transform: scale(1.01);
}

.facture-table tbody tr:last-child td {
    border-bottom: none;
}

.facture-table td:last-child {
    font-weight: 600;
    color: #dc0000;
}

.facture-totaux {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 40px;
}

.totaux-wrapper {
    min-width: 400px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.facture-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 25px;
    border-bottom: 1px solid #dee2e6;
}

.total-label {
    color: #666666;
    font-weight: 500;
    font-size: 1em;
}

.total-value {
    color: #1a1a1a;
    font-weight: 600;
    font-size: 1.1em;
}

.facture-total-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, #dc0000 50%, transparent 100%);
    margin: 5px 0;
}

.facture-total-final {
    background: linear-gradient(135deg, #dc0000 0%, #a00000 100%);
    color: white;
    padding: 20px 25px;
    border-bottom: none;
    margin: 0;
    border-radius: 0;
}

.total-label-final {
    font-weight: 700;
    font-size: 1.3em;
    letter-spacing: 1px;
}

.total-value-final {
    font-weight: 700;
    font-size: 1.6em;
}

.facture-footer {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 3px solid #e9ecef;
}

.footer-thank-you {
    text-align: center;
    font-size: 1.3em;
    font-weight: 600;
    color: #dc0000;
    margin-bottom: 25px;
}

.footer-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #dee2e6 20%, #dee2e6 80%, transparent 100%);
    margin: 20px 0;
}

.footer-conditions {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 25px;
}

.condition-item {
    color: #495057;
    font-size: 0.95em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-contact {
    text-align: center;
    color: #6c757d;
    font-size: 0.85em;
    font-style: italic;
}

.footer-contact p {
    margin: 0;
}

/* Styles d'impression */
@media print {
    @page {
        size: A4;
        margin: 0;
    }
    
    body {
        background-color: white;
        padding: 0;
        margin: 0;
    }
    
    .form-section,
    .btn,
    .facture-actions,
    .pdf-instruction,
    header,
    .facture-section {
        display: none !important;
    }
    
    .container {
        background: white;
    }
    
    .facture-print {
        box-shadow: none;
        padding: 15mm;
        border: none;
        margin: 0;
        page-break-after: avoid;
    }
    
    #factureOfficielle {
        display: block !important;
        margin: 0;
        padding: 0;
    }
    
    .facture-table {
        page-break-inside: avoid;
    }
    
    .facture-table tbody tr:hover {
        transform: none;
        background-color: inherit;
    }
    
    .logo-icon {
        filter: none;
    }
    
    .facture-header,
    .info-card,
    .facture-totaux,
    .facture-footer {
        page-break-inside: avoid;
    }
    
    /* Forcer les couleurs d'arrière-plan */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Actions de la facture */
.facture-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.facture-actions .btn {
    flex: 1;
    min-width: 180px;
}

.pdf-instruction {
    text-align: center;
    color: #6c757d;
    font-size: 0.9em;
    font-style: italic;
    padding: 10px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffe8a1 100%);
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #ffc107;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.article-item {
    animation: slideIn 0.3s ease-out;
}

/* Améliorations visuelles */
.btn {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.form-group input:invalid,
.form-group select:invalid {
    border-color: #ff4444;
}

/* Loader */
.loader {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Styles pour les factures sauvegardées */
#facturesSauvegardees {
    animation: slideIn 0.4s ease-out;
}

.facture-sauvegardee-item {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-left: 6px solid #dc0000;
    padding: 25px;
    margin-bottom: 20px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.facture-sauvegardee-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(180deg, #dc0000 0%, #a00000 100%);
    transition: width 0.3s ease;
}

.facture-sauvegardee-item:hover::before {
    width: 100%;
    opacity: 0.05;
}

.facture-sauvegardee-item:hover {
    border-color: #dc0000;
    box-shadow: 0 8px 25px rgba(220, 0, 0, 0.2);
    transform: translateY(-5px);
}

.facture-sauvegardee-info {
    flex-grow: 1;
}

.facture-sauvegardee-numero {
    font-size: 1.4em;
    color: #dc0000;
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.facture-sauvegardee-date {
    color: #6c757d;
    font-size: 0.95em;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.facture-sauvegardee-details {
    color: #495057;
    font-size: 1em;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-block;
}

.facture-sauvegardee-total {
    color: #1a1a1a;
    font-size: 1.2em;
    font-weight: 600;
    background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
    padding: 10px 15px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 5px;
}

.facture-sauvegardee-total strong {
    color: #dc0000;
    font-size: 1.3em;
}

.facture-sauvegardee-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 10px 20px;
    font-size: 14px;
    min-width: auto;
}

input[type="date"] {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
    background-color: #fafafa;
}

input[type="date"]:focus {
    outline: none;
    border-color: #dc0000;
    box-shadow: 0 0 0 4px rgba(220, 0, 0, 0.1);
    background-color: #ffffff;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .header-icon {
        font-size: 3em;
    }
    
    .form-section, .facture-section {
        padding: 20px;
    }
    
    .facture-header {
        flex-direction: column;
        gap: 25px;
    }
    
    .facture-info {
        text-align: left;
    }
    
    .facture-badge {
        font-size: 1.4em;
        padding: 10px 20px;
    }
    
    .totaux-wrapper {
        min-width: 100%;
    }
    
    .footer-conditions {
        flex-direction: column;
        gap: 15px;
    }
    
    .facture-actions {
        flex-direction: column;
    }
    
    .facture-actions .btn {
        width: 100%;
    }
    
    .facture-sauvegardee-item {
        flex-direction: column;
        gap: 15px;
    }
    
    .facture-sauvegardee-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .facture-sauvegardee-actions .btn {
        flex: 1;
    }
}
