/* ==========================================================================
   Brego Business Desk - Unified Layout & Shell Architecture
   Design System: Cairo Typography + Navy / Gold / Brand Blue Palette
   ========================================================================== */

:root {
    --brego-navy: #123b78;
    --brego-navy-dark: #0d2852;
    --brego-blue: #1689d8;
    --brego-gold: #bd984e;
    --brego-gold-hover: #a9823c;
    --brego-bg: #f5f7fa;
    --brego-sidebar: #f7f9fc;
    --brego-border: #e6ebf2;
    --brego-text: #2c3e50;
    --brego-muted: #8491a3;
    --brego-card-shadow: 0 4px 18px rgba(18, 59, 120, .04);
}

html, body {
    min-height: 100%;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--brego-bg);
    color: var(--brego-text);
    padding-top: 72px;
    margin: 0;
}

body.sidebar-is-open {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Top Navigation Header
   -------------------------------------------------------------------------- */
.top-header.app-header {
    position: fixed;
    inset: 0 0 auto 0;
    height: 72px;
    min-height: 72px;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: #ffffff;
    border-bottom: 1px solid var(--brego-border);
    box-shadow: 0 2px 14px rgba(18, 59, 120, .035);
}

.header-start,
.header-end {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    text-decoration: none;
}

.app-brand-logo {
    display: block;
    width: 165px;
    max-height: 44px;
    object-fit: contain;
}

.brand-subtitle {
    color: var(--brego-blue);
    font-size: 8.5px;
    font-weight: 900;
    letter-spacing: .12em;
    align-self: flex-end;
    margin: 0 0 4px;
}

.today {
    color: var(--brego-muted);
    font-size: 11.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.today i {
    color: var(--brego-gold);
}

.header-settings-btn {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #f1f4f8;
    color: var(--brego-navy);
    text-decoration: none;
    font-size: 15px;
    transition: all .2s ease;
    border: 1px solid #e1e7f0;
}

.header-settings-btn:hover,
.header-settings-btn.active {
    background: #ffffff;
    color: var(--brego-gold);
    border-color: var(--brego-gold);
    box-shadow: 0 3px 10px rgba(189, 152, 78, .18);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #f4ebd9;
    color: #8b682c;
    font-weight: 900;
    font-size: 14px;
    border: 1.5px solid #ebd8b6;
}

.mobile-menu {
    display: none;
    border: 0;
    background: #f1f4f8;
    color: var(--brego-navy);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 17px;
    cursor: pointer;
    transition: background .2s ease;
}

.mobile-menu:hover {
    background: #e5ebf3;
}

/* --------------------------------------------------------------------------
   App Shell & Desktop Sidebar
   -------------------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: calc(100vh - 72px);
}

.app-sidebar {
    position: fixed;
    top: 72px;
    right: 0;
    bottom: 0;
    z-index: 1050;
    width: 260px;
    padding: 16px 14px 0;
    display: flex;
    flex-direction: column;
    background: var(--brego-sidebar);
    border-left: 1px solid var(--brego-border);
    box-shadow: -4px 0 20px rgba(18, 59, 120, .02);
}

.sidebar-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 2px 28px;
    scrollbar-width: thin;
    scrollbar-color: #dbe2eb transparent;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 5px;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
    background: #dbe2eb;
    border-radius: 4px;
}

.sidebar-intro {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px 16px;
    margin: 0 2px 10px;
    border-bottom: 1px solid #e4eaf2;
}

.sidebar-intro-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    color: var(--brego-blue);
    background: #eaf3fb;
    border-radius: 10px;
    font-size: 15px;
}

.sidebar-intro strong,
.sidebar-intro small,
.sidebar-footer strong,
.sidebar-footer small {
    display: block;
}

.sidebar-intro strong {
    color: #1e3555;
    font-size: 13px;
    font-weight: 900;
}

.sidebar-intro small {
    color: var(--brego-muted);
    font-size: 10px;
    margin-top: 1px;
}

.side-caption {
    padding: 14px 12px 6px;
    color: #929eae;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.app-sidebar .side-link {
    min-height: 43px;
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 3px 0;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #4a5d75;
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 700;
    transition: all .18s ease;
}

.app-sidebar .side-link:hover {
    color: var(--brego-navy);
    background: #ffffff;
    border-color: #e4eaf2;
    transform: translateX(-2px);
}

.app-sidebar .side-link.active {
    color: var(--brego-navy);
    background: #ffffff;
    border-color: #dce4ee;
    box-shadow: 0 3px 12px rgba(18, 59, 120, .05);
}

.nav-icon {
    width: 22px;
    flex: 0 0 22px;
    text-align: center;
    color: var(--brego-gold);
    font-size: 14px;
}

.side-link.active .nav-icon {
    color: var(--brego-blue);
}

.nav-label {
    flex: 1;
}

.nav-chevron {
    color: #bcc6d3;
    font-size: 10px;
    transition: transform .2s ease;
}

.side-link:hover .nav-chevron {
    transform: translateX(-2px);
}

.side-link-sub {
    margin-right: 12px !important;
    width: calc(100% - 12px);
    font-size: 12px;
}

.side-link-sub .nav-icon {
    color: #a4b1c2;
    font-size: 12px;
}

.sidebar-footer {
    min-height: 62px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    border-top: 1px solid #e5eaf2;
    background: var(--brego-sidebar);
}

.sidebar-footer-mark {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: #ffffff;
    color: var(--brego-navy);
    font-weight: 900;
    font-size: 13px;
    border: 1px solid #e0e6ef;
}

.sidebar-footer strong {
    color: #243854;
    font-size: 11px;
    font-weight: 800;
}

.sidebar-footer small {
    color: #98a4b3;
    font-size: 9.5px;
}

.sidebar-version {
    margin-right: auto;
    color: #a2adb9;
    font-size: 9.5px;
    background: #e9eff6;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   Main Content Area
   -------------------------------------------------------------------------- */
.app-main {
    min-width: 0;
    margin-right: 260px;
    width: calc(100% - 260px);
    min-height: calc(100vh - 72px);
    padding: 28px 32px 30px;
}

.app-content-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 36px;
    padding: 16px 2px 6px;
    border-top: 1px solid #e5ecf3;
    color: #929fae;
    font-size: 11px;
    font-weight: 600;
}

.app-alert {
    border-radius: 12px;
    font-size: 13px;
    padding: 13px 18px;
    border: 0;
    box-shadow: 0 4px 14px rgba(18, 59, 120, .04);
}

.sidebar-backdrop {
    display: none;
}

.mobile-bottom {
    display: none;
}

/* --------------------------------------------------------------------------
   Responsive Rules (Breakpoint: 900px)
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    body {
        padding-top: 64px;
    }

    .top-header.app-header {
        height: 64px;
        min-height: 64px;
        padding: 0 16px;
    }

    .mobile-menu {
        display: grid;
        place-items: center;
    }

    .app-brand-logo {
        width: 140px;
        max-height: 38px;
    }

    .brand-subtitle,
    .header-end .today {
        display: none;
    }

    .app-shell {
        min-height: calc(100vh - 64px);
    }

    .app-sidebar {
        top: 64px;
        bottom: 68px;
        width: min(300px, 86vw);
        padding-top: 12px;
        transform: translateX(110%);
        transition: transform .24s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1300;
        box-shadow: -12px 0 36px rgba(18, 59, 120, .16);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 64px 0 68px;
        z-index: 1250;
        border: 0;
        background: rgba(18, 43, 74, .38);
        opacity: 0;
        visibility: hidden;
        transition: opacity .22s ease, visibility .22s ease;
        backdrop-filter: blur(2px);
    }

    .sidebar-backdrop.show {
        opacity: 1;
        visibility: visible;
    }

    .app-main {
        margin: 0;
        width: 100%;
        min-height: calc(100vh - 64px);
        padding: 20px 16px 95px;
    }

    .mobile-bottom {
        position: fixed;
        right: 0;
        left: 0;
        bottom: 0;
        z-index: 1200;
        min-height: 66px;
        padding: 6px 8px max(6px, env(safe-area-inset-bottom));
        display: flex;
        align-items: center;
        justify-content: space-around;
        background: #ffffff;
        border-top: 1px solid var(--brego-border);
        box-shadow: 0 -4px 22px rgba(18, 59, 120, .07);
    }

    .mobile-bottom a {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #8391a3;
        text-decoration: none;
        font-size: 10px;
        font-weight: 800;
        transition: color .18s ease;
    }

    .mobile-bottom a i {
        font-size: 17px;
    }

    .mobile-bottom a.active {
        color: var(--brego-blue);
    }

    .mobile-bottom a.add-nav {
        color: var(--brego-gold);
    }

    .mobile-bottom a.add-nav i {
        width: 38px;
        height: 38px;
        display: grid;
        place-items: center;
        margin-top: -22px;
        border: 4px solid #ffffff;
        border-radius: 50%;
        background: var(--brego-gold);
        color: #ffffff;
        box-sizing: content-box;
        box-shadow: 0 4px 14px rgba(189, 152, 78, .28);
    }
}

@media (min-width: 901px) {
    .sidebar-backdrop {
        display: none !important;
    }
}

/* --------------------------------------------------------------------------
   Print Override
   -------------------------------------------------------------------------- */
@media print {
    .top-header.app-header,
    .app-sidebar,
    .mobile-bottom,
    .sidebar-backdrop,
    .app-content-footer,
    .no-print {
        display: none !important;
    }

    .app-shell,
    .app-main {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        min-height: 0 !important;
    }
}
