/* BTP Manager - Feuille de style principale */
/* Gère l'affichage des cartes, popups, modales et états */

:root {
    --btp-primary: #3498db;
    --btp-secondary: #2c3e50;
    --btp-success: #27ae60;
    --btp-warning: #f39c12;
    --btp-danger: #e74c3c;
    --btp-gray-100: #f8f9fa;
    --btp-gray-200: #e9ecef;
    --btp-gray-300: #dee2e6;
    --btp-gray-400: #ced4da;
    --btp-gray-500: #adb5bd;
    --btp-gray-600: #6c757d;
    --btp-gray-700: #495057;
    --btp-gray-800: #343a40;
    --btp-gray-900: #212529;
    --btp-border: #dee2e6;
    --btp-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --btp-radius: 12px;
    --btp-transition: all 0.3s ease;
}

/* Conteneur principal */
.btp-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 20px 60px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--btp-gray-800);
}

/* En-tête */
.btp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--btp-border);
    flex-wrap: wrap;
    gap: 15px;
}

.btp-title {
    font-size: 1.8rem;
    color: var(--btp-secondary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.btp-icon {
    font-size: 1.4em;
}

/* Boutons - CORRECTION : stabilité au hover */
.btp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--btp-radius) !important;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btp-btn:hover {
    border-radius: var(--btp-radius) !important;
}

.btp-btn-primary {
    background: var(--btp-primary);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btp-btn-primary:hover {
    background: #2980b9;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btp-btn-secondary {
    background: var(--btp-gray-200);
    color: var(--btp-gray-800);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btp-btn-secondary:hover {
    background: var(--btp-gray-300);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btp-btn-add {
    font-weight: 600;
}

.btp-plus {
    font-size: 1.3em;
    font-weight: bold;
}

/* Boutons colorés spéciaux */
.btp-btn-purple {
    background: #9b59b6;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btp-btn-purple:hover {
    background: #8e44ad;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btp-btn-orange {
    background: #f39c12;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btp-btn-orange:hover {
    background: #e67e22;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btp-btn-danger {
    background: #e74c3c;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btp-btn-danger:hover {
    background: #c0392b;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Grille de cartes */
.btp-clients-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 10px;
}

/* Carte client */
.btp-client-card {
    background: white;
    border: 1px solid var(--btp-border);
    border-radius: var(--btp-radius);
    padding: 22px;
    box-shadow: var(--btp-shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border-left: 4px solid var(--btp-primary);
}

.btp-client-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    border-color: var(--btp-primary);
}

.btp-client-card:focus {
    outline: 3px solid var(--btp-primary);
    outline-offset: 2px;
}

/* En-tête de carte */
.btp-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.btp-client-name {
    margin: 0;
    font-size: 1.25rem;
    color: var(--btp-secondary);
    font-weight: 600;
    line-height: 1.3;
}

.btp-card-badge {
    background: var(--btp-primary);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 9px;
    border-radius: 6px;
    white-space: nowrap;
}

.btp-badge-projet {
    background: var(--btp-secondary);
}

/* Corps de carte */
.btp-card-body {
    margin-bottom: 16px;
    color: var(--btp-gray-700);
    font-size: 0.95rem;
}

.btp-card-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
    word-break: break-word;
}

.btp-info-icon {
    font-size: 1.3em;
    color: var(--btp-primary);
    min-width: 22px;
    text-align: center;
}

/* Footer de carte */
.btp-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--btp-gray-500);
    font-size: 0.85rem;
    font-style: italic;
}

.btp-card-arrow {
    font-size: 1.3em;
    color: var(--btp-primary);
    opacity: 0.8;
}

/* État vide */
.btp-empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--btp-gray-500);
    background: var(--btp-gray-100);
    border-radius: var(--btp-radius);
    margin-top: 20px;
}

.btp-empty-icon {
    font-size: 3.5rem;
    margin-bottom: 18px;
    opacity: 0.6;
}

.btp-empty-state h3 {
    margin: 0 0 12px 0;
    font-size: 1.5rem;
    color: var(--btp-gray-700);
}

.btp-empty-state p {
    margin: 0 0 20px 0;
    color: var(--btp-gray-600);
}

/* MODALS - Base */
.btp-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

.btp-modal.active {
    opacity: 1;
}

.btp-modal-content {
    background: white;
    border-radius: var(--btp-radius);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    margin: 40px auto;
    max-width: 500px;
    width: 100%;
    transform: translateY(-15px);
    transition: transform 0.4s ease;
    overflow: hidden;
    animation: fadeInUp 0.4s ease;
}

.btp-modal.active .btp-modal-content {
    transform: translateY(0);
}

/* En-tête modal standard */
.btp-modal-header {
    padding: 20px 24px;
    background: var(--btp-gray-100);
    border-bottom: 1px solid var(--btp-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btp-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--btp-secondary);
    font-weight: 600;
}

.btp-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--btp-gray-600);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btp-modal-close:hover {
    background: var(--btp-gray-200);
    color: var(--btp-gray-800);
}

/* POPUPS - Styles spécialisés */
#clientPopup .btp-modal-content,
#projectPopup .btp-modal-content {
    max-width: 600px;
}

#clientPopup .btp-modal-header,
#projectPopup .btp-modal-header {
    padding: 24px 24px 20px;
    background: linear-gradient(135deg, var(--btp-primary), var(--btp-secondary));
    color: white;
    border-bottom: none;
}

