@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');

:root {
    --primary-color: #0279fe;
    --secondary-color: #50E3C2;
    --background-color: #f4f7fc;
    --sidebar-bg: #ffffff;
    --text-color: #333;
    --text-light: #888;
    --border-color: #e0e0e0;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* NOUVEAU : Ajout de box-sizing pour éviter les débordements */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* Logo Styles */
.logo-container {
    text-align: center;
    margin-bottom: 20px;
}

.login-logo {
    max-width: auto;
    height: auto;
    border-radius: 8px;
}

.sidebar-logo {
    text-align: center;
    margin-bottom: 15px;
}

.sidebar-logo-img {
    max-width: auto;
    height: auto;
    border-radius: 6px;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.login-box {
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-box p {
    color: var(--text-light);
    margin-bottom: 30px;
}

/* Layout */
#dashboard {
    display: flex;
}

#sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    height: 100vh;
    position: fixed;
    top: 0; /* Ajouté pour s'assurer qu'il est en haut */
    left: 0; /* Ajouté pour s'assurer qu'il est à gauche */
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
    z-index: 1100; /* Augmenté pour être au-dessus du contenu */
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
    margin-top: 20px;
}

.nav-link {
    display: block;
    padding: 12px 20px;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-link i {
    margin-right: 10px;
    width: 20px;
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--primary-color);
    color: white;
    border-left-color: var(--secondary-color);
}

#main-content {
    margin-left: 250px;
    width: calc(100% - 250px);
    padding: 20px;
    min-height: 100vh;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* Sections */
.section {
    display: none;
}

.section.active {
    display: block;
}

.section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* NOUVEAU : Styles pour la grille de cartes */
.card-grid {
    display: grid;
    /* MODIFICATION : On passe de 320px à 280px pour mieux s'adapter aux petits écrans */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.data-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid var(--primary-color);
}

.data-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--primary-color);
    white-space: normal; /* MODIFICATION : Permet au texte de passer à la ligne */
    overflow-wrap: break-word; /* S'assure que les mots très longs ne débordent pas */
    line-height: 1.4; /* OPTIONNEL : Améliore l'espacement si le titre est sur deux lignes */
}

.card-body {
    padding: 20px;
    flex-grow: 1; /* Permet au corps de prendre l'espace restant */
}

.card-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 14px;
}

.card-item i {
    color: var(--primary-color);
    width: 20px;
    text-align: center;
}

.card-item span {
    color: var(--text-light);
}

.card-footer {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-radius: 0 0 12px 12px;
}

/* Fin des styles de carte */


