/* =============================================================================
   KVM4 Admin Panel — Composants CSS (mobile-first)
   ============================================================================= */

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

.app-main {
    flex: 1;
    margin-left: 0;
    padding-top: var(--header-height);
    padding-bottom: var(--bottom-nav-height);
    transition: margin-left var(--transition-base);
}

@media (min-width: 1024px) {
    .app-main {
        margin-left: var(--drawer-width);
        padding-bottom: 0;
    }
}

.app-content {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: var(--space-4);
}

@media (min-width: 768px) {
    .app-content {
        padding: var(--space-6);
    }
}

/* -- Header ---------------------------------------------------------------- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    gap: var(--space-3);
    z-index: var(--z-header);
    transition: left var(--transition-base);
}

@media (min-width: 1024px) {
    .header {
        left: var(--drawer-width);
    }
}

.header__menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-md);
}

.header__menu-btn:hover {
    background: var(--bg-surface-hover);
}

@media (min-width: 1024px) {
    .header__menu-btn {
        display: none;
    }
}

.header__title {
    font-size: var(--text-lg);
    font-weight: 600;
    flex: 1;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-left: auto;
}

.header__actions .btn--icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.header__actions .btn--icon:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.header__actions .btn--icon svg {
    width: 20px;
    height: 20px;
}

/* -- Drawer (navigation laterale) ------------------------------------------ */
.drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--drawer-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-default);
    z-index: var(--z-drawer);
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.drawer.open {
    transform: translateX(0);
}

@media (min-width: 1024px) {
    .drawer {
        transform: translateX(0);
    }
}

.drawer__header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--header-height);
}

.drawer__logo {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--accent);
}

.drawer__version {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.drawer__section {
    padding: var(--space-3) var(--space-3) var(--space-1);
}

.drawer__section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 var(--space-2);
    margin-bottom: var(--space-1);
}

.drawer__nav {
    list-style: none;
}

.drawer__link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    margin: var(--space-1) var(--space-2);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.drawer__link:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.drawer__link.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 500;
}

.drawer__link-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.drawer__link.active .drawer__link-icon {
    opacity: 1;
}

.drawer__badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

.drawer__footer {
    margin-top: auto;
    padding: var(--space-4);
    border-top: 1px solid var(--border-default);
}

/* Overlay quand le drawer est ouvert en mobile */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: var(--z-overlay);
}

.drawer-overlay.visible {
    display: block;
}

@media (min-width: 1024px) {
    .drawer-overlay {
        display: none !important;
    }
}

/* -- Bottom nav (mobile) --------------------------------------------------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-surface);
    border-top: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: var(--z-bottom-nav);
}

@media (min-width: 1024px) {
    .bottom-nav {
        display: none;
    }
}

.bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-1) var(--space-2);
    color: var(--text-muted);
    font-size: var(--text-xs);
    cursor: pointer;
    text-decoration: none;
    border: none;
    background: none;
    transition: color var(--transition-fast);
}

.bottom-nav__item.active {
    color: var(--accent);
}

.bottom-nav__icon {
    width: 22px;
    height: 22px;
}

/* -- Boutons --------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn--secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.btn--secondary:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    border-color: var(--border-hover);
}

.btn--danger {
    background: var(--danger);
    color: #fff;
}
.btn--danger:hover:not(:disabled) {
    background: #dc2626;
}

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

.btn--sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn--xs {
    padding: 2px var(--space-2);
    font-size: 11px;
    line-height: 1.4;
}

.btn--lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

.btn--icon {
    width: 36px;
    height: 36px;
    padding: 0;
}

.btn--full {
    width: 100%;
}

/* -- Inputs / Forms -------------------------------------------------------- */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.form-label--required::after {
    content: ' *';
    color: var(--danger);
}

.input {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

.input--error {
    border-color: var(--danger);
}
.input--error:focus {
    box-shadow: 0 0 0 3px var(--danger-subtle);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--danger);
    margin-top: var(--space-1);
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* -- Aide contextuelle ----------------------------------------------------- */
.help-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-surface-hover);
    border-radius: var(--radius-full);
    cursor: help;
    margin-left: var(--space-1);
    vertical-align: middle;
}

