:root {
    /* Charte Graphique */
    --text-dark: #464E59;
    --gold: #BF8E34;
    --bronze: #8C6A2A;
    --beige: #D9C7A7;
    --bg-page: #F2F2F2;
    --white: #FFFFFF;

    /* Variables Utilitaires */
    --danger: #e74c3c;
    --whatsapp: #25D366;
    --shadow: 0 8px 24px rgba(70, 78, 89, 0.08);
    --radius: 12px;
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Poppins', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg-page);
    color: var(--text-dark);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3 { font-family: var(--font-heading); color: var(--text-dark); }
.hidden { display: none !important; }
.text-center { text-align: center; }

/* === COMPOSANTS BOUTONS === */
.btn {
    padding: 10px 20px; border: none; border-radius: 8px;
    cursor: pointer; font-weight: 500; transition: 0.3s;
    font-family: var(--font-heading);
}
.btn-gold { background-color: var(--gold); color: white; }
.btn-gold:hover { background-color: var(--bronze); transform: translateY(-2px); }
.btn-outline { border: 1px solid var(--gold); color: var(--gold); background: transparent; }
.btn-outline:hover { background: var(--gold); color: white; }
.btn-danger { background-color: #fee2e2; color: var(--danger); }
.btn-danger:hover { background-color: var(--danger); color: white; }
.full-width { width: 100%; }

/* === LOGIN === */
.login-container {
    height: 100vh;
    display: flex; justify-content: center; align-items: center;
    background: linear-gradient(135deg, var(--bg-page) 0%, var(--beige) 100%);
}
.login-card {
    background: var(--white); padding: 40px; border-radius: var(--radius);
    box-shadow: var(--shadow); width: 380px; text-align: center;
    border-top: 4px solid var(--gold);
}
.brand-header i { font-size: 2.5rem; color: var(--gold); margin-bottom: 10px; }
.brand-header p { letter-spacing: 4px; color: var(--bronze); font-size: 0.8rem; margin-bottom: 30px; }
.form-group { margin-bottom: 15px; }
.form-group input {
    width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; outline: none;
    font-family: var(--font-body);
}
.form-group input:focus { border-color: var(--gold); }

/* === LAYOUT === */
.app-layout { display: flex; height: 100vh; }

/* SIDEBAR */
.sidebar {
    width: 260px; background-color: var(--beige);
    display: flex; flex-direction: column; padding: 20px;
    border-right: 1px solid rgba(140, 106, 42, 0.1);
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px; font-size: 1.1rem;
    font-weight: 700; color: var(--bronze); margin-bottom: 40px;
}
.gold-text { color: var(--gold); }

.sidebar-menu ul { list-style: none; }
.menu-item {
    padding: 12px 15px; margin-bottom: 8px; border-radius: 8px;
    cursor: pointer; display: flex; align-items: center; gap: 12px;
    color: var(--text-dark); transition: 0.3s;
}
.menu-item i { width: 20px; text-align: center; color: var(--bronze); }
.menu-item:hover, .menu-item.active { background-color: rgba(255,255,255,0.6); color: var(--gold); font-weight: 600; }
.menu-item.active i { color: var(--gold); }

.user-profile {
    margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(0,0,0,0.05);
    display: flex; align-items: center; gap: 10px;
}
.avatar {
    width: 35px; height: 35px; background: var(--bronze); color: white;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.info { flex: 1; }
.info .name { display: block; font-size: 0.85rem; font-weight: 600; }
.info .role { font-size: 0.7rem; opacity: 0.7; }
.logout-btn { border: none; background: none; cursor: pointer; color: var(--text-dark); }

/* MAIN CONTENT */
.main-content { flex: 1; padding: 30px; overflow-y: auto; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.kpi-wrapper { display: flex; gap: 10px; }
.kpi-badge {
    padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600;
}
.kpi-badge.info { background: var(--white); color: var(--bronze); border: 1px solid var(--beige); }
.kpi-badge.alert { background: #fee2e2; color: var(--danger); border: 1px solid var(--danger); }

/* TASKS LIST */
.tasks-grid { display: grid; gap: 15px; }
.dash-pagination {
    display: flex; justify-content: center; align-items: center; gap: 16px;
    padding: 16px 0; margin-top: 8px;
}
.dash-page-info { color: var(--text-dark); font-size: 0.9em; font-weight: 500; }
.task-card {
    background: var(--white); padding: 20px; border-radius: var(--radius);
    box-shadow: var(--shadow); display: grid;
    grid-template-columns: 80px 1.5fr 2fr 120px; align-items: center; gap: 20px;
    border-left: 4px solid transparent; transition: transform 0.2s;
}
@media (hover: hover) { .task-card:hover { transform: translateY(-2px); } }

/* Ligne statut */
.task-card.prospect { border-left-color: #bdc3c7; }
.task-card.client { border-left-color: var(--gold); }
.status-badge {
    font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
    text-align: center; padding: 4px 8px; border-radius: 4px;
}
.status-badge.crit { background: #fee2e2; color: var(--danger); border: 1px solid var(--danger); }
.prospect .status-badge { background: #f0f0f0; color: #7f8c8d; }
.client .status-badge { background: rgba(191, 142, 52, 0.1); color: var(--gold); }

/* Infos */
.task-info h4 { margin-bottom: 2px; font-size: 0.95rem; }
.task-info span { font-size: 0.8rem; color: #888; }
.journey-link { color: var(--text-dark); text-decoration: none; border-bottom: 1px dashed var(--bronze); }
.journey-link:hover { color: var(--gold); border-bottom-color: var(--gold); }
.tag { font-size: 0.7rem; background: var(--beige); padding: 2px 6px; border-radius: 4px; margin-left: 5px; }
.task-note-icon { color: var(--bronze); margin-left: 5px; font-size: 0.8rem; cursor: help; opacity: 0.7; }
.task-note-icon:hover { opacity: 1; }

/* Message */
.task-msg h5 { font-size: 0.85rem; color: var(--bronze); margin-bottom: 3px; }
.task-msg p { font-size: 0.8rem; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }
.late-tag { color: white; background: var(--danger); font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; margin-left: 5px; }

/* Actions */
.task-actions { display: flex; gap: 8px; justify-content: flex-end; }
.action-btn {
    width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 0.9rem; transition: 0.2s;
}
.btn-wa { background: rgba(37, 211, 102, 0.1); color: var(--whatsapp); }
.btn-wa:hover { background: var(--whatsapp); color: white; }
.btn-conv { background: rgba(191, 142, 52, 0.1); color: var(--gold); }
.btn-conv:hover { background: var(--gold); color: white; }
.btn-snooze { background: #fff3e0; color: #e65100; }
.btn-snooze:hover { background: #e65100; color: white; }
.btn-ign { background: #f5f5f5; color: #999; }
.btn-ign:hover { background: #ddd; color: var(--text-dark); }
.btn-done { background: #e8f5e9; color: #2e7d32; }
.btn-done:hover { background: #2e7d32; color: white; }

.task-card.task-sent { 
    background: #fdfdfd; 
    border-left-color: var(--whatsapp); 
    opacity: 0.85; 
}
.btn-relancer { 
    animation: pulse-green 2s infinite; 
}
@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* DASHBOARD FILTERS */
.dashboard-filters .row {
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    margin-bottom: 0;
    gap: 10px;
}
.dashboard-filters input,
.dashboard-filters select {
    padding: 8px 10px;
    font-size: 0.85rem;
}

/* FORM & TABLE */
.card { background: var(--white); padding: 30px; border-radius: var(--radius); box-shadow: var(--shadow); }
.form-card { max-width: 700px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.col { display: flex; flex-direction: column; gap: 8px; }
label { font-size: 0.85rem; font-weight: 500; color: var(--bronze); }
input, select { padding: 10px; border: 1px solid #ddd; border-radius: 6px; font-family: var(--font-body); }
.radio-group { display: flex; gap: 15px; }

.styled-table { width: 100%; border-collapse: collapse; }
.styled-table th { text-align: left; padding: 15px; color: var(--bronze); border-bottom: 2px solid var(--beige); font-family: var(--font-heading); }
.styled-table td { padding: 15px; border-bottom: 1px solid #eee; font-size: 0.9rem; }

/* MODALS */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(70, 78, 89, 0.6); backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center; z-index: 1000;
}
.modal-content {
    background: white; padding: 30px; border-radius: var(--radius); width: 450px;
    position: relative; animation: slideUp 0.3s ease; border-top: 4px solid var(--bronze);
    max-height: 90vh; overflow: auto;
}
.modal-header.warning { color: var(--danger); display: flex; align-items: center; gap: 10px; margin-bottom: 15px; font-size: 1.2rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }
.close-modal { position: absolute; top: 15px; right: 15px; border: none; background: none; font-size: 1.2rem; cursor: pointer; color: #999; }
.success-anim { font-size: 3rem; color: var(--gold); margin-bottom: 15px; animation: pop 0.5s; }

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

/* Modales spécifiques plus larges */
#modal-scn .modal-content { width: 840px; max-width: 95vw; }
#modal-ct .modal-content { width: 720px; max-width: 95vw; }
#modal-journey .modal-content { width: 560px; max-width: 95vw; }

/* Timeline parcours contact */
.journey-list { list-style: none; position: relative; padding-left: 24px; }
.journey-list::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--beige); }
.journey-item { position: relative; margin-bottom: 16px; padding: 10px 14px; border-radius: 8px; background: #fafafa; border: 1px solid #eee; }
.journey-item::before {
    content: ''; position: absolute; left: -21px; top: 14px;
    width: 10px; height: 10px; border-radius: 50%; border: 2px solid #ccc; background: #fff;
}
.journey-item.sent { border-left: 3px solid var(--whatsapp); }
.journey-item.sent::before { background: var(--whatsapp); border-color: var(--whatsapp); }
.journey-item.overdue { border-left: 3px solid var(--danger); }
.journey-item.overdue::before { background: var(--danger); border-color: var(--danger); }
.journey-item.snoozed { border-left: 3px solid #e65100; }
.journey-item.snoozed::before { background: #e65100; border-color: #e65100; }
.journey-item.pending { border-left: 3px solid var(--beige); opacity: 0.7; }
.journey-item.pending::before { background: var(--beige); border-color: var(--beige); }
.journey-item .j-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 2px; }
.journey-item .j-delay { font-size: 0.75rem; color: var(--bronze); }
.journey-item .j-status { font-size: 0.75rem; font-weight: 600; margin-top: 2px; }
.journey-item.sent .j-status { color: var(--whatsapp); }
.journey-item.overdue .j-status { color: var(--danger); }
.journey-item.snoozed .j-status { color: #e65100; }
.journey-item.pending .j-status { color: #aaa; }

/* Toaster */
.toast {
    position: fixed; right: 16px; bottom: 16px; background:#333; color:#fff;
    padding:10px 14px; border-radius:6px; opacity:0; transform: translateY(8px);
    transition: .2s; z-index: 3000; box-shadow: var(--shadow);
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.success { background: #137a16; }
.toast.error { background: #a81b1b; }

/* Statistiques */
.stats-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.stat-card {
    background: var(--white); padding: 20px; border-radius: var(--radius);
    box-shadow: var(--shadow); text-align: center; border-top: 3px solid var(--gold);
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--bronze); font-family: var(--font-heading); }
.stat-label { font-size: 0.8rem; color: #888; margin-top: 4px; }
.stat-bars { display: flex; flex-direction: column; gap: 10px; }
.stat-bar-row { display: flex; align-items: center; gap: 10px; }
.stat-bar-label { width: 100px; font-size: 0.85rem; font-weight: 500; text-align: right; flex-shrink: 0; }
.stat-bar-track { flex: 1; height: 20px; background: #f0f0f0; border-radius: 10px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--gold); border-radius: 10px; transition: width 0.5s ease; }
.stat-bar-count { width: 30px; font-size: 0.85rem; font-weight: 600; color: var(--bronze); }

/* Hamburger — caché sur desktop */
.hamburger-btn {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 900;
    width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--beige); color: var(--bronze); font-size: 1.1rem;
    box-shadow: var(--shadow);
}

/* Overlay sidebar mobile */
.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); z-index: 998;
}

/* === ALERTE DOUBLONS === */
.duplicate-alert {
    margin: 12px 0;
    padding: 14px 18px;
    background: #fffbeb;
    border: 1px solid #f59e0b;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
}
.dup-header {
    font-family: var(--font-heading, 'Montserrat', sans-serif);
    font-weight: 600;
    font-size: 0.9rem;
    color: #b45309;
    margin-bottom: 10px;
}
.dup-list { display: flex; flex-direction: column; gap: 8px; }
.dup-item {
    background: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #eee;
}
.dup-item-main {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.9rem;
}
.dup-item-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.8rem;
    color: #888;
}
.dup-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    text-transform: uppercase;
}
.dup-client { background: rgba(191,142,52,0.12); color: var(--gold, #BF8E34); }
.dup-prospect { background: #f0f0f0; color: #7f8c8d; }

/* === RESPONSIVE TABLETTE (≤ 768px) === */
@media (max-width: 768px) {
    body { overflow: auto; height: auto; }
    .app-layout { flex-direction: column; height: auto; min-height: 100vh; }
    .hamburger-btn { display: flex; align-items: center; justify-content: center; }

    .sidebar {
        position: fixed; top: 0; left: -280px; width: 260px; height: 100vh;
        z-index: 999; transition: left 0.3s ease; box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    .sidebar.open { left: 0; }

    .main-content { padding: 60px 16px 16px; }

    /* Page header empilé */
    .page-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
    .kpi-wrapper { width: 100%; }

    /* Filtres dashboard empilés */
    .dashboard-filters .row { grid-template-columns: 1fr 1fr; }

    /* Cartes de tâches empilées */
    .task-card {
        grid-template-columns: 1fr;
        gap: 10px; padding: 14px;
    }
    .task-status { display: none; }
    .task-info h4 { font-size: 0.9rem; }
    .task-msg p { max-width: 100%; white-space: normal; }

    /* Boutons d'action plus grands pour le tactile */
    .action-btn { width: 40px; height: 40px; font-size: 1rem; }
    .task-actions { justify-content: flex-start; flex-wrap: wrap; }

    /* Formulaires en 1 colonne */
    .row { grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
    .form-card { max-width: 100%; }
    .card { padding: 16px; }

    /* Modales plein écran */
    .modal-content { width: 95vw !important; max-width: 95vw !important; padding: 20px; }

    /* Tables avec scroll horizontal */
    .table-card { overflow-x: auto; }
    .styled-table th, .styled-table td { padding: 10px 8px; font-size: 0.8rem; white-space: nowrap; }

    /* Alerte doublons responsive */
    .duplicate-alert { margin: 10px 0; padding: 10px 12px; }
    .dup-item-detail { flex-direction: column; gap: 4px; }
}

/* === RESPONSIVE MOBILE (≤ 480px) === */
@media (max-width: 480px) {
    .main-content { padding: 56px 10px 10px; }

    .dashboard-filters .row { grid-template-columns: 1fr; }
    .dashboard-filters { padding: 8px 10px !important; }

    .kpi-badge { font-size: 0.7rem; padding: 4px 8px; }

    .task-card { padding: 12px; }
    .task-actions { gap: 6px; }

    .modal-content { padding: 16px; }
    .modal-actions { flex-wrap: wrap; }
    .modal-actions .btn { flex: 1; min-width: 80px; text-align: center; }

    /* Login adapté */
    .login-card { width: 90vw; padding: 24px; }
}