/*
 * Layout CakePHP 5 — Sidebar icon-only bleu foncé
 * Fichier : webroot/css/layout.css
 * ================================================
 */

/* ── Variables ─────────────────────────────────── */
:root {
    --sidebar-width:       64px;
    --topbar-height:       60px;
    --footer-height:       44px;

    /* Palette sidebar */
    --sidebar-bg:          #0d1b2a;
    --sidebar-border:      #1a2d42;
    --sidebar-icon:        #7da9cc;
    --sidebar-icon-hover:  #ffffff;
    --sidebar-active-bg:   #1a3a5c;
    --sidebar-active-icon: #4da6ff;
    --sidebar-brand-icon:  #4da6ff;

    /* Surface & texte */
    --topbar-bg:           #ffffff;
    --topbar-border:       #e9ecef;
    --main-bg:             #f4f6f9;
    --footer-bg:           #ffffff;
    --footer-border:       #e9ecef;
    --heading-color:       #1a2d42;
    --text-muted:          #6c757d;
}

/* ── Reset de base ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body.layout-wrapper {
    display: flex;
    min-height: 100vh;
    margin: 0;
    background-color: var(--main-bg);
    font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    overflow: hidden;
    z-index: 1030;
    transition: transform .25s ease;
}

/* Brand / Logo */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--topbar-height);
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--sidebar-brand-icon);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    transition: background .2s, color .2s;
}

.sidebar-brand-link:hover {
    background: var(--sidebar-active-bg);
    color: #fff;
}

.sidebar-brand-icon { font-size: 1.6rem; }

/* Navigation links */
.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 4px auto;
    border-radius: 10px;
    color: var(--sidebar-icon);
    font-size: 1.2rem;
    text-decoration: none;
    transition: background .18s, color .18s;
    position: relative;
}

.sidebar-nav-link:hover,
.sidebar-nav-link:focus-visible {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-icon-hover);
}

.sidebar-nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-icon);
    box-shadow: inset 3px 0 0 var(--sidebar-active-icon);
}

.sidebar-nav-link--danger:hover {
    background: rgba(220, 53, 69, .15);
    color: #ff6b6b;
}

/* Séparateur sidebar */
.sidebar-divider {
    border-color: var(--sidebar-border);
    margin: 4px 12px;
    opacity: 1;
}

/* ── Main wrapper ───────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar-inner { width: 100%; }

.topbar-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--heading-color);
    letter-spacing: -.01em;
}

/* Bouton icône topbar */
.topbar-icon-btn,
.btn-ghost-secondary {
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
    padding: 0;
}

.topbar-icon-btn:hover,
.btn-ghost-secondary:hover {
    background: var(--main-bg);
    color: var(--heading-color);
}

.topbar-user-btn {
    width: auto;
    padding: 0 10px;
    height: 36px;
    gap: .4rem;
}

/* ── Contenu principal ──────────────────────────── */
.main-content {
    flex: 1 1 auto;
    padding-bottom: var(--footer-height);
}

/* ── Footer ─────────────────────────────────────── */
.main-footer {
    height: var(--footer-height);
    display: flex;
    align-items: center;
    background: var(--footer-bg);
    border-top: 1px solid var(--footer-border);
    padding: 0;
}

/* ── Flash messages ─────────────────────────────── */
.message,
.alert {
    border-radius: 8px;
    font-size: .875rem;
}

/* ── Responsive mobile ──────────────────────────── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .sidebar.sidebar--open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,.25);
    }

    .main-wrapper {
        margin-left: 0;
    }

    /* Overlay semi-transparent quand sidebar ouverte */
    body.sidebar-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 1029;
    }
}

/* ── Scrollbar sidebar (optionnel) ──────────────── */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 2px; }