.help-panel {
    display: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-panel.open {
    display: block;
}

.help-panel code {
    background: var(--bg-surface-active);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
}

/* -- Cards ----------------------------------------------------------------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.card:hover {
    border-color: var(--border-hover);
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-default);
}

.card__title {
    font-size: var(--text-base);
    font-weight: 600;
}

.card__body {
    padding: var(--space-4);
}

.card__footer {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-default);
    background: var(--bg-primary);
}

/* Grille de cards */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
}

@media (min-width: 640px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Variante 2 colonnes pour les charts */
.card-grid--2 {
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .card-grid--2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* -- Badge ----------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge--success {
    background: var(--success-subtle);
    color: var(--success);
}
.badge--warning {
    background: var(--warning-subtle);
    color: var(--warning);
}
.badge--danger {
    background: var(--danger-subtle);
    color: var(--danger);
}
.badge--info {
    background: var(--info-subtle);
    color: var(--info);
}
.badge--neutral {
    background: var(--bg-surface-active);
    color: var(--text-secondary);
}
.badge--accent {
    background: var(--accent-subtle, rgba(99, 102, 241, 0.12));
    color: var(--accent-primary);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* -- Toast (notifications) ------------------------------------------------- */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + var(--space-4));
    right: var(--space-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: 400px;
    width: calc(100% - var(--space-8));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toast-in 250ms ease-out;
    font-size: var(--text-sm);
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--info    { border-left: 3px solid var(--info); }

.toast__message {
    flex: 1;
    color: var(--text-primary);
}

.toast__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    font-size: var(--text-lg);
    line-height: 1;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast.removing {
    animation: toast-out 200ms ease-in forwards;
}

@keyframes toast-out {
    to { opacity: 0; transform: translateX(20px); }
}

/* -- Terminal (output temps reel) ------------------------------------------ */
.terminal {
    background: #0d1117;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.6;
    color: #c9d1d9;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 400px;
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal__line {
    display: block;
}

.terminal__line--info    { color: #58a6ff; }
.terminal__line--success { color: #3fb950; }
.terminal__line--warning { color: #d29922; }
.terminal__line--error   { color: #f85149; }
.terminal__line--step    { color: #bc8cff; font-weight: 500; }

.terminal__cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background: #c9d1d9;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* -- Modal ----------------------------------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 100%;
    animation: modal-in 200ms ease-out;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-default);
}

.modal__title {
    font-size: var(--text-lg);
    font-weight: 600;
}

.modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--text-xl);
    line-height: 1;
    padding: var(--space-1);
}

.modal__body {
    padding: var(--space-5);
}

.modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--border-default);
}

/* -- Tabs ------------------------------------------------------------------ */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: var(--space-4);
    overflow-x: auto;
}

.tab {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* -- Spinner --------------------------------------------------------------- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

.spinner--sm { width: 14px; height: 14px; }
.spinner--lg { width: 32px; height: 32px; border-width: 3px; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

.table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-default);
    color: var(--text-primary);
}

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

.table tr:hover td {
    background: var(--bg-surface-hover);
}

/* -- Page header ----------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.page-title {
    font-size: var(--text-2xl);
    font-weight: 700;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-top: var(--space-1);
}

/* -- Empty state ----------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-4);
    color: var(--text-muted);
}

.empty-state__icon {
    font-size: var(--text-3xl);
    margin-bottom: var(--space-3);
    opacity: 0.4;
}

.empty-state__text {
    font-size: var(--text-base);
    margin-bottom: var(--space-4);
}

/* -- Login ----------------------------------------------------------------- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-4);
}

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

.login-logo {
    text-align: center;
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--accent);
    margin-bottom: var(--space-2);
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-bottom: var(--space-6);
}

/* -- Steps indicator ------------------------------------------------------- */
.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-default);
    transition: all var(--transition-base);
}

.step-dot.active {
    background: var(--accent);
    width: 24px;
    border-radius: var(--radius-full);
}

.step-dot.done {
    background: var(--success);
}

/* -- Dashboard stats ------------------------------------------------------- */
.stat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.stat-error {
    color: var(--danger);
    text-align: center;
    padding: var(--space-4);
}

.stat-label {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.stat-value {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.stat-detail {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.stat-bar {
    height: 6px;
    background: var(--bg-primary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: var(--space-2);
}

.stat-bar__fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
}

.stat-bar__fill--danger {
    background: var(--danger);
}

.counter-card {
    text-align: center;
    padding: var(--space-4) !important;
}

.counter-icon {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-2);
    opacity: 0.6;
}

.counter-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}

.counter-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* -- Password generator ---------------------------------------------------- */
.pass-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.pass-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
}

