/* =============================================
   GestERP Module Mailing - Styles CSS
   Version avec menu horizontal blanc/beige
   ============================================= */

/* Variables CSS */
:root {
    --primary: #d4a574;
    --primary-dark: #b8956a;
    --primary-light: #e5c4a8;
    --secondary: #8b7355;
    --success: #6b8e6b;
    --warning: #d4a574;
    --danger: #c17c74;
    --info: #7a9eb8;

    --bg-header: #faf8f5;
    --bg-header-border: #e8e2d9;
    --bg-light: #fdfcfa;
    --bg-white: #ffffff;
    --bg-card: #ffffff;
    --bg-beige: #f5f0e8;

    --text-primary: #4a4039;
    --text-secondary: #7a6f63;
    --text-light: #a49789;
    --text-white: #ffffff;

    --border-color: #e8e2d9;
    --border-radius: 8px;
    --shadow-sm: 0 1px 3px rgba(74,64,57,0.08);
    --shadow: 0 4px 12px rgba(74,64,57,0.1);
    --shadow-lg: 0 10px 25px rgba(74,64,57,0.12);

    --header-height: 70px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-light);
    line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* Layout */
.app-container { min-height: 100vh; display: flex; flex-direction: column; }

/* Top Header - Menu Horizontal Blanc/Beige */
.top-header {
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--bg-header-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 16px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 16px;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

.header-brand i { font-size: 1.4rem; color: var(--primary); }
.header-brand span { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }
.header-brand small { font-size: 0.7rem; color: var(--text-light); background: var(--bg-beige); padding: 2px 8px; border-radius: 4px; margin-left: 4px; }

/* Navigation Horizontale */
.horizontal-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.horizontal-nav::-webkit-scrollbar { display: none; }

.horizontal-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 10px;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: var(--transition);
    white-space: nowrap;
    font-size: 0.82rem;
}

.horizontal-nav .nav-item:hover { background: var(--bg-beige); color: var(--text-primary); }
.horizontal-nav .nav-item.active { background: var(--primary); color: var(--text-white); }
.horizontal-nav .nav-item i { font-size: 0.85rem; }

/* Header Actions */
.header-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.api-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 20px;
    background: var(--bg-beige);
}

.api-status.connected { color: var(--success); }
.api-status.connected i { font-size: 6px; }

.btn-icon {
    position: relative;
    background: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover { background: var(--bg-beige); color: var(--primary); }

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}

.btn-hub {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: var(--border-radius);
    background: var(--bg-beige);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    flex-shrink: 0;
}
.btn-hub:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.btn-hub i { font-size: 0.9rem; }

/* Main Content */
.main-content { flex: 1; display: flex; flex-direction: column; }

/* Sub Header */
.sub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
}

.sub-header h2 { font-size: 1.4rem; font-weight: 600; color: var(--text-primary); }

.search-box { position: relative; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-light); }
.search-box input {
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    width: 280px;
    background: var(--bg-light);
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.15);
}

/* Content Area */
.content-area { flex: 1; padding: 24px; overflow-y: auto; background: var(--bg-light); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: var(--border-radius); font-weight: 500; transition: var(--transition); border: none; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg-beige); color: var(--text-secondary); }
.btn-secondary:hover { background: var(--border-color); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #5a7a5a; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a86a63; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(212, 165, 116, 0.05); }
.btn-icon-only { width: 36px; height: 36px; padding: 0; justify-content: center; }

/* Cards */
.card { background: var(--bg-card); border-radius: var(--border-radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; background: var(--bg-beige); }
.card-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 20px; }
.card-footer { padding: 16px 20px; border-top: 1px solid var(--border-color); background: var(--bg-beige); }

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

.stat-card { background: var(--bg-card); border-radius: var(--border-radius); padding: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); display: flex; align-items: flex-start; gap: 16px; }

