/* ═══════════════════════════════════════════════════════════════
   VISION FINANCE — Layout shell (sidebar, topbar, main, bottom-nav)
   Extracted from templates/base.html — VIS-257 (F17 P1a)
   ═══════════════════════════════════════════════════════════════ */

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

html { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--t1);
    font-size: var(--font-base);
    font-weight: 400;
    line-height: 1.5;
    height: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

/* ════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════ */
.vf-sidebar {
    width: var(--sb-width-closed);
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width var(--transition);
    z-index: 100;
}
.vf-sidebar.open { width: var(--sb-width-open); }

/* Logo */
.sb-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 13px;
    border-bottom: 1px solid var(--sb-border);
    min-height: 44px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}
.sb-logo:hover { background: rgba(255,255,255,.03); }
.sb-logo-icon {
    width: 36px; height: 36px;
    background: transparent;
    border-radius: 6px;
    display: grid; place-items: center;
    flex-shrink: 0;
    overflow: hidden;
}
.sb-logo-icon img {
    width: 36px; height: 36px;
    object-fit: contain;
    display: block;
    mix-blend-mode: screen;
}

/* Nav */
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0; }
.sb-nav::-webkit-scrollbar { width: 2px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 1px; }

.sb-section-label {
    padding: 8px 14px 3px;
    font-size: 10.5px; font-weight: 600;
    color: rgba(255,255,255,.38);
    text-transform: uppercase; letter-spacing: .07em;
    white-space: nowrap;
    opacity: 0; transition: opacity .1s;
}
.vf-sidebar.open .sb-section-label { opacity: 1; }

/* Nav item */
.sb-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 13px;
    color: var(--sb-text);
    text-decoration: none;
    white-space: nowrap;
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: color .12s, background .12s;
    position: relative;
}
.sb-item:hover { color: var(--sb-text-hover); background: rgba(255,255,255,.04); text-decoration: none; }
.sb-item.active { color: #fff; background: var(--sb-active-bg); border-left-color: var(--sb-active-border); }
.sb-item i { font-size: var(--font-md); flex-shrink: 0; width: 16px; text-align: center; }
.sb-item-label { font-size: var(--font-sm); opacity: 0; transition: opacity .1s .04s; white-space: nowrap; flex: 1; }
.vf-sidebar.open .sb-item-label { opacity: 1; }

/* Collapse trigger chevron */
.sb-chevron { margin-left: auto; font-size: var(--font-2xs); opacity: 0; transition: opacity .1s, transform .2s; }
.vf-sidebar.open .sb-chevron { opacity: 1; }
.sb-item.open .sb-chevron { transform: rotate(180deg); }

/* Sub-items */
.sb-sub { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.sb-sub.open { max-height: 400px; }
.sb-sub .sb-item { padding-left: 34px; font-size: 11.5px; }
.sb-sub .sb-item i { font-size: var(--font-base); }

/* Badge NEW */
.sb-badge {
    font-size: var(--font-2xs); font-weight: 700;
    background: var(--accent); color: #fff;
    padding: 1px 5px; border-radius: 20px;
    flex-shrink: 0;
    opacity: 0; transition: opacity .1s;
}
.vf-sidebar.open .sb-badge { opacity: 1; }

/* Contact section */
.sb-contact {
    padding: 4px 0 2px;
    border-top: 1px solid var(--sb-border);
    flex-shrink: 0;
}

/* Footer */
.sb-footer {
    padding: 10px 13px;
    border-top: 1px solid var(--sb-border);
    display: flex; align-items: center; gap: 9px;
    flex-shrink: 0;
}
.sb-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--accent-bg);
    border: 1.5px solid var(--accent);
    display: grid; place-items: center;
    font-size: var(--font-2xs); font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}
.sb-username {
    font-size: var(--font-xs); color: rgba(255,255,255,.4);
    white-space: nowrap; flex: 1;
    opacity: 0; transition: opacity .1s .04s;
}
.vf-sidebar.open .sb-username { opacity: 1; }

/* Theme toggle in footer */
.sb-theme-btn {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.45);
    font-size: var(--font-md);
    padding: 6px; min-width: 32px; min-height: 32px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    opacity: 0; transition: opacity .1s, color .15s, background .15s;
}
.sb-theme-btn:hover { color: rgba(255,255,255,.85); background: rgba(255,255,255,.05); }
.vf-sidebar.open .sb-theme-btn { opacity: 1; }