.pass-option:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.pass-option.selected {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

/* -- Log viewer ------------------------------------------------------------ */
.log-viewer {
    background: #0d1117;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.5;
    color: #c9d1d9;
    overflow: auto;
    max-height: 500px;
    white-space: pre;
}

/* -- Detail row (expandable) ----------------------------------------------- */
.detail-row {
    display: none;
}

.detail-row.open {
    display: table-row;
}

.detail-row td {
    background: var(--bg-primary);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
}

/* -- Filter bar ------------------------------------------------------------ */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    align-items: flex-end;
}

.filter-bar .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

/* -- Pagination ------------------------------------------------------------ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-muted);
}

/* =============================================================================
   Chat
   ============================================================================= */

.chat-layout {
    display: flex;
    height: calc(100vh - var(--header-height) - var(--bottom-nav-height) - var(--space-8));
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-surface);
}

@media (min-width: 1024px) {
    .chat-layout {
        height: calc(100vh - var(--header-height) - var(--space-8));
    }
}

/* -- Sidebar canaux -------------------------------------------------------- */
.chat-sidebar {
    width: 240px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-default);
    background: var(--bg-primary);
    overflow-y: auto;
    display: none;
}

@media (min-width: 768px) {
    .chat-sidebar {
        display: flex;
        flex-direction: column;
    }
}

/* Mobile : sidebar en overlay */
.chat-sidebar--open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
    width: 260px;
    box-shadow: var(--shadow-lg);
}

.chat-sidebar__header {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-sidebar__section {
    padding: var(--space-3) var(--space-2);
}

.chat-sidebar__title {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 var(--space-2);
    margin-bottom: var(--space-1);
}

.chat-channel-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    margin: 1px 0;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chat-channel-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.chat-channel-item.active {
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 500;
}

.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

/* -- Zone messages --------------------------------------------------------- */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

.chat-main__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-surface);
    min-height: 48px;
}

.chat-main__back {
    display: inline-flex;
}

@media (min-width: 768px) {
    .chat-main__back {
        display: none;
    }
}

.chat-typing {
    font-size: var(--text-xs);
    color: var(--accent);
    font-style: italic;
    margin-left: auto;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.chat-typing.visible {
    opacity: 1;
}

/* -- Messages -------------------------------------------------------------- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.chat-msg {
    max-width: 85%;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    font-size: var(--text-sm);
}

.chat-msg--mine {
    align-self: flex-end;
    background: var(--accent-subtle);
}

.chat-msg--system {
    align-self: center;
    max-width: 100%;
    text-align: center;
    background: none;
    padding: var(--space-1) 0;
}

.chat-msg__header {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: 2px;
}

.chat-msg__author {
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--accent);
}

.chat-msg__time {
    font-size: 10px;
    color: var(--text-muted);
}

.chat-msg__body {
    word-break: break-word;
    white-space: pre-wrap;
    line-height: 1.4;
}

.chat-msg__system {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
}

/* -- Input bar ------------------------------------------------------------- */
.chat-input-bar {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--border-default);
    background: var(--bg-surface);
}

.chat-input-bar .input {
    flex: 1;
}

/* =============================================================================
   Guide certificats
   ============================================================================= */

.cert-guide__prereq {
    margin-bottom: var(--space-4);
}

.cert-guide__prereq ul {
    margin: var(--space-2) 0;
    padding-left: var(--space-5);
}

.cert-guide__prereq li {
    margin-bottom: var(--space-1);
}

