/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f6fa;
    color: #2c3e50;
    line-height: 1.6;
}

/* Header et navigation */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.menu a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s;
}

.menu a:hover {
    opacity: 0.8;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Messages flash */
.flash-messages {
    margin-bottom: 1rem;
}

.flash-message {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 0.5rem;
}

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.flash-error {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 3px solid #667eea;
}

.page-header h2 {
    color: #2c3e50;
    font-size: 2rem;
}

/* Boutons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-info {
    background-color: #3498db;
    color: white;
}

/* Boutons petits - UNIFORMISÉS */
.btn-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    min-width: 36px;
    min-height: 36px;
    font-weight: 500;
}

.btn-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.btn-small.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-small.btn-warning:hover {
    background-color: #e67e22;
}

.btn-small.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-small.btn-danger:hover {
    background-color: #c0392b;
}

.btn-small.btn-info {
    background-color: #3498db;
    color: white;
}

.btn-small.btn-info:hover {
    background-color: #2980b9;
}

.btn-small.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-small.btn-success:hover {
    background-color: #229954;
}

/* Cartes */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.card:hover {
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.card h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.card .number {
    font-size: 3rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 1rem 0;
}

/* Tableaux */
.table {
    width: 100%;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid #ecf0f1;
}

.table tbody tr:hover {
    background-color: #f8f9fa;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.montant {
    font-weight: 600;
    color: #27ae60;
}

/* Actions dans les tableaux */
td.actions {
    white-space: nowrap;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-brouillon {
    background-color: #95a5a6;
    color: white;
}

.badge-secondary {
    background-color: #95a5a6;
    color: white;
}

.badge-à-valider {
    background-color: #3498db;
    color: white;
}

.badge-info {
    background-color: #3498db;
    color: white;
}

.badge-à-modifier {
    background-color: #f39c12;
    color: white;
}

.badge-warning {
    background-color: #f39c12;
    color: white;
}

.badge-envoyé {
    background-color: #27ae60;
    color: white;
}

.badge-success {
    background-color: #27ae60;
    color: white;
}

.badge-danger {
    background-color: #e74c3c;
    color: white;
}

.badge-large {
    font-size: 1.2rem;
    padding: 0.8rem 2rem;
}

/* Formulaires */
.form-container {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Info box */
.info-box {
    background-color: #e8f5e9;
    border-left: 4px solid #27ae60;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

/* No data */
.no-data {
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.no-data p {
    font-size: 1.2rem;
    color: #7f8c8d;
    margin-bottom: 1.5rem;
}

/* Footer */
footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 3rem;
}

/* Devis detail */
.devis-status {
    text-align: center;
}

.devis-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.info-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.info-card h3 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.info-card p {
    margin: 0.5rem 0;
}

.devis-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Sections de devis */
.devis-section {
    background: white;
    border-radius: 10px;
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.section-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h4 {
    margin: 0;
    font-size: 1.1rem;
}

.section-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.section-actions form {
    margin: 0;
}

.devis-section .table {
    margin: 0;
    box-shadow: none;
}

/* Sous-prestations */
.sous-prestations {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sous-prestation {
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #3498db;
}

.sous-prestation-desc {
    font-size: 0.95rem;
    color: #2c3e50;
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.sous-prestation-prix {
    font-size: 0.85rem;
    color: #7f8c8d;
    font-style: italic;
}

/* Totaux */
.devis-totaux {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-top: 2rem;
}

.totaux-container {
    max-width: 500px;
    margin-left: auto;
}

.totaux-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #ecf0f1;
}

.totaux-row:last-child {
    border-bottom: none;
}

.totaux-label {
    font-weight: 500;
    color: #2c3e50;
}

.totaux-value {
    font-weight: 600;
    color: #27ae60;
}

.totaux-reduction {
    color: #e74c3c;
}

.totaux-final {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.totaux-final .totaux-label,
.totaux-final .totaux-value {
    color: white;
    font-size: 1.3rem;
}

/* Notes */
/* Sections de devis */
.devis-section {
    background: white;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.section-header {
    background-color: #f8f9fa;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.section-header h4 {
    margin: 0;
    color: #2c3e50;
    font-weight: 600;
}

/* Styles pour les boutons de section */
.section-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Style de base pour tous les boutons de section */
.section-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 4px;
    transition: all 0.2s ease-in-out;
    border: 1px solid transparent;
}

/* Bouton principal - Ajouter une ligne */
.section-actions .btn-primary {
    background-color: #4e73df;
    color: white;
    border-color: #4e73df;
}

.section-actions .btn-primary:hover {
    background-color: #3a5ccc;
    border-color: #3a5ccc;
}

/* Bouton secondaire - Modifier */
.section-actions .btn-secondary {
    background-color: #f8f9fc;
    color: #5a5c69;
    border: 1px solid #d1d3e2;
}

.section-actions .btn-secondary:hover {
    background-color: #e3e6f0;
    border-color: #bac8f3;
    color: #4e73df;
}

/* Bouton danger - Supprimer */
.section-actions .btn-danger {
    background-color: #f8f9fc;
    color: #e74a3b;
    border: 1px solid #d1d3e2;
}

.section-actions .btn-danger:hover {
    background-color: #f1d8d6;
    border-color: #e74a3b;
    color: #e74a3b;
}

/* Icônes dans les boutons */
.section-actions .btn i {
    margin-right: 0.3rem;
    font-size: 0.8em;
}

.devis-notes {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-top: 2rem;
}

.devis-notes h3 {
    color: #667eea;
    margin-bottom: 1rem;
}

.notes-content {
    color: #2c3e50;
    line-height: 1.8;
}

/* Modal Turbo */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 2px solid #ecf0f1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 1.5rem;
}

/* Modal simple (pour exergue) */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.modal .modal-box {
    position: relative;
    z-index: 10000;
}

/* Stats devis */
.devis-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    /* Utiliser un accent visuel sans impacter la boîte pour éviter les différences light/dark */
    box-shadow: inset 4px 0 0 0 #667eea;
}

.stat-icon {
    font-size: 2rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

/* Variantes de couleur pour l'accent gauche via box-shadow inset (au lieu de border-left) */
.stat-à-valider {
    box-shadow: inset 4px 0 0 0 #3498db;
}

.stat-à-modifier {
    box-shadow: inset 4px 0 0 0 #f39c12;
}

.stat-envoyé {
    box-shadow: inset 4px 0 0 0 #27ae60;
}

/* Sous-prestations dans le formulaire */
.part-item {
    background: white;
    border: 2px solid #e3f2fd;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.part-item:hover {
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.2);
    border-color: #2196f3;
}

.part-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e3f2fd;
}

.part-header h4 {
    margin: 0;
    color: #2196f3;
    font-size: 1.1rem;
}

.part-content {
    margin-top: 1rem;
}

.part-total {
    text-align: center;
}

.remove-part {
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
    }

    .menu {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .devis-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        text-align: center;
    }
}