/* layout.css — app shell, topbar, sidebar, bottom-nav, auth */

/* ============ APP SHELL ============ */
.app-body {
    min-height: 100dvh;
    background: var(--color-bg);
}
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100dvh;
}
.app-content {
    display: flex; flex-direction: column;
    min-width: 0;
}
.app-main {
    flex: 1;
    padding: 20px 24px calc(var(--bottom-nav-h) + 24px);
    max-width: 100%;
    overflow-x: hidden;
}
.app-container {
    max-width: var(--content-max);
    margin: 0 auto;
    width: 100%;
}

/* ============ SIDEBAR (desktop) ============ */
.app-sidebar {
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex; flex-direction: column;
    position: sticky; top: 0;
    height: 100dvh;
    padding: 16px 12px;
    gap: 12px;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px 12px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}
.sidebar-brand-logo { color: var(--color-primary); display: flex; }
.sidebar-brand-name { font-weight: 700; font-size: 16px; }
.sidebar-nav {
    display: flex; flex-direction: column; gap: 2px;
    flex: 1;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--color-text); text-decoration: none;
    font-size: 14.5px; font-weight: 500;
    transition: background .12s ease;
}
.sidebar-link svg { color: var(--color-muted); }
.sidebar-link:hover { background: var(--color-surface-2); text-decoration: none; }
.sidebar-link:hover svg { color: var(--color-text); }
.sidebar-link.active { background: var(--color-primary); color: #fff; }
.sidebar-link.active svg { color: #fff; }

.sidebar-user {
    display: flex; gap: 10px; align-items: center;
    padding: 10px 8px;
    border-top: 1px solid var(--color-border);
    min-width: 0;
    flex-shrink: 0;
}
.sidebar-user-meta { min-width: 0; flex: 1; }
.sidebar-user-name {
    font-weight: 600; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user-role { font-size: 12px; color: var(--color-muted); text-transform: capitalize; }

/* ============ TOPBAR ============ */
.app-topbar {
    position: sticky; top: 0; z-index: 40;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 0 20px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.topbar-left {
    display: flex; align-items: center; gap: 14px;
    min-width: 0; flex: 1;
}
.topbar-brand {
    display: flex; align-items: center; gap: 8px;
    color: var(--color-text); text-decoration: none;
    font-weight: 700; font-size: 16px;
}
.topbar-brand:hover { text-decoration: none; }
.topbar-logo { color: var(--color-primary); display: flex; }
.topbar-title { display: inline; }
.topbar-page-title {
    display: none;
    margin: 0;
    font-size: 15px; font-weight: 600;
    color: var(--color-text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 6px; }

/* ============ USER MENU ============ */
.user-menu-wrap { position: relative; }
.user-trigger {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 4px;
    background: transparent; border: 1px solid transparent;
    border-radius: 999px;
    color: var(--color-text); cursor: pointer;
    font-size: 14px; font-weight: 500;
    transition: background .12s ease;
}
.user-trigger:hover { background: var(--color-surface-2); }
.user-trigger-name {
    max-width: 120px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 240px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 60;
}
.user-dropdown[hidden] { display: none; }
.user-dropdown-header { padding: 12px 14px; }
.user-dropdown-name { font-weight: 600; font-size: 14px; }
.user-dropdown-meta { font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.user-dropdown-divider { height: 1px; background: var(--color-border); }
.user-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: transparent; border: 0;
    color: var(--color-text); cursor: pointer;
    font-size: 14px; text-align: left;
    text-decoration: none;
}
.user-dropdown-item:hover { background: var(--color-surface-2); text-decoration: none; }
.user-dropdown-item svg { color: var(--color-muted); }
.user-dropdown-item.danger { color: var(--color-danger); }
.user-dropdown-item.danger svg { color: var(--color-danger); }
.user-dropdown-form { margin: 0; }

/* ============ NOTIF BELL ============ */
.notif-bell-wrap { position: relative; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    background: transparent; border: 0;
    border-radius: 50%;
    color: var(--color-text); cursor: pointer;
    position: relative;
    transition: background .12s ease;
    text-decoration: none;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--color-surface-2); text-decoration: none; }
.notif-badge {
    position: absolute; top: 4px; right: 4px;
    background: var(--color-danger); color: #fff;
    font-size: 10px; font-weight: 700;
    border-radius: 10px;
    padding: 1px 5px;
    min-width: 16px; line-height: 14px; text-align: center;
}
.notif-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 340px; max-width: calc(100vw - 32px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column;
    max-height: 480px;
    z-index: 60;
    overflow: hidden;
}
.notif-dropdown[hidden] { display: none; }
.notif-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
    font-size: 14px;
}
.notif-list {
    list-style: none; margin: 0; padding: 0;
    overflow-y: auto;
    flex: 1; min-height: 60px;
}
.notif-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    font-size: 13.5px;
    display: flex; gap: 10px;
    align-items: flex-start;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-surface-2); }
.notif-item.unread { background: rgba(37,99,235,.06); }
.notif-item-icon {
    flex-shrink: 0;
    color: var(--color-muted);
    margin-top: 2px;
}
.notif-item.unread .notif-item-icon { color: var(--color-primary); }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item .ntitle { font-weight: 500; }
.notif-item.unread .ntitle { font-weight: 600; }
.notif-item .nbody { color: var(--color-muted); font-size: 12.5px; margin-top: 2px; }
.notif-item .ntime { color: var(--color-muted); font-size: 11px; margin-top: 4px; }
.notif-empty {
    padding: 32px 16px; text-align: center;
    color: var(--color-muted); font-size: 13px;
}
.notif-empty-icon { display: inline-block; margin-bottom: 8px; opacity: .5; }
.notif-empty p { margin: 0; }

/* ============ BOTTOM NAV (selalu fixed, semua viewport) ============ */
.app-bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--bottom-nav-h);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    z-index: 50;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    display: flex;
    align-items: stretch;
    overflow: hidden;
    /* smooth transition */
    transition: background .2s ease, border-color .2s ease;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