.cert-guide__note {
    margin-top: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.cert-guide__platforms {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.cert-guide__card {
    overflow: hidden;
}

.cert-guide__card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    user-select: none;
}

.cert-guide__card-header:hover {
    background: var(--bg-tertiary);
}

.cert-guide__card-icon {
    flex-shrink: 0;
    color: var(--accent-primary);
}

.cert-guide__card-browser {
    display: block;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.cert-guide__chevron {
    margin-left: auto;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.cert-guide__steps {
    padding: 0 var(--space-4) var(--space-4);
}

.cert-guide__steps ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cert-guide__steps li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-top: 1px solid var(--border-default);
    line-height: 1.5;
}

.cert-guide__step-num {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 600;
}

.cert-guide__troubleshoot {
    margin-top: var(--space-4);
}

.cert-guide__faq details {
    border-top: 1px solid var(--border-default);
}

.cert-guide__faq details:first-child {
    border-top: none;
}

.cert-guide__faq summary {
    padding: var(--space-3) 0;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

.cert-guide__faq summary:hover {
    color: var(--accent-primary);
}

.cert-guide__faq details p {
    padding: 0 0 var(--space-3);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* =============================================================================
   Onboarding
   ============================================================================= */

.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.onboarding-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    max-width: 520px;
    width: 100%;
    padding: var(--space-6);
    text-align: center;
    animation: modal-in var(--transition-normal);
}

.onboarding-card h2 {
    margin-bottom: var(--space-2);
}

.onboarding-card p {
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
    line-height: 1.6;
}

.onboarding__steps {
    display: flex;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.onboarding__step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border-default);
    transition: background var(--transition-fast);
}

.onboarding__step-dot.active {
    background: var(--accent-primary);
}

.onboarding__step-dot.done {
    background: var(--success);
}

.onboarding__actions {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.onboarding__feature-list {
    text-align: left;
    margin: var(--space-3) 0;
    padding: 0;
    list-style: none;
}

.onboarding__feature-list li {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) 0;
    color: var(--text-secondary);
}

.onboarding__feature-list li::before {
    content: '';
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-primary);
    opacity: 0.2;
}

/* -- Onboarding : icône SVG dans les features -------------------------------- */
.onboarding__feature-list li svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.onboarding__feature-list li svg + span { flex: 1; }

/* Supprime le pseudo-élément quand une icône SVG est présente */
.onboarding__feature-list li:has(svg)::before { display: none; }

/* -- Onboarding : illustration bienvenue ------------------------------------- */
.onboarding__hero-icon {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-4);
}

.onboarding__hero-icon svg {
    width: 80px;
    height: 80px;
    color: var(--accent-primary);
    opacity: 0.85;
}

/* -- Onboarding : lien certificat -------------------------------------------- */
.onboarding__cert-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    margin-top: var(--space-2);
    transition: opacity var(--transition-fast);
}

.onboarding__cert-link:hover { opacity: 0.8; }

/* -- Tour interactif : highlight --------------------------------------------- */
.tour-highlight {
    position: relative;
    z-index: calc(var(--z-modal) + 2);
    box-shadow: 0 0 0 4px var(--accent-primary), 0 0 0 9999px rgba(0, 0, 0, 0.6);
    border-radius: var(--radius-md);
    transition: box-shadow var(--transition-normal);
}

/* -- Tour interactif : tooltip ----------------------------------------------- */
.tour-tooltip {
    position: fixed;
    z-index: calc(var(--z-modal) + 3);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    max-width: 340px;
    box-shadow: var(--shadow-xl, 0 20px 60px rgba(0,0,0,0.3));
    animation: tour-in 0.25s ease-out;
}

.tour-tooltip__title {
    font-weight: 600;
    margin-bottom: var(--space-2);
    color: var(--text-primary);
}

.tour-tooltip__text {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: 1.5;
    margin-bottom: var(--space-3);
}

.tour-tooltip__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

.tour-tooltip__arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    transform: rotate(45deg);
}

.tour-tooltip__arrow--top {
    top: -7px;
    left: 24px;
    border-bottom: none;
    border-right: none;
}

.tour-tooltip__arrow--bottom {
    bottom: -7px;
    left: 24px;
    border-top: none;
    border-left: none;
}

.tour-tooltip__arrow--left {
    left: -7px;
    top: 24px;
    border-top: none;
    border-right: none;
}

/* -- Tour interactif : stepper ----------------------------------------------- */
.tour-tooltip__steps {
    display: flex;
    gap: 6px;
    margin-bottom: var(--space-3);
}

.tour-tooltip__step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-default);
    transition: background var(--transition-fast);
}

.tour-tooltip__step-dot.active { background: var(--accent-primary); }
.tour-tooltip__step-dot.done { background: var(--success); }

@keyframes tour-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* -- VHost grouping -------------------------------------------------------- */
.vhost-group {
    margin-bottom: var(--space-6);
}

.vhost-children {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px dashed var(--border-default);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.vhost-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface-active);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-primary);
}

.vhost-child__info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    min-width: 0;
}

.vhost-child__domain {
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--text-primary);
    word-break: break-all;
}