#clientPopup .btp-modal-header h3,
#projectPopup .btp-modal-header h3 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

#clientPopup .btp-modal-close,
#projectPopup .btp-modal-close {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    backdrop-filter: blur(5px);
}

#clientPopup .btp-modal-close:hover,
#projectPopup .btp-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.btp-popup-content {
    max-width: 600px;
}

.btp-popup-body {
    padding: 30px;
}

.btp-client-details {
    margin-bottom: 30px;
}

.btp-client-projects {
    margin-bottom: 30px;
}

.btp-client-projects h3 {
    margin: 20px 0 15px 0;
    color: var(--btp-secondary);
    font-size: 1.1rem;
    font-weight: 600;
}

.btp-detail-row {
    display: flex;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--btp-gray-200);
    font-size: 1rem;
}

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

.btp-detail-label {
    font-weight: 600;
    color: var(--btp-gray-700);
    min-width: 180px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    line-height: 1.5;
}

.btp-detail-value {
    flex: 1;
    color: var(--btp-gray-800);
    word-break: break-word;
    line-height: 1.5;
    padding-top: 0;
}

.btp-popup-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.btp-popup-actions .btp-btn {
    padding: 11px 18px !important;
    font-size: 0.95rem;
    border: none !important;
    margin: 0 !important;
}

/* FORMULAIRES */
.btp-form {
    padding: 24px;
}

.btp-form-group {
    margin-bottom: 20px;
}

.btp-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--btp-gray-700);
    font-size: 0.95rem;
}

.btp-input,
.btp-textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--btp-border);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--btp-transition);
    box-sizing: border-box;
    font-family: inherit;
}

.btp-input:focus,
.btp-textarea:focus {
    outline: none;
    border-color: var(--btp-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btp-textarea {
    min-height: 80px;
    resize: vertical;
}

select.btp-input {
    cursor: pointer;
    background-color: white;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="m0 1h4l-2 2z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 35px;
    appearance: none;
    line-height: 1.4;
    height: auto;
    min-height: 44px;
}

select.btp-input option {
    padding: 8px 12px;
    line-height: 1.4;
    color: var(--btp-gray-800);
    background-color: white;
}

.btp-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--btp-border);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Messages d'état */
.btp-error {
    background: #fdf6f6;
    border-left: 4px solid var(--btp-danger);
    color: var(--btp-danger);
    padding: 14px 18px;
    margin: 15px 0;
    border-radius: var(--btp-radius);
    font-size: 0.95rem;
    animation: fadeOut 0.5s ease-in-out 4.5s forwards;
}

.btp-success {
    background: #f6fdf6;
    border-left: 4px solid var(--btp-success);
    color: var(--btp-success);
    padding: 14px 18px;
    margin: 15px 0;
    border-radius: var(--btp-radius);
    font-size: 0.95rem;
    animation: fadeOut 0.5s ease-in-out 4.5s forwards;
}

.btp-warning {
    background: #fff9f4;
    border-left: 4px solid var(--btp-warning);
    color: var(--btp-warning);
    padding: 14px 18px;
    margin: 15px 0;
    border-radius: var(--btp-radius);
    font-size: 0.95rem;
    animation: fadeOut 0.5s ease-in-out 4.5s forwards;
}

.btp-info {
    background: #f6fbff;
    border-left: 4px solid var(--btp-primary);
    color: var(--btp-primary);
    padding: 14px 18px;
    margin: 15px 0;
    border-radius: var(--btp-radius);
    font-size: 0.95rem;
    animation: fadeOut 0.5s ease-in-out 4.5s forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* États des champs */
.btp-input-error {
    border-color: var(--btp-danger) !important;
    box-shadow: 0 0 0 3px rgb(231, 76, 60, 0.1) !important;
}

.btp-input-warning {
    border-color: var(--btp-warning) !important;
    box-shadow: 0 0 0 3px rgb(243, 156, 18, 0.1) !important;
}

.btp-field-error,
.btp-field-warning {
    font-size: 12px;
    margin-top: 4px;
}

.btp-field-error {
    color: var(--btp-danger);
}

.btp-field-warning {
    color: var(--btp-warning);
}

/* États du body */
body.btp-modal-open {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    .btp-header {
        flex-direction: column;
        align-items: stretch;
    }

    .btp-btn {
        width: 100%;
        justify-content: center;
    }

    .btp-modal {
        padding: 10px;
    }

    .btp-modal-content {
        margin: 10px auto;
        max-width: none;
    }

    .btp-form {
        padding: 20px;
    }

    .btp-popup-body {
        padding: 20px;
    }

    .btp-form-actions {
        flex-direction: column;
    }

    .btp-form-actions .btp-btn {
        width: 100%;
    }

    .btp-popup-actions {
        justify-content: stretch;
    }

    .btp-popup-actions .btp-btn {
        flex: 1;
        min-width: auto;
    }

    .btp-clients-grid {
        grid-template-columns: 1fr;
    }
}

/* Accessibilité */
.btp-client-card {
    outline: none;
}

.btp-client-card:focus-visible {
    outline: 3px solid var(--btp-primary);
    outline-offset: 2px;
}

/* Focus pour les éléments interactifs */
.btp-btn:focus-visible,
.btp-input:focus-visible,
.btp-textarea:focus-visible {
    outline: 3px solid var(--btp-primary);
    outline-offset: 2px;
}

/* Animations avancées */
.btp-notification {
    animation: slideInRight 0.3s ease;
}

.btp-mini-project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}