/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #1A2B3C;
    background-color: #f5f7fa;
}

/* Colors Palette */
:root {
    --primary: #4DC94B;
    --primary-dark: #38A83C;
    --primary-rgb: 77, 201, 75;
    --secondary: #243B55;
    --danger: #e74c3c;
    --success: #27ae60;
    --warning: #f39c12;
    --info: #3498db;
    --light: #f5f7fa;
    --dark: #1A2B3C;
    --text: #1A2B3C;
    --text-muted: #5a6a7a;
    --text-light: #8a9bac;
    --border: #e8edf2;
    --shadow-sm: 0 2px 4px rgba(26, 43, 60, 0.06);
    --shadow-md: 0 2px 8px rgba(26, 43, 60, 0.09);
    --shadow-lg: 0 10px 40px rgba(26, 43, 60, 0.18);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 {
    font-size: 32px;
}

h2 {
    font-size: 24px;
}

h3 {
    font-size: 18px;
}

p {
    margin-bottom: 1rem;
}

/* Links */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(var(--primary-rgb), 0.35);
}

.btn-secondary {
    background-color: #edf1f5;
    color: var(--text-muted);
}

.btn-secondary:hover {
    background-color: #dde4ec;
}

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

.btn-danger:hover {
    background-color: #c0392b;
}

/* Forms */
input, textarea, select {
    font-family: inherit;
    font-size: 14px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(77, 201, 75, 0.15);
}

/* Containers */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.card-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.card-header h2 {
    margin: 0;
}

.card-body {
    padding: 0;
}

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

/* Navbar */
.navbar {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.navbar-brand img {
    height: 10.5px;
    display: block;
}

.navbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    font-weight: 600;
    color: var(--dark);
    pointer-events: none;
}

.navbar-center img {
    height: 42.53px;
    display: block;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto;
}

.user-info {
    font-size: 14px;
    color: var(--text-muted);
}

.user-email {
    font-weight: 500;
    color: var(--dark);
}

.logout-btn {
    padding: 8px 16px;
    background-color: #edf1f5;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s;
}

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

/* Subnav */
.subnav {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    justify-content: center;
}

.subnav-link {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.subnav-link:hover {
    color: var(--dark);
    border-bottom-color: var(--primary);
}

.subnav-link.active {
    color: var(--dark);
    border-bottom-color: var(--primary);
}

/* Subnav — icônes monochromes des liens */
.subnav-home-icon,
.subnav-ico { display: block; flex-shrink: 0; }

/* Subnav dropdown */
.subnav-dropdown {
    position: relative;
    display: flex;
    align-items: stretch;
}

.subnav-dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
}

.subnav-caret {
    font-size: 10px;
    transition: transform 0.2s;
}

.subnav-dropdown:hover .subnav-caret {
    transform: translateY(1px);
}

.subnav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
    z-index: 1000;
}

.subnav-dropdown:hover .subnav-dropdown-menu,
.subnav-dropdown:focus-within .subnav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.subnav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.15s, color 0.15s;
}

.subnav-dropdown-icon {
    font-size: 16px;
    line-height: 1;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.subnav-dropdown-item:hover {
    background-color: rgba(var(--primary-rgb), 0.1);
    color: var(--dark);
}

.subnav-dropdown-item.active {
    color: var(--primary-dark);
    background-color: rgba(var(--primary-rgb), 0.12);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

thead {
    background-color: var(--light);
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

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

tbody tr:hover {
    background-color: #f8fafb;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.text-light {
    color: var(--text-light);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.d-flex {
    display: flex;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.gap-4 { gap: 2rem; }

.hidden {
    display: none !important;
}

/* Stats block */
.stats-kpi-row { display: flex; gap: 14px; margin-bottom: 28px; }
.stats-kpi {
    flex: 1;
    background: #f8fafb;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 16px;
    text-align: center;
}
.stats-kpi-value { font-size: 34px; font-weight: 700; color: var(--dark); line-height: 1; margin-bottom: 6px; }
.stats-kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stats-chart-wrap { position: relative; height: 260px; }
.stats-block-loading { color: var(--text-muted); font-size: 14px; padding: 40px 0; text-align: center; }

/* RAG documents (listebot — API recherche_rag) */
.rag-docs-panel {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    background: #f8fafc;
}
.rag-docs-title {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
}
.rag-docs-upload-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}
.rag-doc-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #e8edf2;
    font-size: 13px;
}
.rag-doc-row:last-child {
    border-bottom: none;
}
.btn-rag-doc-delete {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--danger);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 16px;
    }

    .container {
        padding: 0 16px;
    }

    .card {
        padding: 16px;
    }
}