.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block; /* Ajouté pour un meilleur rendu */
}
/* Statuts (inchangés) */
.status-prospect { background-color: #e2e8f0; color: #4a5568; }
.status-actif { background-color: #c6f6d5; color: #2f855a; }
.status-ancien { background-color: #fed7d7; color: #c53030; }
.status-prospection { background-color: #e2e8f0; color: #4a5568; }
.status-qualification { background-color: #bee3f8; color: #2b6cb0; }
.status-proposition { background-color: #fef5e7; color: #d69e2e; }
.status-négociation { background-color: #fed7d7; color: #c53030; }
.status-gagné { background-color: #c6f6d5; color: #2f855a; }
.status-perdu { background-color: #fed7d7; color: #c53030; }
.status-en-attente { background-color: #e2e8f0; color: #4a5568; }
.status-en-cours { background-color: #bee3f8; color: #2b6cb0; }
.status-terminé { background-color: #c6f6d5; color: #2f855a; }
.status-suspendu { background-color: #fed7d7; color: #c53030; }
.status-à-faire { background-color: #e2e8f0; color: #4a5568; }


/* Action Buttons */
.action-btn {
    padding: 8px 14px; /* Augmentation pour un meilleur clic */
    margin: 0 2px;
    border: none;
    border-radius: 6px; /* Cohérence avec les autres boutons */
    cursor: pointer;
    font-size: 14px; /* Augmenté pour une meilleure lisibilité */
    transition: all 0.2s;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-btn-edit { background-color: #fbbf24; }
.action-btn-edit:hover { background-color: #f59e0b; }
.action-btn-delete { background-color: #ef4444; }
.action-btn-delete:hover { background-color: #dc2626; }
.action-btn-whatsapp { background-color: #25D366; }
.action-btn-whatsapp:hover { background-color: #128C7E; }

/* Stats Grid (inchangé) */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; padding: 25px; border-radius: 12px; box-shadow: var(--shadow); text-align: center; border-left: 4px solid var(--primary-color); }
.stat-card h4 { color: var(--text-light); font-size: 14px; font-weight: 500; margin: 0 0 10px 0; text-transform: uppercase; }
.stat-card p { font-size: 32px; font-weight: 700; color: var(--primary-color); margin: 0; }


/* Calendar (inchangé) */
#calendar-container { background: white; padding: 20px; border-radius: 8px; box-shadow: var(--shadow); }
#calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
#calendar-header button { background: var(--primary-color); border: none; color: white; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; transition: background 0.2s; }
#calendar-header button:hover { background: #3a7ac8; }
#calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; }
.calendar-weekday, .calendar-day { padding: 10px; text-align: center; background: white; }
.calendar-weekday { font-weight: 600; background: var(--primary-color); color: white; padding: 15px 10px; }
.calendar-day { min-height: 100px; text-align: right; background: #f8f9fa; position: relative; }
.calendar-day:hover { background: #e3f2fd; }
.tasks-list { list-style: none; padding: 0; margin: 5px 0 0; font-size: 11px; text-align: left; position: absolute; top: 25px; left: 5px; right: 5px; }
.tasks-list li { background: var(--secondary-color); color: #006A4E; padding: 2px 6px; border-radius: 3px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tasks-list li:hover { background-color: #40d4aa; }


/* Form Elements (inchangé) */
.input-group { margin-bottom: 20px; text-align: left; }
.input-group label { display: block; margin-bottom: 5px; font-weight: 500; color: var(--text-color); }
.input-group input, .input-group select, .input-group textarea { width: 100%; padding: 12px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 14px; transition: border-color 0.2s; }
.input-group textarea { resize: vertical; min-height: 80px; }
.input-group input:focus, .input-group select:focus, .input-group textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1); }


/* Buttons (inchangé) */
.btn { padding: 12px 20px; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; transition: all 0.2s; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary { background-color: var(--primary-color); color: white; }
.btn-primary:hover { background-color: #3a7ac8; transform: translateY(-1px); }
.btn-secondary { background-color: #e0e0e0; color: #333; }
.btn-secondary:hover { background-color: #d0d0d0; }


/* Modals (inchangé) */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); z-index: 1000; }
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-content { background: white; padding: 30px; border-radius: 12px; width: 90%; max-width: 500px; position: relative; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); max-height: 90vh; overflow-y: auto; }
.modal-close { position: absolute; top: 15px; right: 20px; font-size: 24px; cursor: pointer; color: var(--text-light); }
.modal-close:hover { color: var(--text-color); }


/* Loading & Empty States */
.loading { grid-column: 1 / -1; text-align: center; padding: 40px; color: var(--text-light); }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 40px; color: var(--text-light); font-style: italic; }


/* Notification (inchangé) */
.notification { position: fixed; top: 20px; right: 20px; padding: 15px 20px; border-radius: 8px; color: white; font-weight: 500; z-index: 1001; transform: translateX(400px); transition: transform 0.3s ease; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); max-width: 300px; }
.notification.show { transform: translateX(0); }
.notification.success { background-color: #10b981; }
.notification.error { background-color: #ef4444; }
.notification.warning { background-color: #f59e0b; }
.notification.info { background-color: var(--primary-color); }


/* Responsive */
.hidden-desktop {
    display: none;
}

@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }
    
    .main-header {
        justify-content: space-between; /* Changé de center à space-between */
        position: relative;
        padding: 15px; /* Ajusté le padding */
    }

    .hidden-desktop {
        display: inline-flex;
    }
    
    .main-header #logoutBtn {
        right: 15px;
    }
    
    #headerUserName {
        font-size: 14px;
        text-align: center;
        flex: 1; /* Ajouté pour centrer le texte */
        margin: 0 10px; /* Ajouté des marges latérales */
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .card-grid {
        grid-template-columns: 1fr; /* Une seule colonne sur mobile */
    }

    /* NOUVEAU : Ajustement du padding des cartes pour un look plus aéré */
    .data-card .card-body {
        padding: 15px;
    }
    .data-card .card-footer {
        padding: 10px 15px;
    }

    /* NOUVEAU : Réduction de la taille de la police dans les cartes */
    .card-item {
        font-size: 13px;
        margin-bottom: 12px;
    }
    
    /* NOUVEAU : Boutons d'action plus compacts */
    .card-footer .action-btn {
        padding: 6px 10px;
        font-size: 13px;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    /* NOUVEAU : Assurer que le conteneur des listes de tâches passe sur une colonne */
    .tasks-list-container {
        grid-template-columns: 1fr;
    }
    
    /* NOUVEAU : Ajustement du padding de la section tâches */
    .tasks-overview {
        padding: 15px;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

/* Charts Section */
.charts-section {
    margin-top: 30px;
}

.chart-container {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary-color);
}

.chart-container h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
    text-align: center;
    font-weight: 600;
}

.chart-container canvas {
    max-height: 400px;
}

@media (max-width: 768px) {
    .chart-container {
        padding: 15px;
        margin: 0 -5px;
    }
    
    .chart-container h3 {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .chart-container canvas {
        max-height: 300px;
    }
}

.projects-stats-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.upcoming-projects-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--secondary-color);
}

.upcoming-list {
    max-height: 250px;
    overflow-y: auto;
}

.project-item {
    padding: 10px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.project-item h5 {
    margin: 0 0 5px 0;
    color: var(--primary-color);
    font-size: 14px;
}

.project-item .project-meta {
    font-size: 12px;
    color: var(--text-light);
}

/* MODIFICATION 2: Couleurs pour les statuts des tâches dans le calendrier */
.task-status-a-faire { background: #4a5568 !important; color: #ffffff !important; }
.task-status-en-cours { background: #2b6cb0 !important; color: #ffffff !important; }
.task-status-termine { background: #2f855a !important; color: #fcfcfc !important; }

/* MODIFICATION 3: Couleurs pour les projets dans le calendrier */
.project-item-calendar {
    background: #fef5e7 !important;
    color: #d69e2e !important;
    border-left: 3px solid #f6ad55 !important;
}

.project-status-en-cours { background: #bee3f8; color: #2b6cb0; }
.project-status-en-attente { background: #e2e8f0; color: #4a5568; }
.project-status-termine { background: #c6f6d5; color: #2f855a; }
.project-status-suspendu { background: #fed7d7; color: #c53030; }

@media (max-width: 768px) {
    .projects-stats-container {
        flex-direction: column;
    }
    
    .chart-container, .upcoming-projects-container {
        margin: 0 0 15px 0 !important;
    }
}

/* STYLES POUR LA SECTION TÂCHES DU DASHBOARD */
.tasks-overview {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--secondary-color);
}

.tasks-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.task-category h4 {
    margin: 0 0 15px 0;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
    font-size: 16px;
}

.task-category h4 .fas {
    margin-right: 8px;
}

.task-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid var(--primary-color);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.task-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.task-item-title {
    font-weight: 500;
    font-size: 14px;
}

.task-item-date {
    font-size: 12px;
    color: var(--text-light);
    background-color: #e9ecef;
    padding: 3px 8px;
    border-radius: 12px;
}

/* Couleurs pour les icônes de statut de tâche */
.task-late { color: #ef4444; }
.task-today { color: #fbbf24; }
.task-upcoming { color: var(--primary-color); }