.stat-icon { width: 48px; height: 48px; border-radius: var(--border-radius); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.stat-icon.blue { background: rgba(122, 158, 184, 0.15); color: var(--info); }
.stat-icon.green { background: rgba(107, 142, 107, 0.15); color: var(--success); }
.stat-icon.orange { background: rgba(212, 165, 116, 0.15); color: var(--primary); }
.stat-icon.red { background: rgba(193, 124, 116, 0.15); color: var(--danger); }
.stat-icon.purple { background: rgba(139, 115, 85, 0.15); color: var(--secondary); }

.stat-content h4 { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; margin-bottom: 4px; }
.stat-content .value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); }
.stat-content .trend { font-size: 0.8rem; margin-top: 4px; }
.stat-content .trend.up { color: var(--success); }
.stat-content .trend.down { color: var(--danger); }

/* Tables */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border-color); }
.data-table th { background: var(--bg-beige); font-weight: 600; color: var(--text-secondary); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
.data-table tbody tr:hover { background: var(--bg-light); }
.data-table .checkbox-col { width: 40px; }
.data-table .actions-col { width: 120px; text-align: right; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-weight: 500; margin-bottom: 6px; color: var(--text-primary); }
.form-label.required::after { content: '*'; color: var(--danger); margin-left: 4px; }
.form-control { width: 100%; padding: 10px 14px; border: 1px solid var(--border-color); border-radius: var(--border-radius); background: var(--bg-white); transition: var(--transition); }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.15); }
.form-control.error { border-color: var(--danger); }
.form-hint { font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }
.form-error { font-size: 0.8rem; color: var(--danger); margin-top: 4px; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* Toggle Switch */
.toggle-switch { position: relative; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--border-color); border-radius: 24px; transition: var(--transition); }
.toggle-slider::before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: var(--transition); }
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Badges & Tags */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 500; }
.badge-primary { background: rgba(212, 165, 116, 0.15); color: var(--primary-dark); }
.badge-success { background: rgba(107, 142, 107, 0.15); color: var(--success); }
.badge-warning { background: rgba(212, 165, 116, 0.2); color: var(--secondary); }
.badge-danger { background: rgba(193, 124, 116, 0.15); color: var(--danger); }
.badge-secondary { background: var(--bg-beige); color: var(--text-secondary); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; background: var(--bg-beige); border-radius: 4px; font-size: 0.8rem; color: var(--text-secondary); }
.tag .remove { cursor: pointer; opacity: 0.6; }
.tag .remove:hover { opacity: 1; color: var(--danger); }

/* Status */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-brouillon .status-dot { background: var(--text-light); }
.status-pret .status-dot { background: var(--info); }
.status-programme .status-dot { background: var(--warning); }
.status-encours .status-dot { background: var(--primary); }
.status-termine .status-dot { background: var(--success); }
.status-erreur .status-dot { background: var(--danger); }
.status-annule .status-dot { background: var(--secondary); }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(74, 64, 57, 0.5); z-index: 200; display: none; opacity: 0; transition: opacity 0.3s ease; }
.modal-overlay.active { display: block; opacity: 1; }
.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.9); background: var(--bg-white); border-radius: var(--border-radius); box-shadow: var(--shadow-lg); z-index: 201; width: 90%; max-width: 600px; max-height: 90vh; overflow: hidden; display: none; opacity: 0; transition: var(--transition); }
.modal.active { display: block; opacity: 1; transform: translate(-50%, -50%) scale(1); }
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1200px; }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; background: var(--bg-beige); }
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.btn-close-modal { background: none; color: var(--text-light); font-size: 1.2rem; transition: var(--transition); }
.btn-close-modal:hover { color: var(--danger); }
.modal-body { padding: 20px; max-height: calc(90vh - 140px); overflow-y: auto; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; background: var(--bg-beige); }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 12px; }
.toast { display: flex; align-items: center; gap: 12px; padding: 14px 20px; background: var(--bg-white); border-radius: var(--border-radius); box-shadow: var(--shadow-lg); min-width: 300px; animation: slideIn 0.3s ease; border-left: 4px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-icon { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { background: rgba(107, 142, 107, 0.15); color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { background: rgba(193, 124, 116, 0.15); color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { background: rgba(212, 165, 116, 0.15); color: var(--warning); }
.toast-info { border-left-color: var(--info); }
.toast-info .toast-icon { background: rgba(122, 158, 184, 0.15); color: var(--info); }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-message { font-size: 0.85rem; color: var(--text-secondary); }
.toast-close { background: none; color: var(--text-light); padding: 4px; }
.toast-close:hover { color: var(--text-primary); }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 12px; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-group select { padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--border-radius); background: var(--bg-white); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; }
.pagination-btn { width: 36px; height: 36px; border: 1px solid var(--border-color); border-radius: var(--border-radius); background: var(--bg-white); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.pagination-btn:hover { border-color: var(--primary); color: var(--primary); }
.pagination-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.pagination-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Empty State */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state-icon { font-size: 4rem; color: var(--border-color); margin-bottom: 20px; }
.empty-state h3 { font-size: 1.25rem; margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); margin-bottom: 20px; }

/* Progress Bar */
.progress-bar { height: 8px; background: var(--bg-beige); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.progress-fill.blue { background: var(--info); }
.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--primary); }
.progress-fill.red { background: var(--danger); }

/* Avatar */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary); color: white; font-weight: 600; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.8rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.2rem; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 20px; background: var(--bg-white); border-radius: var(--border-radius) var(--border-radius) 0 0; }
.tab-item { padding: 14px 24px; color: var(--text-secondary); border-bottom: 3px solid transparent; transition: var(--transition); cursor: pointer; display: flex; align-items: center; gap: 8px; }
.tab-item:hover { color: var(--primary); background: var(--bg-beige); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--bg-white); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Segment Builder */
.segment-rules { background: var(--bg-beige); border-radius: var(--border-radius); padding: 20px; }
.rule-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 12px; background: var(--bg-white); border-radius: var(--border-radius); border: 1px solid var(--border-color); }
.rule-row select, .rule-row input { padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--border-radius); }
.rule-connector { padding: 8px 16px; background: var(--primary); color: white; border-radius: var(--border-radius); font-weight: 500; font-size: 0.8rem; }
.btn-add-rule { margin-top: 12px; }

