/* b4cextract — même charte que gestionAPI.php (coque sombre) et aiassistAPI.php (contenu clair) */

* { margin: 0; padding: 0; box-sizing: border-box; font-family: Arial, sans-serif; }
html, body { height: 100%; }
button { font: inherit; }

/* ---------- Coque (gestionAPI) ---------- */
.app-body, .login-body {
    background: #0A1421;
    background-image: radial-gradient(circle at 50% 0%, rgba(47, 168, 199, 0.06), transparent 60%);
    color: #FFFFFF;
}
.app-body { display: flex; flex-direction: column; overflow: hidden; }
.page-header-wrap { border-bottom: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; }
.page-header { display: flex; align-items: center; gap: 14px; padding: 22px 24px; }
/* Logo Board4care (img/logo-board4care.png, fond transparent) */
.page-logo { width: 42px; height: 42px; object-fit: contain; flex-shrink: 0; display: block; }
.page-title { color: #BFE0F5; font-size: 18px; font-weight: bold; }
.page-title small { display: block; color: #6E86A8; font-size: 12px; font-weight: normal; margin-top: 2px; }
.page-user { margin-left: auto; display: flex; align-items: center; gap: 10px; color: #A9BDD6; font-size: 13.5px; }
.page-user i { color: #2FA8C7; }
.logout-btn {
    background: transparent; border: 1px solid #33506E; color: #A9BDD6; border-radius: 8px;
    padding: 6px 10px; cursor: pointer; transition: border-color .15s, color .15s;
}
.logout-btn:hover { border-color: #E15C5C; color: #FFFFFF; }
.logout-btn i { color: inherit; }

.page-body { padding: 24px; display: flex; gap: 28px; flex: 1; min-height: 0; overflow: hidden; }

.sidebar { width: 250px; flex-shrink: 0; height: 100%; overflow-y: auto; }
.sidebar-section { margin-bottom: 12px; }
.sidebar-group {
    display: flex; align-items: center; gap: 12px; background: #16283F;
    border: 1px solid rgba(255,255,255,0.06); border-radius: 10px; padding: 14px 16px; cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}
.sidebar-group:hover { border-color: #2FA8C7; background: #1B3350; }
.sidebar-section.open .sidebar-group { border-color: #2FA8C7; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.sidebar-group-icon {
    width: 38px; height: 38px; border-radius: 9px; background: rgba(47,168,199,0.16); color: #2FA8C7;
    display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0;
    transition: background .15s ease, color .15s ease;
}
.sidebar-section.open .sidebar-group-icon { background: #2FA8C7; color: #06131F; }
.sidebar-group-label { color: #E4EEF7; font-weight: 600; font-size: 14px; flex: 1; }
.sidebar-group-chevron { color: #6E86A8; font-size: 12px; transition: transform .2s ease, color .15s ease; }
.sidebar-section.open .sidebar-group-chevron { transform: rotate(180deg); color: #2FA8C7; }
.sidebar-menu {
    display: flex; flex-direction: column; max-height: 0; overflow: hidden; background: #101E30;
    border: 1px solid rgba(255,255,255,0.06); border-top: none; border-radius: 0 0 10px 10px;
    transition: max-height .25s ease;
}
.sidebar-section.open .sidebar-menu { max-height: 1400px; }
/* Sous-menu (Référentiel → Tables de référence) */
.sidebar-sub-chevron { margin-left: auto; font-size: 10px !important; color: #6E86A8 !important; transition: transform .2s ease; }
.sidebar-subtoggle.open .sidebar-sub-chevron { transform: rotate(180deg); }
.sidebar-submenu { display: none; flex-direction: column; border-top: 1px solid rgba(255,255,255,0.04); background: #0C1828; }
.sidebar-submenu.open { display: flex; }
.sidebar-submenu .sidebar-link { padding: 7px 14px 7px 36px; font-size: 12.5px; }
.sidebar-submenu .sidebar-link i { font-size: 11px; }
.sidebar-submenu .count { margin-left: auto; color: #6E86A8; font-size: 11px; }
.sidebar-submenu .missing { color: #6E86A8; font-style: italic; }
/* Consultation d'une table de référence */
.ref-table-wrap { overflow: auto; max-height: 68vh; border: 1px solid #DCE9EF; border-radius: 8px; }
.ref-table-wrap .tbl { border: none; border-radius: 0; }
.ref-table-wrap .tbl th { position: sticky; top: 0; z-index: 1; }
.ref-table-wrap mark { background: #FFF1B8; padding: 0; }
.sidebar-link {
    display: flex; align-items: center; gap: 11px; padding: 10px 16px 10px 20px; cursor: pointer;
    color: #A9BDD6; font-size: 13.5px; transition: background .12s ease, color .12s ease;
}
.sidebar-link:hover, .sidebar-link.active { background: rgba(47,168,199,0.1); color: #FFFFFF; }
.sidebar-link i { width: 16px; text-align: center; color: #2FA8C7; font-size: 14px; }

.content-area {
    flex: 1; min-width: 0; height: 100%; background: #16283F; border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
}
.content-area-title {
    display: flex; align-items: center; gap: 10px; padding: 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08); color: #E4EEF7; font-size: 14.5px; font-weight: 600;
}
.content-area-title i { color: #2FA8C7; width: 18px; text-align: center; }
.content-scroll { flex: 1; min-height: 0; overflow-y: auto; background: #EAF3F7; }

/* ---------- Contenu clair (aiassistAPI) ---------- */
.view { padding: 24px 28px; color: #16283F; font-size: 13.5px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
.btn {
    display: inline-flex; align-items: center; gap: 8px; background: #FFFFFF; border: 1px solid #C9DCE6;
    color: #16283F; border-radius: 8px; padding: 9px 15px; font-size: 13.5px; font-weight: 500; cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .1s ease;
    box-shadow: 0 1px 3px rgba(22,40,63,0.06); text-decoration: none; white-space: nowrap;
}
.btn i { color: #2FA8C7; width: 16px; text-align: center; }
.btn:hover:not(:disabled) { border-color: #2FA8C7; background: #F2FAFC; transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #2FA8C7; border-color: #2FA8C7; color: #06131F; font-weight: 600; }
.btn-primary i { color: #06131F; }
.btn-primary:hover:not(:disabled) { background: #3BB7D6; border-color: #3BB7D6; }
.btn-danger:hover:not(:disabled) { border-color: #E15C5C; background: #FDF1F1; }
.btn-danger i { color: #E15C5C; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

.panel {
    background: #FFFFFF; border: 1px solid #DCE9EF; border-radius: 10px; padding: 20px 22px;
    box-shadow: 0 2px 10px rgba(22,40,63,0.05); margin-bottom: 18px;
}
.panel-title { font-weight: 700; color: #16283F; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel-title i { color: #2FA8C7; }
.muted { color: #5C7891; }
.empty { color: #A9BDD6; font-style: italic; }

/* Formulaires */
.form-grid { display: grid; grid-template-columns: 180px 1fr; gap: 12px 16px; align-items: center; max-width: 720px; }
.form-grid label { text-align: right; color: #5C7891; }
input[type=text], input[type=number], input[type=password], input[type=email], input[type=tel], select {
    border: 1px solid #C9DCE6; border-radius: 7px; padding: 8px 10px; font-size: 13.5px; color: #16283F; background: #FFF;
}
input:focus, select:focus { outline: none; border-color: #2FA8C7; box-shadow: 0 0 0 3px rgba(47,168,199,0.15); }
.check { display: flex; align-items: center; gap: 8px; color: #16283F; }
.upload-box { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; max-width: 640px; }
.upload-box .dropzone { width: 100%; }
.dropzone {
    border: 2px dashed #9CCBDB; border-radius: 10px; padding: 30px; text-align: center; color: #5C7891;
    background: #F7FBFD; cursor: pointer; transition: border-color .15s, background .15s; grid-column: 1 / -1;
}
.dropzone.over, .dropzone:hover { border-color: #2FA8C7; background: #EEF8FB; }
.dropzone i { font-size: 30px; color: #2FA8C7; display: block; margin-bottom: 10px; }
.dropzone strong { color: #16283F; }

/* Tableaux */
.tbl { width: 100%; border-collapse: collapse; background: #FFF; border: 1px solid #DCE9EF; border-radius: 8px; overflow: hidden; }
.tbl th { background: #F3F8FB; color: #5C7891; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; text-align: left; padding: 10px 12px; border-bottom: 1px solid #DCE9EF; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid #EEF4F7; vertical-align: top; word-break: break-word; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: #F2FAFC; }
.tbl tr.sub td { background: #FAFCFD; }
.tbl tr.sub td:first-child { padding-left: 28px; }
.tbl code { font-family: Consolas, monospace; font-size: 12.5px; color: #0B5C73; }
.icon-btn { color: #B8C7D1; cursor: pointer; font-size: 15px; padding: 2px 5px; transition: color .15s; background: none; border: none; }
.icon-btn:hover { color: #2FA8C7; }
.icon-btn.del:hover { color: #E15C5C; }

/* Statuts */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-idle { background: #EEF2F5; color: #5C7891; }
.badge-run { background: #E6F5FA; color: #137C98; }
.badge-wait { background: #FFF5E0; color: #A06A00; }
.badge-ok { background: #E7F7EE; color: #1E7A46; }
.badge-ko { background: #FDECEC; color: #B33A3A; }

/* Pipeline */
.pipeline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.step { border: 1px solid #DCE9EF; border-radius: 10px; padding: 14px 16px; background: #F7FBFD; display: flex; flex-direction: column; gap: 10px; }
.step-head { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: #DCE9EF; color: #16283F; display: flex; align-items: center; justify-content: center; font-size: 12.5px; }
.step.done { border-color: #BFE6CF; background: #F3FBF6; }
.step.done .step-num { background: #1E7A46; color: #FFF; }
.step.running { border-color: #9CCBDB; background: #EEF8FB; }
.step.running .step-num { background: #2FA8C7; color: #06131F; }
.step.failed { border-color: #F2C4C4; background: #FDF5F5; }
.step.failed .step-num { background: #E15C5C; color: #FFF; }
.step-meta { color: #5C7891; font-size: 12.5px; min-height: 16px; }
.alert { border-radius: 8px; padding: 10px 14px; margin-top: 14px; display: flex; gap: 10px; align-items: flex-start; }
.alert-ko { background: #FDECEC; color: #8E2B2B; border: 1px solid #F2C4C4; }
.alert-info { background: #EEF8FB; color: #0B5C73; border: 1px solid #BEE3F2; }

/* Méta-données */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: #5C7891; }
.kv dd { color: #16283F; font-weight: 500; word-break: break-all; }

/* Onglets */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid #DCE9EF; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
    background: transparent; border: none; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer;
    color: #5C7891; font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.tab i { color: #9CB3C4; }
.tab:hover { color: #16283F; }
.tab.active { color: #16283F; border-bottom-color: #2FA8C7; }
.tab.active i { color: #2FA8C7; }
.tab:disabled { color: #C2D0DA; cursor: not-allowed; }
.tab:disabled i { color: #D4DEE5; }

.viewer { width: 100%; height: 72vh; border: 1px solid #DCE9EF; border-radius: 8px; background: #FFF; }
.viewer-img { max-width: 100%; border: 1px solid #DCE9EF; border-radius: 8px; background: #FFF; }

/* Sections repliables (aia-result-section) */
.section { background: #F7FBFD; border: 1px solid #DCE9EF; border-radius: 8px; margin-bottom: 12px; overflow: hidden; }
.section-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; user-select: none; }
.section-head .title { font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; color: #16283F; flex: 1; }
.section-head .chev { color: #2FA8C7; font-size: 12px; transition: transform .2s ease; }
.section.open .section-head .chev { transform: rotate(180deg); }
.section-body { display: none; padding: 0 14px 14px; }
.section.open .section-body { display: block; }

/* Modale + toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(6,19,31,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #16283F; color: #E4EEF7; border: 1px solid #33506E; border-radius: 12px; padding: 22px 24px; width: 440px; max-width: 92vw; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.modal-title { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.modal-wide { width: 1000px; max-width: 94vw; }
.modal-wide .toolbar input { background: #0F1D2E; border-color: #33506E; color: #FFF; }
.json-view {
    background: #0B1624; color: #CFE6F3; border: 1px solid #33506E; border-radius: 8px; padding: 14px 16px;
    max-height: 66vh; overflow: auto; font-family: Consolas, 'Courier New', monospace; font-size: 12.5px; line-height: 1.45;
    white-space: pre; margin-bottom: 16px;
}
.json-view mark { background: #F4C542; color: #06131F; border-radius: 2px; }
.keymap-link { background: none; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; color: #0B5C73; padding: 2px 0; }
.keymap-link i { color: #2FA8C7; }
.keymap-link:hover code { text-decoration: underline; }
.modal-text { color: #A9BDD6; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal .btn { box-shadow: none; }
#toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #16283F; color: #E4EEF7; border-left: 4px solid #2FA8C7; padding: 11px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: 420px; font-size: 13.5px; }
.toast.ko { border-left-color: #E15C5C; }
.toast.ok { border-left-color: #3CB371; }

.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Connexion ---------- */
.login-body { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: #16283F; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 28px; width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: 16px; }
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; color: #A9BDD6; font-size: 13px; }
.login-card input { background: #0F1D2E; border-color: #33506E; color: #FFF; }
.login-card .btn { justify-content: center; }
.login-error { background: rgba(225,92,92,.15); color: #F3B4B4; border: 1px solid rgba(225,92,92,.4); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.login-info { background: rgba(47,168,199,.14); color: #BFE0F5; border: 1px solid rgba(47,168,199,.4); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.login-card.wide { width: 600px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.login-card select { background: #0F1D2E; border-color: #33506E; color: #FFF; }
.login-text { color: #A9BDD6; font-size: 13.5px; line-height: 1.5; }
.login-text strong { color: #E4EEF7; }
.login-hint { color: #6E86A8; font-size: 12px; margin-top: -4px; }
.login-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.login-actions form { display: inline; }
.link-btn { background: none; border: none; color: #2FA8C7; cursor: pointer; font-size: 13px; text-decoration: none; padding: 0; display: inline-flex; gap: 6px; align-items: center; }
.link-btn:hover { color: #BFE0F5; text-decoration: underline; }
.btn-ghost { background: transparent; border-color: #33506E; color: #E4EEF7; box-shadow: none; justify-content: center; }
.btn-ghost i { color: #2FA8C7; }
.btn-ghost:hover:not(:disabled) { background: #1B3350; border-color: #2FA8C7; }
.login-sep { display: flex; align-items: center; gap: 10px; color: #6E86A8; font-size: 12px; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; border-top: 1px solid #33506E; }
.code-input { font-size: 26px !important; letter-spacing: 10px; text-align: center; font-family: 'Courier New', monospace; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.login-kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; }
.login-kv dt { color: #6E86A8; }
.login-kv dd { color: #E4EEF7; font-weight: 600; word-break: break-all; }
@media (max-width: 640px) { .login-grid { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
    .page-body { flex-direction: column; overflow-y: auto; padding: 16px; }
    .sidebar { width: 100%; height: auto; }
    .content-area { height: auto; min-height: 70vh; }
    .pipeline { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid label { text-align: left; }
}
