/* ==========================================================================
   Alliance-Franco — Styles de l'administration
   S'appuie sur les variables et composants de style.css.
   ========================================================================== */

body.admin { background: #F4F2ED; }
.d-block { display: block; }
.small { font-size: .85rem; }

/* ---------- Structure ---------- */
.admin-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px;
    padding: 24px 16px; background: var(--ink); color: rgba(255, 255, 255, .7); overflow-y: auto;
}
.sidebar .brand { padding: 0 8px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.side-nav a, .side-bottom a, .side-bottom button {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border-radius: 10px;
    color: rgba(255, 255, 255, .72); text-decoration: none; font: 500 .94rem var(--font);
    background: none; border: 0; cursor: pointer; text-align: left; transition: background .2s, color .2s;
}
.side-nav a:hover, .side-bottom a:hover, .side-bottom button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav a.is-active { background: rgba(200, 161, 90, .16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.side-nav a.is-active .icon { color: var(--gold); }
.nav-count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--gold); color: var(--ink); font-size: .75rem; font-weight: 700; text-align: center; }
.side-bottom { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 16px; }
.sidebar-backdrop { display: none; }

.admin-main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
    padding: 14px 32px; background: rgba(244, 242, 237, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.sidebar-toggle { display: none; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-btn:hover { border-color: var(--gold); color: var(--gold-dark); }
.topbar-search { position: relative; flex: 1; max-width: 460px; }
.topbar-search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar-search input { padding: 10px 14px 10px 42px; border-radius: 999px; background: var(--surface); }
.topbar-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-name { display: flex; flex-direction: column; font-weight: 600; font-size: .9rem; line-height: 1.2; color: var(--ink); }
.topbar-name small { color: var(--muted); font-weight: 400; font-size: .78rem; }
.avatar { display: inline-grid; place-items: center; flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: var(--gold); font-weight: 700; font-size: .85rem; }
.avatar-soft { background: var(--gold-soft); color: var(--gold-dark); }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.4rem; }

.admin-content { flex: 1; width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 32px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: clamp(1.5rem, 2.5vw, 2rem); margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-intro { color: var(--muted); margin: -8px 0 24px; }
.admin-footer { padding: 18px 32px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.admin-footer p { margin: 0; }
.admin-footer strong { color: var(--gold-dark); }

/* ---------- Panneaux ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-flush > .panel-head { padding: 20px 22px 0; }
.panel-flush .empty-state { padding: 40px 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-head h2 { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; margin: 0; }
.panel-head h2 .icon { color: var(--gold-dark); }
.panel-head a { font-size: .88rem; font-weight: 600; text-decoration: none; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 22px; border-top: 1px solid var(--line); font-size: .88rem; }
.panel-danger { border-color: rgba(184, 58, 51, .25); background: #FFFBFA; }
.empty-state { text-align: center; color: var(--muted); padding: 20px; }
.empty-state p { margin: 10px 0 0; }
.group-title { font-family: var(--font); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }

/* ---------- Indicateurs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
    display: flex; flex-direction: column; gap: 4px; padding: 20px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; transition: border-color .2s, transform .2s var(--ease);
}
a.kpi:hover { border-color: var(--gold); transform: translateY(-2px); color: var(--text); }
.kpi-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; margin-bottom: 8px; }
.kpi-warning { background: var(--warning-bg); color: var(--warning); }
.kpi-success { background: var(--success-bg); color: var(--success); }
.kpi-gold { background: var(--gold-soft); color: var(--gold-dark); }
.kpi-info { background: var(--info-bg); color: var(--info); }
.kpi-label { font-size: .85rem; color: var(--muted); }
.kpi-value { font-family: var(--font-display); font-size: 2rem; line-height: 1.1; color: var(--ink); }
.kpi-money { font-size: 1.45rem; }
.kpi-sub { font-size: .8rem; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.dash-grid .panel { margin-bottom: 20px; }

/* Graphique en barres (CSS pur) */
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 220px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar { width: 100%; max-width: 46px; height: var(--h); min-height: 4px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%); transition: height .6s var(--ease); }
.bar-col:last-child .bar { background: linear-gradient(180deg, var(--ink-3) 0%, var(--ink) 100%); }
.bar-value { font-size: .8rem; font-weight: 700; color: var(--ink); }
.bar-label { font-size: .78rem; color: var(--muted); }

.hbar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.hbar-label { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 6px; }
.hbar { display: block; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.hbar span { display: block; height: 100%; border-radius: inherit; background: var(--ink); }

.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li + li { border-top: 1px solid var(--line); }
.event-list a { display: flex; align-items: center; gap: 14px; padding: 12px 4px; text-decoration: none; color: var(--text); border-radius: 8px; }
.event-list a:hover { background: var(--bg); }
.event-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.event-info strong { color: var(--ink); }
.event-info small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 50px; height: 52px; border-radius: 12px; background: var(--gold-soft); color: var(--gold-dark); font-size: .72rem; text-transform: uppercase; flex-shrink: 0; line-height: 1.1; }
.date-chip strong { font-family: var(--font-display); font-size: 1.3rem; color: var(--ink); }

/* ---------- Onglets, filtres, tableaux ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a span { padding: 0 8px; border-radius: 999px; background: var(--surface-2); font-size: .75rem; }
.tabs a.is-active { color: var(--ink); border-color: var(--gold); }
.tabs a.is-active span { background: var(--ink); color: #fff; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters-search { flex: 1 1 260px; }
.filters select { width: auto; flex: 0 1 200px; }
.filters input, .filters select { padding-block: 9px; }

.table-admin td { font-size: .9rem; }
.table-admin tbody tr:hover { background: #FCFBF8; }
.table-admin th:first-child, .table-admin td:first-child { padding-left: 22px; }
.table-admin th:last-child, .table-admin td:last-child { padding-right: 22px; }
.ref-link { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; font-size: .85rem; text-decoration: none; }
.actions-col { width: 60px; text-align: right; }
.client-cell { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.status-form { margin: 0; }
.status-select { width: auto; padding: 5px 28px 5px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; border-width: 1px; }
.status-en_attente { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.status-confirmee { background: var(--success-bg); color: var(--success); border-color: transparent; }
.status-terminee { background: var(--info-bg); color: var(--info); border-color: transparent; }
.status-annulee { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.pagination { display: flex; gap: 4px; flex-wrap: wrap; }
.page-link { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; font-weight: 600; font-size: .85rem; color: var(--ink); }
.page-link:hover { border-color: var(--gold); }
.page-link.is-current { background: var(--ink); border-color: var(--ink); color: #fff; }
.page-gap { padding: 0 4px; color: var(--muted); align-self: center; }

/* ---------- Pages de détail ---------- */
.detail-hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; padding: 24px; margin-bottom: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.detail-hero h2 { font-size: 1.4rem; margin: 10px 0 4px; }
.detail-hero p { margin: 0; }
.detail-total { display: flex; flex-direction: column; align-items: flex-end; padding: 14px 20px; border-radius: var(--radius-sm); background: var(--ink); color: rgba(255, 255, 255, .7); font-size: .85rem; }
.detail-total strong { font-family: var(--font-display); font-size: 1.6rem; color: #fff; }
.detail-total small { color: var(--gold); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.detail-side .panel { margin-bottom: 20px; }

.row-muted td { background: var(--bg); }
select.input-sm, input.input-sm { width: auto; padding: 6px 10px; font-size: .88rem; }
input.input-qty { width: 90px; padding: 6px 10px; text-align: right; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.inline-form select { flex: 1 1 260px; width: auto; padding-block: 9px; }
.inline-form .input-qty { padding-block: 9px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-full { grid-column: 1 / -1; }
.field-end { display: flex; align-items: flex-end; justify-content: flex-end; }
.field-check { display: flex; align-items: center; }

.status-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.status-option { position: relative; cursor: pointer; }
.status-option input { position: absolute; opacity: 0; }
.status-option span { display: block; padding: 9px; border-radius: 10px; text-align: center; font-weight: 600; font-size: .85rem; border: 2px solid transparent; opacity: .6; transition: all .2s; }
.status-option input:checked + span { opacity: 1; border-color: currentColor; }
.status-option input:focus-visible + span { outline: 3px solid rgba(200, 161, 90, .55); }

.client-card { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.client-card strong { color: var(--ink); }
.client-card-center { flex-direction: column; text-align: center; gap: 6px; }
.contact-list { list-style: none; padding: 0; margin: 0 0 12px; }
.contact-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: .9rem; overflow-wrap: anywhere; }
.contact-list .icon { color: var(--gold-dark); }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.mini-stats div { padding: 12px; border-radius: 10px; background: var(--bg); text-align: center; }
.mini-stats strong { display: block; color: var(--ink); font-size: 1rem; }
.mini-stats span { font-size: .78rem; color: var(--muted); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9A2F29; color: #fff; }
.link-danger { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; color: var(--danger); font: 600 .85rem var(--font); cursor: pointer; }
.link-danger:hover { text-decoration: underline; }

/* ---------- Catalogue (éléments dépliables) ---------- */
.editable { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface); }
.editable[open] { border-color: var(--gold); box-shadow: var(--shadow-sm); }
.editable summary { display: flex; align-items: center; gap: 14px; padding: 10px 14px; cursor: pointer; list-style: none; }
.editable summary::-webkit-details-marker { display: none; }
.editable .option-icon { width: 40px; height: 40px; }
.editable-name { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.editable-name strong { color: var(--ink); }
.editable-name small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editable-price { font-weight: 700; color: var(--ink); white-space: nowrap; }
.editable-price small { font-weight: 400; color: var(--muted); }
.editable-toggle { color: var(--muted); }
.editable > form:not(.editable-delete) { padding: 16px 16px 0; border-top: 1px solid var(--line); }
.editable-delete { padding: 0 16px 14px; }
.editable.is-inactive summary { opacity: .6; }
.editable-new { border-style: dashed; }
.editable-new summary { color: var(--gold-dark); font-weight: 600; }

/* ---------- Connexion ---------- */
.login-page { background: var(--bg); }
.login-shell { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-visual { display: grid; place-items: center; padding: 48px; background: var(--ink); color: rgba(255, 255, 255, .7); }
.login-visual > div { max-width: 460px; }
.login-visual .illustration { max-width: 380px; margin-bottom: 32px; }
.login-visual h2 { color: #fff; font-size: 1.8rem; }
.login-form-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { margin-bottom: 36px; }
.login-card h1 { font-size: 2rem; margin-bottom: 4px; }
.login-card > .muted { margin-bottom: 24px; }
.login-card .btn { margin-top: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 20px; font-size: .9rem; text-decoration: none; color: var(--muted); }
.login-footer { margin: 40px 0 0; font-size: .8rem; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
    .admin-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 60; transform: translateX(-100%); transition: transform .3s var(--ease); }
    body.sidebar-open .sidebar { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .35); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(14, 24, 45, .45); }
    .sidebar-toggle { display: inline-grid; }
    .dash-grid, .detail-grid { grid-template-columns: 1fr; }
    .login-shell { grid-template-columns: 1fr; }
    .login-visual { display: none; }
}

@media (max-width: 720px) {
    .topbar { padding: 12px 16px; }
    .topbar-name { display: none; }
    .admin-content { padding: 20px 16px 40px; }
    .admin-footer { padding: 16px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi { padding: 14px; }
    .kpi-value { font-size: 1.5rem; }
    .kpi-money { font-size: 1.05rem; }
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .filters select { flex: 1 1 45%; }
    .editable-price { display: none; }
    .detail-total { align-items: flex-start; width: 100%; }

    /* Tableaux transformés en cartes */
    .table-admin thead { display: none; }
    .table-admin, .table-admin tbody, .table-admin tr, .table-admin td { display: block; width: 100%; }
    .table-admin tr { padding: 12px 16px; border-bottom: 1px solid var(--line); position: relative; }
    .table-admin td { border: 0; padding: 4px 0 !important; text-align: left; }
    .table-admin td[data-label]::before { content: attr(data-label); display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
    .table-admin td.num { text-align: left; }
    .table-admin .actions-col { position: absolute; top: 12px; right: 16px; width: auto; }
}

@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .status-picker { grid-template-columns: 1fr; }
}

/* ---------- Impression ---------- */
@media print {
    .sidebar, .topbar, .page-actions, .admin-footer, .no-print, .alert { display: none !important; }
    .admin-shell, .detail-grid { display: block; }
    .panel, .detail-hero { border: 1px solid #ddd; break-inside: avoid; }
    .input-qty, .input-sm { border: 0; padding: 0; }
}
