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

:root {
    --accent:       #02489E;
    --accent-light: #E8F0FB;
    --accent-dark:  #013270;

    --text-primary:   #111827;
    --text-secondary: #6B7280;
    --text-muted:     #9CA3AF;

    --border:    #E5E7EB;
    --border-md: #D1D5DB;

    --bg:        #FFFFFF;
    --bg-subtle: #F9FAFB;
    --bg-hover:  #F3F4F6;

    --sidebar-w: 224px;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow:    0 4px 16px rgba(0,0,0,.08);

    --font: 'Montserrat', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

html, body { height: 100%; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-subtle);
    -webkit-font-smoothing: antialiased;
}

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

/* ─── Layout ────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; border-radius: 4px; transition: background .2s; }
.sidebar:hover::-webkit-scrollbar-thumb { background: var(--border-md); }

.sidebar-brand {
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-brand-logo {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-brand-name {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--text-primary);
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-section {
    padding: 14px 10px 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: color .12s, background .12s;
    position: relative;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sidebar-link.active {
    color: var(--accent);
    background: var(--accent-light);
    font-weight: 600;
}

.sidebar-link i {
    font-size: 15px;
    flex-shrink: 0;
    opacity: .6;
}

.sidebar-link:hover i { opacity: .8; }
.sidebar-link.active i { opacity: 1; }

.sidebar-link i {
    font-size: 15px;
    opacity: .7;
    flex-shrink: 0;
}

.sidebar-link.active i { opacity: 1; }

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

.sidebar-user-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.sidebar-user-role {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* ─── Main ──────────────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 56px;
    flex-shrink: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 12px;
}

.topbar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.page-body {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-body { padding: 24px; }

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

.card-header-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-icon {
    font-size: 18px;
    color: var(--accent);
    margin-bottom: 12px;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    line-height: 1;
}

.btn-sm { padding: 7px 14px; font-size: 13px; font-weight: 500; }
.btn-lg { padding: 13px 28px; font-size: 15px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

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

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-md);
}
.btn-outline:hover { background: var(--bg-hover); }

.btn-danger {
    background: transparent;
    color: #DC2626;
    border-color: #FECACA;
}
.btn-danger:hover { background: #FEF2F2; }

.btn-icon {
    padding: 7px;
    border-radius: var(--radius-sm);
}

/* ─── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 9px 13px;
    font-size: 13.5px;
    color: var(--text-primary);
    background: var(--bg);
    border: 1px solid var(--border-md);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(2,72,158,.12);
}

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

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

select.form-control { cursor: pointer; }

.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 5px;
}

.form-error {
    font-size: 12px;
    color: #DC2626;
    margin-top: 5px;
}

/* Checkboxes in Forms (e.g., expanded ChoiceType) */
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.form-group .form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.form-group .form-check label {
    margin-bottom: 0;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
}

/* Fallback for native symfony rendering without custom classes */
.form-group > div > div {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.form-group > div > div > label {
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ─── Detail ────────────────────────────────────────────────── */
.detail-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail-value {
    font-size: 13.5px;
    color: var(--text-primary);
}

/* ─── Table ─────────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

thead {
    background: var(--bg-subtle);
}

th {
    padding: 11px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--bg-subtle); }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 99px;
}

.badge-primary { background: var(--accent-light); color: var(--accent); }
.badge-indigo  { background: var(--accent-light); color: var(--accent); }
.badge-green   { background: #DCFCE7; color: #16A34A; }
.badge-gray    { background: var(--bg-hover); color: var(--text-secondary); }
.badge-orange  { background: #FEF3C7; color: #D97706; }
.badge-red     { background: #FEE2E2; color: #DC2626; }

/* ─── Page header ────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}

.page-header-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.page-header-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ─── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
.alert-error   { background: #FEE2E2; color: #B91C1C; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: var(--accent-light); color: var(--accent-dark); border: 1px solid #B3CBE8; }

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: .6;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}
.alert-close:hover { opacity: 1; }

/* ─── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
}

.empty-state-icon {
    font-size: 40px;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: .4;
}

.empty-state-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

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

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow);
}

.login-logo {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    margin-bottom: 24px;
}

.login-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 28px;
}

/* ─── Divider ────────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}

/* ─── Table toolbar ─────────────────────────────────────────── */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.table-search {
    position: relative;
    flex: 1;
    max-width: 320px;
}

.table-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
}

.table-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg);
    border: 1px solid var(--border-md);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-family: var(--font);
}

.table-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(2,72,158,.12);
}

.table-search input::placeholder { color: var(--text-muted); }

/* Barre de sélection flottante */
.selection-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
}

.selection-bar.visible { display: flex; }

.selection-bar-count { flex: 1; }

.selection-bar .btn-close-sel {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.selection-bar .btn-close-sel:hover { background: rgba(255,255,255,.35); }

/* Checkbox */
.cb-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

.cb-wrap input[type=checkbox] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--accent);
}

tr.selected td { background: var(--accent-light) !important; }

/* Ligne masquée par la recherche */
tr.search-hidden { display: none; }

/* Compteur résultats */
.table-results {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .12s;
    text-decoration: none;
}

.pagination-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.pagination-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
    cursor: default;
}

.pagination-btn.disabled {
    opacity: .35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── Utility ───────────────────────────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent   { color: var(--accent); }
.text-danger   { color: #DC2626; }
.text-success  { color: #16A34A; }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

.d-flex        { display: flex; }
.align-center  { align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.gap-16        { gap: 16px; }
.flex-1        { flex: 1; }

.w-full { width: 100%; }