.bn-group {
    display: flex;
    align-items: stretch;
    width: 100%;
    position: absolute;
    inset: 0;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    transition: opacity .22s ease, transform .22s ease;
    will-change: opacity, transform;
}
.bn-group-app   { opacity: 1; transform: translateX(0); }
.bn-group-admin { opacity: 0; transform: translateX(8px); pointer-events: none; }

html[data-area="admin"] .bn-group-app   { opacity: 0; transform: translateX(-8px); pointer-events: none; }
html[data-area="admin"] .bn-group-admin { opacity: 1; transform: translateX(0); pointer-events: auto; }

.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    flex: 1 1 0;
    min-width: 0;
    color: var(--color-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    padding: 6px 2px;
    border-radius: 8px;
    transition: color .12s ease, background .12s ease;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.1;
}
.bottom-nav-item:hover { text-decoration: none; }
.bottom-nav-item.active { color: var(--color-primary); }

/* ============ AUTH SHELL ============ */
.auth-body { min-height: 100dvh; background: var(--color-bg); }
.auth-shell {
    display: flex; align-items: center; justify-content: center;
    min-height: 100dvh; padding: 24px 16px;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-md);
}
.auth-brand-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }
.auth-brand-logo { color: var(--color-primary); display: flex; }
.auth-brand { font-size: 20px; margin: 0; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 14px; }

/* ============ ERROR CARD ============ */
.error-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100dvh; padding: 24px;
    text-align: center;
}
.error-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}
.error-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px;
    background: var(--color-surface-2);
    border-radius: 50%;
    color: var(--color-muted);
    margin-bottom: 12px;
}
.error-card h1 { font-size: 32px; margin-bottom: 6px; }
.error-card p { margin-bottom: 16px; color: var(--color-muted); }

/* ============ RESPONSIVE ============ */
/* Desktop ≥ 861px: sidebar kiri + bottom-nav tetap ada (compact) */
@media (min-width: 861px) {
    .app-main {
        padding: 24px 32px calc(var(--bottom-nav-h) + 24px);
    }
    .app-bottom-nav {
        /* Desktop juga tampil, sama seperti mobile */
        box-shadow: 0 -4px 12px rgba(0,0,0,.04);
    }
    .bottom-nav-item {
        max-width: 110px;
        margin: 0 auto;
        flex: 0 1 auto;
        min-width: 76px;
    }
    .bn-group {
        justify-content: center;
        gap: 4px;
    }
}

/* Mobile ≤ 860px: sidebar diganti bottom-nav */
@media (max-width: 860px) {
    .app-layout { grid-template-columns: 1fr; }
    .app-sidebar { display: none; }
    .app-main {
        padding: 16px 14px calc(var(--bottom-nav-h) + 20px);
    }
    .topbar-brand .topbar-title { display: none; }
    .topbar-page-title { display: block; }
    .user-trigger-name { display: none; }
    .user-trigger { padding: 4px; }
}

@media (max-width: 430px) {
    .app-main { padding: 12px 12px calc(var(--bottom-nav-h) + 18px); }
    .auth-card { padding: 22px 18px; }
    .notif-dropdown {
        position: fixed;
        left: 12px; right: 12px;
        top: calc(var(--topbar-h) + 6px);
        width: auto; max-width: none;
    }
}