/* Segment card layout */
.segment-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.segment-card-count {
    text-align: right;
    min-width: 80px;
    flex-shrink: 0;
}
.segment-card-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.segment-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* Widgets */
.widget-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 24px; }
.widget { background: var(--bg-card); border-radius: var(--border-radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); }
.widget-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; background: var(--bg-beige); }
.widget-header h4 { font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.widget-header h4 i { color: var(--primary); }
.widget-body { padding: 20px; }
.widget-list-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.widget-list-item:last-child { border-bottom: none; }

/* Automatisations */
.automation-card { background: var(--bg-card); border-radius: var(--border-radius); border: 1px solid var(--border-color); padding: 20px; margin-bottom: 16px; }
.automation-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.automation-info h4 { font-size: 1rem; margin-bottom: 4px; }
.automation-info p { color: var(--text-secondary); font-size: 0.85rem; }
.automation-flow { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--bg-beige); border-radius: var(--border-radius); flex-wrap: wrap; }
.flow-step { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--bg-white); border-radius: var(--border-radius); border: 1px solid var(--border-color); }
.flow-step i { color: var(--primary); }
.flow-arrow { color: var(--text-light); }

/* Charts */
.chart-container { position: relative; height: 300px; padding: 20px; }
.chart-legend { display: flex; justify-content: center; gap: 24px; margin-top: 16px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.legend-color { width: 12px; height: 12px; border-radius: 2px; }

/* Settings */
.settings-section { margin-bottom: 32px; }
.settings-section h3 { font-size: 1.1rem; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border-color); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }

/* Responsive */

/* Hamburger et drawer : invisibles sur desktop */
.btn-hamburger      { display: none; }
.mobile-nav-overlay { display: none; }
.mobile-nav-drawer  { display: none; }

/* ── 1200px : labels nav masqués, icônes seules ─────────────────── */
@media (max-width: 1200px) {
    .horizontal-nav .nav-item span { display: none; }
    .horizontal-nav .nav-item      { padding: 10px 12px; }
    .api-status span               { display: none; }
}

