/* ═══════════════════════════════════════
   CRM Méridien Digital — Design System
   ═══════════════════════════════════════ */

/* --- Variables --- */
:root {
    --bg: #070706;
    --bg-card: #1C1B17;
    --bg-card-hover: #2A2820;
    --bg-sidebar: #0E0E0C;
    --bg-input: #16150F;
    --gold: #C4A35A;
    --gold-light: #DDB96E;
    --gold-dim: rgba(196, 163, 90, 0.15);
    --gold-gradient: linear-gradient(135deg, #C4A35A, #DDB96E);
    --text: #EDE8DC;
    --text-muted: rgba(237, 232, 220, 0.55);
    --text-dim: rgba(237, 232, 220, 0.3);
    --danger: #E74C3C;
    --success: #2ECC71;
    --warning: #F39C12;
    --info: #3498DB;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 4px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-w: 260px;
    --header-h: 64px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@300;400;500;600;700&family=Instrument+Serif:ital@1&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Unbounded', sans-serif; font-weight: 500; }
.font-serif { font-family: 'Instrument Serif', serif; font-style: italic; }

a { color: var(--gold); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold-light); }

/* --- Curseur doré --- */
/* body { cursor: none; } */
.cursor-dot {
    width: 8px; height: 8px;
    background: var(--gold);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    transition: transform 0.1s;
    mix-blend-mode: difference;
}

/* ═══════ LOGIN PAGE ═══════ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid rgba(196, 163, 90, 0.2);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow);
}

.login-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 20px rgba(196, 163, 90, 0.3));
}

.login-card h1 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.login-card code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    color: var(--gold);
}

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

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid rgba(196, 163, 90, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(196, 163, 90, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
}

.sidebar-brand {
    font-family: 'Unbounded', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-brand small {
    display: block;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.65rem;
    font-weight: 400;
    -webkit-text-fill-color: var(--text-muted);
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 400;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    position: relative;
}

.nav-item:hover {
    background: var(--gold-dim);
    color: var(--text);
}

.nav-item.active {
    background: var(--gold-dim);
    color: var(--gold);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--gold-gradient);
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    opacity: 0.7;
    flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--gold-dim);
    color: var(--gold);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* --- Sidebar footer (user) --- */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(196, 163, 90, 0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--gold-dim);
}

.sidebar-user-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Main content --- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
}

.main-header {
    height: var(--header-h);
    border-bottom: 1px solid rgba(196, 163, 90, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    background: rgba(7, 7, 6, 0.9);
    backdrop-filter: blur(12px);
    z-index: 50;
}

.main-header h1 {
    font-size: 1.1rem;
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-content {
    padding: 32px;
}

/* --- Hamburger mobile --- */
.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 8px;
}

.hamburger svg { width: 24px; height: 24px; }

/* ═══════ COMPOSANTS ═══════ */

/* --- Boutons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-gold {
    background: var(--gold-gradient);
    color: #070706;
}
.btn-gold:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(196, 163, 90, 0.3);
    color: #070706;
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(196, 163, 90, 0.3);
    color: var(--gold);
}
.btn-outline:hover {
    background: var(--gold-dim);
    border-color: var(--gold);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 8px 12px;
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(1.1); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

.btn:disabled, .btn.loading {
    opacity: 0.5;
    pointer-events: none;
}
.btn.loading::after {
    content: '';
    width: 14px; height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid rgba(196, 163, 90, 0.08);
    border-radius: var(--radius);
    padding: 24px;
    transition: all var(--transition);
}

.card:hover {
    border-color: rgba(196, 163, 90, 0.15);
    box-shadow: var(--shadow-sm);
}

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

.card-title {
    font-size: 0.9rem;
    font-weight: 500;
}

/* --- KPI Cards --- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid rgba(196, 163, 90, 0.08);
    border-radius: var(--radius);
    padding: 20px 24px;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.kpi-value {
    font-family: 'Unbounded', sans-serif;
    font-size: 1.8rem;
    font-weight: 600;
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.kpi-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Formulaires --- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid rgba(196, 163, 90, 0.15);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    transition: border-color var(--transition);
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.1);
}

.form-input::placeholder { color: var(--text-dim); }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23C4A35A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select option { background: var(--bg-card); color: var(--text); }

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

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

/* --- Tables --- */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid rgba(196, 163, 90, 0.08);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead {
    background: rgba(196, 163, 90, 0.06);
}

th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(196, 163, 90, 0.1);
}

