/* AdSense-inspired shell: left nav + top bar
   Accents: orange (brand). Text: dark like Google (#202124). */

:root {
    --sb-width: 256px;
    --sb-bg: #ffffff;
    --sb-border: #e8eaed;
    --sb-text: #202124;
    --sb-text-sec: #5f6368;
    --sb-hover: #f1f3f4;
    --sb-active-bg: #fff7ed;
    --sb-active: #c2410c;
    --sb-active-bar: #ea580c;
    --topbar-h: 56px;
    --font-ui: "Google Sans", Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
}

body.has-sidebar {
    margin: 0;
    background: #f8f9fa !important;
    font-family: var(--font-ui) !important;
    color: var(--sb-text) !important;
    overflow-x: hidden;
}

/* Kill old top header/nav when sidebar layout is active */
body.has-sidebar > header,
body.has-sidebar > nav {
    display: none !important;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sb-width);
    min-width: var(--sb-width);
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1200;
    overflow: hidden;
}

.sb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 16px;
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0;
}
.sb-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ea580c, #c2410c);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sb-brand-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--sb-text);
    line-height: 1.2;
}
.sb-brand-sub {
    font-size: 12px;
    color: var(--sb-text-sec);
    font-weight: 400;
}

.sb-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px 16px;
}

.sb-link,
.sb-group-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    margin: 1px 0;
    border: none;
    background: transparent;
    border-radius: 0 20px 20px 0;
    margin-right: 8px;
    width: calc(100% - 8px);
    color: var(--sb-text) !important;
    font-family: var(--font-ui) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    text-align: left;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    line-height: 1.25;
}
.sb-link:hover,
.sb-group-btn:hover {
    background: var(--sb-hover) !important;
    color: var(--sb-text) !important;
    transform: none !important;
}
.sb-link.is-active {
    background: var(--sb-active-bg) !important;
    color: var(--sb-active) !important;
}
.sb-link.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--sb-active-bar);
}

.sb-ico {
    width: 20px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
    opacity: 0.9;
}
.sb-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sb-chevron {
    font-size: 10px;
    color: var(--sb-text-sec);
    transition: transform 0.15s ease;
}
.sb-group.is-open > .sb-group-btn .sb-chevron {
    transform: rotate(180deg);
}

.sb-sub {
    display: none;
    padding: 2px 0 6px 0;
}
.sb-group.is-open > .sb-sub {
    display: block;
}
.sb-sub .sb-link {
    min-height: 36px;
    padding-left: 44px;
    font-size: 13px !important;
    font-weight: 400 !important;
    color: #3c4043 !important;
}
.sb-sub .sb-link.is-active {
    color: var(--sb-active) !important;
    font-weight: 500 !important;
}
.sb-sub .sb-ico {
    display: none;
}

.sb-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ea580c;
    color: #fff !important;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sb-footer {
    border-top: 1px solid var(--sb-border);
    padding: 12px;
    flex-shrink: 0;
}
.sb-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.sb-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #c2410c;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sb-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--sb-text);
}
.sb-user-role {
    font-size: 12px;
    color: var(--sb-text-sec);
}
.sb-logout {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--sb-active) !important;
    text-decoration: none !important;
    padding: 6px 4px;
}

/* ===== MAIN + TOPBAR ===== */
.app-main {
    flex: 1;
    margin-left: var(--sb-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--sb-border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.sb-menu-btn {
    display: none;
    border: none;
    background: transparent;
    font-size: 20px;
    color: var(--sb-text);
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.sb-menu-btn:hover {
    background: var(--sb-hover);
}
.topbar-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--sb-text);
    flex: 1;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar-user {
    font-size: 13px;
    color: var(--sb-text-sec);
    font-weight: 500;
}
.topbar-logout {
    font-size: 13px;
    font-weight: 500;
    color: var(--sb-active) !important;
    text-decoration: none !important;
}

.content.container,
body.has-sidebar main.content.container,
body.has-sidebar .app-main main.container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 16px 24px 32px !important;
    flex: 1;
    box-sizing: border-box;
}

.app-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--sb-border);
    background: #fff;
    font-size: 12px;
    color: var(--sb-text-sec);
}
.app-footer p {
    margin: 0;
}

/* Typography alignment with Google-ish density */
body.has-sidebar h1,
body.has-sidebar h2 {
    color: var(--sb-text) !important;
    font-weight: 500 !important;
}
body.has-sidebar .ui-page-head h2 {
    font-size: 22px !important;
    font-weight: 400 !important;
    letter-spacing: 0;
    color: #202124 !important;
}
body.has-sidebar .ui-page-head p,
body.has-sidebar .form-help,
body.has-sidebar .text-muted {
    color: #5f6368 !important;
}
body.has-sidebar,
body.has-sidebar p,
body.has-sidebar td,
body.has-sidebar label,
body.has-sidebar span,
body.has-sidebar li {
    color: #3c4043;
}
body.has-sidebar strong,
body.has-sidebar b {
    color: #202124;
}

/* Backdrop for mobile */
.sb-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(32, 33, 36, 0.4);
    z-index: 1100;
}

/* Mobile */
@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: 0 8px 28px rgba(0,0,0,0.15);
    }
    body.sb-open .sidebar {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
    }
    .sb-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .content.container,
    body.has-sidebar main.content.container {
        padding: 12px 14px 24px !important;
    }
}

/* Login page keeps simple centered layout */
body.is-login {
    background: #f8f9fa !important;
}
body.is-login .login-main {
    max-width: 480px !important;
    margin: 48px auto !important;
    padding: 24px !important;
}