/* ════════════════════════════════════════════
   TOPBAR
   ════════════════════════════════════════════ */
.vf-topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 16px; gap: 8px;
    flex-shrink: 0;
}
.tb-breadcrumb {
    font-size: var(--font-sm); color: var(--t2);
    display: flex; align-items: center; gap: 5px;
    flex: 1;
}
.tb-breadcrumb .current { color: var(--t1); font-weight: 500; }
.tb-sep { color: var(--t3); font-size: var(--font-2xs); }
.tb-icon-btn {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    display: grid; place-items: center;
    cursor: pointer; color: var(--t2);
    transition: background .12s, color .12s;
    flex-shrink: 0;
}
.tb-icon-btn:hover { background: var(--surface2); color: var(--t1); }
.tb-icon-btn i { font-size: var(--font-base); }
.tb-btn {
    height: 28px; padding: 0 12px;
    border-radius: var(--radius-sm);
    font-size: var(--font-xs); font-weight: 600;
    cursor: pointer; display: flex; align-items: center; gap: 5px;
    white-space: nowrap; text-decoration: none;
    transition: opacity .12s;
    border: none;
}
.tb-btn:hover { opacity: .85; text-decoration: none; }
.tb-btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--t2); }
.tb-btn-accent { background: var(--accent); color: #fff; }
.tb-avatar {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--accent-bg);
    border: 1.5px solid var(--accent);
    display: grid; place-items: center;
    font-size: var(--font-2xs); font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

/* ════════════════════════════════════════════
   MAIN CONTENT
   ════════════════════════════════════════════ */
.vf-main {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden; min-width: 0;
}
.vf-content {
    flex: 1; overflow-y: auto;
    padding: 20px;
}
.vf-content::-webkit-scrollbar { width: 3px; }
.vf-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ════ BOTTOM NAV MOBILE ════ */
.vf-bottom-nav {
    display: none;
}
@media (max-width: 768px) {
    .vf-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 300;
        background: var(--surface);
        border-top: 1px solid var(--border);
        height: calc(56px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
    }
    .vf-bn-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--t2);
        text-decoration: none;
        font-size: var(--font-xs);
        font-weight: 500;
        min-height: 44px;
        transition: color var(--transition-fast);
    }
    .vf-bn-item i { font-size: var(--font-xl); }
    .vf-bn-item.active { color: var(--accent); }
    .vf-bn-item:active { opacity: .7; }
}

/* Overlay sidebar mobile */
.vf-sidebar-overlay {
    display: none;
}
@media (max-width: 768px) {
    .vf-sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 199;
        background: rgba(0,0,0,.5);
        backdrop-filter: blur(2px);
    }
    .vf-sidebar-overlay.visible { display: block; }
}

/* Responsive */
@media (max-width: 768px) {
    /* Réserve la place de la .vf-bottom-nav (fixed, ~56px + safe-area) au niveau du shell — */
    /* le footer légal (sibling de .vf-content dans .vf-main) remonte ainsi au-dessus de la nav. */
    .vf-shell { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
    .vf-sidebar { position: fixed; z-index: 200; height: 100dvh; }
    .vf-sidebar:not(.open) { width: 0; border: none; }
    .vf-content { padding: 14px 16px; }
    /* iOS auto-zoom prevention — inputs must be >= 16px on mobile */
    .form-control, .form-select, input, textarea, select { font-size: var(--font-lg) !important; }
    /* Touch target minimum 44px (Apple HIG) */
    .sb-item { min-height: 44px; }
    .tb-icon-btn { min-width: 44px; min-height: 44px; }
}

/* ── Google Translate — masquer la barre native ── */
.goog-te-banner-frame, .goog-te-menu-frame { display: none !important; }
.skiptranslate { display: none !important; }
body { top: 0 !important; }
font { font-size: inherit !important; }

/* ── Language switcher ── */
.lang-opt {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 8px 12px;
    background: none; border: none; cursor: pointer;
    font-size: var(--font-sm); font-weight: 400; color: var(--t1);
    text-align: left; transition: background .1s; font-family: inherit;
}
.lang-opt:hover { background: var(--surface2); }
.lang-opt--active { font-weight: 700; color: var(--accent); }
.lang-opt__check { margin-left: auto; color: var(--accent); }