/* ── 768px : hamburger + drawer ─────────────────────────────────── */
@media (max-width: 768px) {

    /* Header : une seule ligne */
    .top-header      { height: 54px; padding: 0 12px; gap: 10px; flex-wrap: nowrap; }
    .header-brand    { border-right: none; padding-right: 0; }
    .header-brand small { display: none; }
    .horizontal-nav  { display: none !important; }
    .api-status      { display: none; }
    .btn-hub span    { display: none; }
    .btn-hub         { padding: 7px 10px; }
    .user-menu span  { display: none; }
    .header-actions  { margin-left: auto; gap: 6px; }

    /* Hamburger visible */
    .btn-hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        background: none;
        border: none;
        border-radius: 8px;
        font-size: 1.2rem;
        color: var(--text-primary);
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.15s;
    }
    .btn-hamburger:hover { background: var(--bg-beige); }

    /* Overlay : visible sur mobile, caché par opacité */
    .mobile-nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 400;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }
    .mobile-nav-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* Drawer : visible sur mobile, hors écran par défaut */
    .mobile-nav-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100%;
        background: var(--bg-card);
        z-index: 401;
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.18);
        overflow-y: auto;
    }
    .mobile-nav-drawer.open { transform: translateX(0); }

    .mobile-nav-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
        border-bottom: 1px solid var(--border-color);
        background: var(--bg-beige);
        flex-shrink: 0;
    }
    .mobile-nav-close {
        background: none;
        border: none;
        font-size: 1.2rem;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 4px 8px;
        border-radius: 6px;
    }
    .mobile-nav-close:hover { background: var(--border-color); }

    .mobile-nav-item {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 20px;
        color: var(--text-primary);
        font-size: 0.95rem;
        border-bottom: 1px solid var(--border-color);
        text-decoration: none;
        transition: background 0.15s;
    }
    .mobile-nav-item i { width: 20px; text-align: center; color: var(--primary); }
    .mobile-nav-item:hover  { background: var(--bg-beige); }
    .mobile-nav-item.active { background: var(--primary); color: white; }
    .mobile-nav-item.active i { color: white; }

    /* Contenu */
    .sub-header { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 14px; }
    .sub-header .search-box { width: 100%; }
    .sub-header .search-box input { width: 100%; }
    .content-area { padding: 12px; }

    /* Toolbar */
    .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
    .toolbar-left  { flex-wrap: wrap; gap: 8px; }
    .toolbar-right { flex-direction: column; align-items: stretch; gap: 8px; }
    .filter-group  { flex-wrap: wrap; gap: 6px; }
    .filter-group select { flex: 1; min-width: 130px; }
    .toolbar-right .search-box { width: 100%; }
    .toolbar-right .search-box input { width: 100%; }

    /* Tables */
    .table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 520px; }
    .data-table th, .data-table td { padding: 10px; font-size: 0.85rem; }
    .data-table .col-hide-mobile { display: none; }
    .data-table .actions-col { width: 80px; }

    /* Stats */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card  { padding: 14px; }
    .stat-card .value { font-size: 1.6rem; }

    /* Modals */
    .modal {
        width: 96% !important;
        max-width: none !important;
        top: 50% !important;
        left: 50% !important;
        max-height: 92vh;
    }
    .modal-lg, .modal-xl { max-width: none !important; }
    .modal-body   { padding: 14px; }
    .modal-footer { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .modal-footer .btn { flex: 1; justify-content: center; }

    /* Segments */
    .segment-card-top     { flex-direction: column; }
    .segment-card-count   { text-align: left; min-width: 0; }
    .segment-card-footer  { flex-direction: column; align-items: flex-start; }
    .segment-card-actions { width: 100%; }
    .segment-card-actions .btn-label { display: none; }
    .segment-card-actions .btn { flex: 1; justify-content: center; }

    /* Divers */
    .automation-flow { flex-wrap: wrap; }
    .flow-arrow      { display: none; }
    .form-row        { grid-template-columns: 1fr; }
    .settings-grid   { grid-template-columns: 1fr !important; }
    .pagination      { flex-wrap: wrap; justify-content: center; gap: 4px; }
    .tabs            { flex-wrap: wrap; gap: 4px; }
    .tab-item        { flex: 1; text-align: center; padding: 8px 10px; font-size: 0.82rem; }
    .toast-container { left: 12px; right: 12px; max-width: none; }
    .widget-grid     { grid-template-columns: 1fr; }
    .widget-list-item { flex-wrap: wrap; gap: 6px; }
}

