/* Cockpit Design System — Master Manager ZDigital */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Thème Sombre Slate/Zinc par défaut */
    --bg-app: #090d16;
    --bg-sidebar: #0d1322;
    --bg-header: rgba(13, 19, 34, 0.85);
    --bg-card: #131c31;
    --bg-card-hover: #17223b;
    --bg-surface: #192540;
    --bg-input: #0e1526;
    --bg-badge: rgba(255, 255, 255, 0.05);
    --bg-hover: #192540;

    --border-subtle: #1e293b;
    --border-light: #26354d;
    --border-color: #1e293b;
    --border-focus: #6366f1;

    --text-primary: #f8fafc;
    --text-main: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;

    --brand-primary: #6366f1;
    --brand-primary-hover: #4f46e5;
    --brand-light: rgba(99, 102, 241, 0.15);

    --status-success: #10b981;
    --status-success-bg: rgba(16, 185, 129, 0.12);
    --status-warning: #f59e0b;
    --status-warning-bg: rgba(245, 158, 11, 0.12);
    --status-danger: #ef4444;
    --status-danger-bg: rgba(239, 68, 68, 0.12);
    --status-info: #0ea5e9;
    --status-info-bg: rgba(14, 165, 233, 0.12);
    --status-purple: #a855f7;
    --status-purple-bg: rgba(168, 85, 247, 0.12);

    --color-cost: #fb7185;
    --color-profit: #34d399;
    --color-brand: #818cf8;

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --sidebar-width: 240px;
    --header-height: 54px;
    --shadow-card: 0 4px 16px -4px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.03);
}

/* Commutateur Thème Clair */
html.light {
    --bg-app: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.95);
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-surface: #f1f5f9;
    --bg-input: #ffffff;
    --bg-badge: rgba(0, 0, 0, 0.05);
    --bg-hover: #f1f5f9;

    --border-subtle: #e2e8f0;
    --border-light: #cbd5e1;
    --border-color: #e2e8f0;
    --border-focus: #4f46e5;

    --text-primary: #0f172a;
    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-dim: #94a3b8;

    --brand-primary: #4f46e5;
    --brand-primary-hover: #4338ca;
    --brand-light: #eef2ff;

    --status-success: #059669;
    --status-success-bg: #ecfdf5;
    --status-warning: #d97706;
    --status-warning-bg: #fffbeb;
    --status-danger: #dc2626;
    --status-danger-bg: #fef2f2;
    --status-info: #0284c7;
    --status-info-bg: #f0f9ff;
    --status-purple: #7c3aed;
    --status-purple-bg: #f5f3ff;

    --color-cost: #e11d48;
    --color-profit: #059669;
    --color-brand: #4f46e5;

    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
}

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

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* Layout Cockpit Shell */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-subtle);
    gap: 10px;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.02em;
    color: #ffffff;
}

html.light .brand-logo {
    color: #0f172a;
}

.brand-icon {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 900;
    font-size: 13px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    padding: 8px 10px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12.5px;
    transition: all 0.15s ease;
}

.nav-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-item:hover {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--brand-light);
    color: var(--brand-primary);
    font-weight: 600;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}

.nav-item.active svg {
    opacity: 1;
    stroke: var(--brand-primary);
}

.nav-counter {
    background: var(--bg-badge);
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 600;
}

.nav-counter.alert {
    background: var(--status-danger-bg);
    color: var(--status-danger);
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.user-avatar {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 11px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-role {
    font-size: 10.5px;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Zone Principale */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-header);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Live Timer Widget */
.live-timer-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    padding: 4px 10px;
    border-radius: var(--radius-full);
}

.timer-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
}

.timer-indicator.running {
    background: var(--status-success);
    box-shadow: 0 0 8px var(--status-success);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.timer-clock {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.timer-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
    border-radius: var(--radius-xs);
    transition: color 0.15s;
}

.timer-btn:hover {
    color: var(--text-primary);
}

/* Boutons Utilitaires Header */
.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-light);
}

/* Boutons Généraux */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}

.btn-primary {
    background: var(--brand-primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--brand-primary-hover);
}

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

html.light .btn-secondary {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

html.light .btn-secondary:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #0f172a;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 11px;
}

