/* ==========================================================================
   KopilotEI — Feuille de style principale (100% CSS Natif)
   ========================================================================== */

:root {
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-dark: #0f172a;
    --border: #e2e8f0;
    --border-dark: #1e293b;

    --text-dark: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;

    --primary: #059669;
    --primary-hover: #047857;
    --danger: #e11d48;
    --danger-light: #fff1f2;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --info: #2563eb;
    --info-light: #eff6ff;

    --radius: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.5;
}

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

.sidebar {
    width: 260px;
    background-color: var(--bg-dark);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 100;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.main-content {
    flex: 1;
    padding: 28px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* --- Sidebar --- */
.sidebar-logo-box {
    padding: 16px;
    border-bottom: 1px solid var(--border-dark);
}

.sidebar-logo-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sidebar-logo-card img {
    max-height: 44px;
    max-width: 100%;
    object-fit: contain;
}

.sidebar-user {
    padding: 12px 16px;
    background: rgba(0,0,0,0.25);
    border-bottom: 1px solid var(--border-dark);
}

.sidebar-user .company-name {
    font-weight: 700;
    color: #f8fafc;
    font-size: 13px;
}

.sidebar-user .user-name {
    color: var(--text-light);
    font-size: 11px;
}

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

.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    font-weight: 700;
    padding: 12px 12px 6px 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background-color: #1e293b;
    color: #ffffff;
}

.nav-link.active {
    background-color: var(--primary);
    color: #ffffff;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-dark);
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background: #1e293b;
    color: #cbd5e1;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
}

.btn-logout:hover {
    background: #881337;
    color: #fecdd3;
}

/* --- Barre Mobile --- */
.mobile-header {
    display: none;
    background-color: var(--bg-dark);
    color: white;
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.menu-toggle-btn {
    background: #1e293b;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 95;
}

/* --- Cartes & Grilles --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

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

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-dark);
    margin: 6px 0 2px 0;
    font-family: monospace;
}

.stat-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Formulaires & Boutons --- */
.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 160px;
}

.form-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease;
}

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

.btn-dark {
    background: var(--bg-dark);
    color: white;
}
.btn-dark:hover {
    background: #1e293b;
}

/* --- Tableaux --- */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.data-table th {
    background: #f8fafc;
    padding: 12px 14px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.data-table tr:hover td {
    background-color: #f1f5f9;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
}
.badge-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }
.badge-success { background: #ecfdf5; color: var(--primary); border: 1px solid #a7f3d0; }
.badge-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #fecdd3; }

/* --- Footer --- */
.app-footer {
    background: #ffffff;
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* --- Media Queries Mobile / Tablette --- */
@media (max-width: 1024px) {
    .mobile-header { display: flex; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    .main-content { padding: 16px; }
}