/* ── 480px ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .content-area { padding: 10px 8px; }
    .data-table { min-width: 400px; }
    .data-table th, .data-table td { padding: 8px; font-size: 0.8rem; }
    .modal { top: 2% !important; transform: translateX(-50%) !important; max-height: 96vh; }
    .avatar.avatar-sm { width: 28px; height: 28px; font-size: 0.65rem; }
}

/* Utilitaires */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.hidden { display: none !important; }
/* ─── Info Button & Popover ─────────────────────────────────────── */
.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--border-color);
    background: var(--bg-beige);
    color: var(--primary);
    font-size: 0.65rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
    padding: 0;
    line-height: 1;
}
.info-btn:hover {
    border-color: var(--primary);
    color: white;
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(212,165,116,0.35);
}

/* Stat-card : le bouton flotte en haut à droite, au-dessus du contenu */
.stat-card { position: relative; }
.stat-card .info-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
}

.info-popover {
    position: fixed;
    z-index: 99999;
    display: none;
    max-width: 280px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--text-primary);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}
.info-popover.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ─── Info bouton dans le titre de module (sub-header) ───────────── */
#page-title .info-btn {
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
    border-width: 2px;
    position: static;   /* annule l'absolute des stat-card */
}
/* Popover module : un peu plus large, texte plus riche */
#page-title ~ * .info-popover,
.info-popover {
    max-width: 320px;
}

/* ─── Agent IA ───────────────────────────────────────────────────── */
.agent-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border-radius: var(--border-radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}
.agent-banner-icon {
    font-size: 2rem;
    width: 56px; height: 56px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.agent-banner h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.agent-banner p  { font-size: 0.85rem; opacity: 0.9; }
.agent-banner-warn {
    margin-left: auto;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.agent-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.agent-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.agent-tab:hover  { border-color: var(--primary); color: var(--primary); }
.agent-tab.active { background: var(--primary); border-color: var(--primary); color: white; }

.agent-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.agent-output {
    min-height: 200px;
    max-height: 480px;
    overflow-y: auto;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-primary);
}
.agent-output p  { margin-bottom: 10px; }
.agent-output h3 { font-size: 1rem; margin: 14px 0 6px; color: var(--text-primary); }
.agent-output h4 { font-size: 0.95rem; margin: 12px 0 6px; }
.agent-output h5 { font-size: 0.9rem; margin: 10px 0 4px; }
.agent-output ul { padding-left: 20px; margin-bottom: 10px; }
.agent-output li { margin-bottom: 4px; }
.agent-output hr { border: none; border-top: 1px solid var(--border-color); margin: 14px 0; }

.agent-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-light);
    gap: 10px;
    font-size: 0.9rem;
}
.agent-placeholder i { font-size: 2rem; opacity: 0.4; }

.agent-error {
    background: rgba(193,124,116,0.1);
    border: 1px solid var(--danger);
    border-radius: 8px;
    padding: 14px;
    color: var(--danger);
    font-size: 0.88rem;
    line-height: 1.6;
}

/* Typing dots */
.agent-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 20px;
    justify-content: center;
}
.agent-typing span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--primary);
    animation: agentBounce 1.2s infinite;
}
.agent-typing span:nth-child(2) { animation-delay: 0.2s; }
.agent-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes agentBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%            { transform: scale(1);   opacity: 1; }
}

/* Alerts contextuelles */
.agent-alerts { display: flex; flex-direction: column; gap: 8px; }
.agent-alert  {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: var(--bg-beige);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
    font-size: 0.85rem;
}

@media (max-width: 768px) {
    .agent-grid  { grid-template-columns: 1fr; }
    .agent-tabs  { gap: 6px; }
    .agent-tab   { padding: 8px 12px; font-size: 0.82rem; }
    .agent-banner { flex-wrap: wrap; }
    .agent-banner-warn { margin-left: 0; width: 100%; }
}

/* Agent IA — tab Profil */
.agent-tab-profil {
    margin-left: auto;
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.agent-tab-profil.active {
    background: var(--secondary);
    border-color: var(--secondary);
    color: white;
}