td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

tr:hover td { background: rgba(196, 163, 90, 0.03); }

/* --- Badges / Statuts --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-prospect { background: rgba(52, 152, 219, 0.15); color: #3498DB; }
.badge-demo_envoyee { background: rgba(155, 89, 182, 0.15); color: #9B59B6; }
.badge-devis { background: rgba(243, 156, 18, 0.15); color: #F39C12; }
.badge-signe { background: rgba(46, 204, 113, 0.15); color: #2ECC71; }
.badge-en_prod { background: rgba(196, 163, 90, 0.15); color: #C4A35A; }
.badge-actif { background: rgba(46, 204, 113, 0.2); color: #2ECC71; }
.badge-perdu { background: rgba(231, 76, 60, 0.15); color: #E74C3C; }

.badge-up { background: rgba(46, 204, 113, 0.15); color: #2ECC71; }
.badge-down { background: rgba(231, 76, 60, 0.15); color: #E74C3C; }
.badge-warning { background: rgba(243, 156, 18, 0.15); color: #F39C12; }
.badge-unknown { background: rgba(255,255,255,0.08); color: var(--text-muted); }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.status-dot.up { background: var(--success); box-shadow: 0 0 8px rgba(46,204,113,0.4); }
.status-dot.down { background: var(--danger); box-shadow: 0 0 8px rgba(231,76,60,0.4); }
.status-dot.warning { background: var(--warning); box-shadow: 0 0 8px rgba(243,156,18,0.4); }

/* --- Kanban --- */
.kanban {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
}

.kanban-column {
    min-width: 280px;
    max-width: 320px;
    flex-shrink: 0;
}

.kanban-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--bg-card);
    border: 1px solid rgba(196, 163, 90, 0.08);
    border-bottom: 2px solid var(--gold-dim);
}

.kanban-title {
    font-size: 0.8rem;
    font-weight: 500;
}

.kanban-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 10px;
}

.kanban-cards {
    min-height: 100px;
    padding: 8px;
    background: rgba(28, 27, 23, 0.5);
    border: 1px solid rgba(196, 163, 90, 0.05);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid rgba(196, 163, 90, 0.1);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all var(--transition);
}

.kanban-card:hover {
    border-color: var(--gold);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.kanban-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.kanban-card-name {
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.kanban-card-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.kanban-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.04);
}

/* --- Modal / Slide-over --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid rgba(196, 163, 90, 0.15);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title { font-size: 1.1rem; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1.5rem;
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* --- Slide-over (panneau droit) --- */
.slideover {
    position: fixed;
    top: 0;
    right: -500px;
    width: 480px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid rgba(196, 163, 90, 0.15);
    z-index: 250;
    overflow-y: auto;
    transition: right var(--transition);
    box-shadow: -8px 0 32px rgba(0,0,0,0.4);
    padding: 24px;
}
.slideover.active { right: 0; }

/* --- Toast notifications --- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid rgba(196, 163, 90, 0.2);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease;
    min-width: 280px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Gauge circulaire --- */
.gauge {
    width: 80px;
    height: 80px;
    position: relative;
}
.gauge svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}
.gauge circle {
    fill: none;
    stroke-width: 6;
}
.gauge .bg { stroke: rgba(255,255,255,0.06); }
.gauge .fill { stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.gauge-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.3; margin-bottom: 16px; }
.empty-state p { font-size: 0.9rem; }

/* --- Animations --- */
.fade-in {
    animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid rgba(196, 163, 90, 0.1);
    margin-bottom: 24px;
}
.tab {
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* --- Grille responsive --- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(196, 163, 90, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(196, 163, 90, 0.4); }

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .hamburger {
        display: block;
    }
    .page-content {
        padding: 16px;
    }
    .kanban {
        flex-direction: column;
    }
    .kanban-column {
        min-width: 100%;
        max-width: 100%;
    }
    .modal {
        width: 95%;
        padding: 20px;
    }
    .slideover {
        width: 100vw;
    }
}