/* Contenu Principal */
.app-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Flash Messages */
.flash-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 4px;
}

.flash-alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid transparent;
}

.flash-success {
    background: var(--status-success-bg);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--status-success);
}

.flash-danger {
    background: var(--status-danger-bg);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--status-danger);
}

.flash-warning {
    background: var(--status-warning-bg);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--status-warning);
}

.flash-info {
    background: var(--status-info-bg);
    border-color: rgba(14, 165, 233, 0.3);
    color: var(--status-info);
}

/* Grille de Métriques Haute Densité */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.metric-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-value {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.metric-icon.indigo {
    background: var(--brand-light);
    color: var(--brand-primary);
}

.metric-icon.emerald {
    background: var(--status-success-bg);
    color: var(--status-success);
}

.metric-icon.amber {
    background: var(--status-warning-bg);
    color: var(--status-warning);
}

.metric-icon.sky {
    background: var(--status-info-bg);
    color: var(--status-info);
}

/* Layout Deux Colonnes Cockpit */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

/* Cartes Cockpit */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 16px;
}

.card-body.p-0 {
    padding: 0;
}

/* Container responsive pour tableaux */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
}

/* Design System Universel des Tableaux Haute Densité */
.table, table.dense-table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 12.5px;
    line-height: 1.45;
    text-align: left;
}

.table thead, .dense-table thead {
    background-color: var(--bg-surface);
}

.table th, .dense-table th {
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

html.light .table th, html.light .dense-table th {
    background-color: #f8fafc;
    color: #475569;
    border-bottom: 1px solid #cbd5e1;
}

.table td, .dense-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
    transition: background-color 0.1s ease;
}

html.light .table td, html.light .dense-table td {
    border-bottom: 1px solid #f1f5f9;
}

.table tbody tr:hover td, .dense-table tbody tr:hover td {
    background-color: var(--bg-card-hover);
}

.table tbody tr:last-child td, .dense-table tbody tr:last-child td {
    border-bottom: none;
}

.table th.text-center, .table td.text-center { text-align: center; }
.table th.text-right, .table td.text-right { text-align: right; }

/* Badges de Statut & Contrats */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 7px;
    border-radius: var(--radius-xs);
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-todo {
    background: var(--bg-badge);
    color: var(--text-muted);
}

.badge-progress, .badge-in_progress {
    background: var(--status-info-bg);
    color: var(--status-info);
}

.badge-review {
    background: var(--status-warning-bg);
    color: var(--status-warning);
}

.badge-waiting, .badge-waiting_client {
    background: var(--status-purple-bg);
    color: var(--status-purple);
}

.badge-done, .badge-resolved {
    background: var(--status-success-bg);
    color: var(--status-success);
}

.badge-urgent, .badge-high {
    background: var(--status-danger-bg);
    color: var(--status-danger);
}

/* Badges de types de contrat */
.badge-forfait {
    background: rgba(99, 102, 241, 0.12);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.25);
}
html.light .badge-forfait {
    background: #eef2ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
}

.badge-regie {
    background: rgba(14, 165, 233, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.25);
}
html.light .badge-regie {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.badge-tma {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.25);
}
html.light .badge-tma {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

/* Classes Utilitaires Couleurs & Typographie */
.text-cost {
    color: var(--color-cost) !important;
}

.text-profit {
    color: var(--color-profit) !important;
}

.text-brand {
    color: var(--color-brand) !important;
}

.font-mono {
    font-family: var(--font-mono) !important;
}

/* Barre de progression budget */
.budget-progress {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 100px;
}

.progress-track {
    width: 100%;
    height: 5px;
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--brand-primary);
    border-radius: var(--radius-full);
}

.progress-fill.over {
    background: var(--status-danger);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-dim);
}

/* Formulaires & Inputs */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 13px;
    transition: all 0.15s;
    outline: none;
    width: 100%;
}

.form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px var(--brand-light);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-check input[type="checkbox"] {
    accent-color: var(--brand-primary);
    width: 14px;
    height: 14px;
}

/* Page d'authentification */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(circle at 50% 20%, #151d33 0%, var(--bg-app) 70%);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-top: 10px;
}

.auth-subtitle {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 4px;
}