/* -- Chat Drawer (panneau lateral droit) ---------------------------------- */
.chat-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.chat-drawer-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.chat-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-default);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-base);
}

.chat-drawer.open {
    transform: translateX(0);
}

.chat-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-surface);
    flex-shrink: 0;
}

.chat-drawer__header .btn--icon svg {
    width: 18px;
    height: 18px;
}

.chat-drawer__body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Adapter le chat-layout dans le drawer */
.chat-drawer__body .chat-layout {
    flex-direction: column;
    height: 100%;
}

.chat-drawer__body .chat-sidebar {
    flex-shrink: 0;
    width: 100%;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border-default);
    overflow: hidden;
}

.chat-drawer__body .chat-sidebar__header {
    display: none;
}

.chat-drawer__body .chat-sidebar__section {
    padding: var(--space-2) var(--space-3);
}

.chat-drawer__body .chat-sidebar__title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: var(--space-1);
}

.chat-drawer__body .chat-channel-item {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-sm);
}

/* Sections sidebar collapsibles */
.chat-drawer__body .chat-sidebar--collapsed .chat-sidebar__section:not(:first-child) {
    display: none;
}

.chat-drawer__body .chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-drawer__body .chat-main__back {
    display: none;
}

.chat-drawer__body .chat-main__header {
    padding: var(--space-2) var(--space-3);
}

.chat-drawer__body .chat-messages {
    flex: 1;
    overflow-y: auto;
}

/* Toggle sidebar dans le drawer */
.chat-drawer__sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    user-select: none;
}

.chat-drawer__sidebar-toggle:hover {
    background: var(--bg-surface-hover);
}

.chat-drawer__sidebar-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-fast);
}

.chat-drawer__sidebar-toggle.open svg {
    transform: rotate(180deg);
}

@media (max-width: 480px) {
    .chat-drawer {
        width: 100vw;
    }
}

/* -- Help Drawer ---------------------------------------------------------- */

.help-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.help-drawer-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.help-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 480px;
    max-width: 100vw;
    background: var(--bg-primary);
    border-left: 1px solid var(--border-default);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-base);
}

.help-drawer.open {
    transform: translateX(0);
}

.help-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-surface);
    flex-shrink: 0;
}

.help-drawer__header .btn--icon svg {
    width: 18px;
    height: 18px;
}

/* Table des matieres */
.help-drawer__toc {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-surface);
    flex-shrink: 0;
    max-height: 140px;
    overflow-y: auto;
}

.help-drawer__toc-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-decoration: none;
    transition: background var(--transition-base), color var(--transition-base);
    cursor: pointer;
}

.help-drawer__toc-item:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.help-drawer__toc-item.active {
    background: var(--accent);
    color: var(--text-on-accent, #fff);
}

.help-drawer__toc-icon {
    display: flex;
    width: 14px;
    height: 14px;
}

.help-drawer__toc-icon svg {
    width: 14px;
    height: 14px;
}

/* Contenu scrollable */
.help-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    scroll-behavior: smooth;
}

.help-drawer__section {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle, var(--border-default));
}

.help-drawer__section:last-child {
    border-bottom: none;
}

.help-drawer__section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
}

.help-drawer__section-icon {
    display: flex;
    width: 20px;
    height: 20px;
    color: var(--accent);
}

.help-drawer__section-icon svg {
    width: 20px;
    height: 20px;
}

.help-drawer__section-content {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
}

.help-drawer__section-content h4 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin: var(--space-3) 0 var(--space-2) 0;
}

.help-drawer__section-content ul,
.help-drawer__section-content ol {
    padding-left: var(--space-4);
    margin: var(--space-2) 0;
}

.help-drawer__section-content li {
    margin-bottom: var(--space-1);
}

.help-drawer__section-content code {
    background: var(--bg-surface);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
}

.help-drawer__section-content details {
    margin: var(--space-2) 0;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
}

.help-drawer__section-content details summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

.help-drawer__section-content details p {
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.help-note {
    margin-top: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-surface);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-style: italic;
}

/* Bouton aide contextuel dans les page-header */
[data-help].btn--ghost.btn--icon {
    opacity: 0.6;
    transition: opacity var(--transition-base);
}

[data-help].btn--ghost.btn--icon:hover {
    opacity: 1;
}

@media (max-width: 480px) {
    .help-drawer {
        width: 100vw;
    }
}
