/* =========================
   DESIGN TOKENS
========================= */

:root {
    /* Brand palette — matches auth layout */
    --color-navy-dark:    #0f2942;
    --color-navy-mid:     #1a4a7a;
    --color-blue:         #1a6ac8;
    --color-blue-dark:    #1a5fb4;

    /* Text */
    --color-text-primary:   #0f172a;
    --color-text-secondary: #374151;
    --color-text-muted:     #64748b;
    --color-text-placeholder: #94a3b8;

    /* Surfaces */
    --color-bg:       #f1f5f9;
    --color-surface:  #ffffff;
    --color-border:   #e2e8f0;

    /* Bootstrap overrides */
    --bs-font-sans-serif: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --bs-body-font-family: var(--bs-font-sans-serif);
    --bs-body-bg: var(--color-bg);
    --bs-body-color: var(--color-text-primary);
    --bs-border-color: var(--color-border);
    --bs-primary: var(--color-blue);
    --bs-primary-rgb: 26, 106, 200;
    --bs-link-color: var(--color-blue);
    --bs-link-hover-color: var(--color-blue-dark);
    --bs-btn-focus-shadow-rgb: 26, 106, 200;
}

/* =========================
   BASE
========================= */

html {
    position: relative;
    min-height: 100%;
    font-size: 14px;
}

@media (min-width: 768px) {
    html { font-size: 16px; }
}

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    color: var(--color-text-primary);
}

/* Bootstrap primary button — use brand blue */
.btn-primary {
    --bs-btn-bg: var(--color-blue);
    --bs-btn-border-color: var(--color-blue);
    --bs-btn-hover-bg: var(--color-blue-dark);
    --bs-btn-hover-border-color: var(--color-blue-dark);
    --bs-btn-active-bg: #165099;
    --bs-btn-active-border-color: #165099;
    --bs-btn-focus-shadow-rgb: 26, 106, 200;
}

.btn-outline-primary {
    --bs-btn-color: var(--color-blue);
    --bs-btn-border-color: var(--color-blue);
    --bs-btn-hover-bg: var(--color-blue);
    --bs-btn-hover-border-color: var(--color-blue);
    --bs-btn-active-bg: var(--color-blue-dark);
    --bs-btn-active-border-color: var(--color-blue-dark);
}

/* Form controls — match auth page style */
.form-control,
.form-select {
    border-color: var(--color-border);
    background-color: #f8fafc;
    color: var(--color-text-primary);
    font-size: .92rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--color-blue);
    background-color: var(--color-surface);
    box-shadow: 0 0 0 3px rgba(26, 106, 200, .12);
}

.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    letter-spacing: .01em;
}

/* Links */
a {
    color: var(--color-blue);
}

a:hover {
    color: var(--color-blue-dark);
}

/* Cards */
.card {
    border-color: var(--color-border);
    border-radius: 10px;
}

.card-header {
    background: #f8fafc;
    border-bottom-color: var(--color-border);
}

/* Focus rings */
.btn:focus, .btn:active:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(26, 106, 200, .15);
}

/* =========================
   APP LAYOUT
========================= */

.app-shell {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* =========================
   SIDEBAR
========================= */

.sidebar {
    width: 250px;
    background: linear-gradient(180deg, var(--color-navy-dark) 0%, #112d4e 100%);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.2s ease, transform 0.2s ease;
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header {
    min-height: 60px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.3px;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
    line-height: 1.25;
    overflow: hidden;
}

/* =========================
   SIDEBAR MENU
========================= */

.sidebar-menu {
    flex: 1;
    min-height: 0;
    padding: 14px 10px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.2);
    border-radius: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.35);
}

    .sidebar-menu a {
        display: flex;
        align-items: center;
        gap: 12px;
        color: rgba(255,255,255,.72);
        text-decoration: none;
        padding: 11px 14px;
        border-radius: 8px;
        margin-bottom: 2px;
        font-size: .9rem;
        transition: background 0.15s ease, color 0.15s ease;
        white-space: nowrap;
    }

        .sidebar-menu a:hover {
            background: rgba(255,255,255,.10);
            color: #fff;
        }

        .sidebar-menu a.active {
            background: rgba(255,255,255,.15);
            color: #fff;
            font-weight: 500;
        }

    .sidebar-menu i {
        width: 20px;
        min-width: 20px;
        text-align: center;
        font-size: 17px;
        flex-shrink: 0;
        opacity: .85;
    }

    .sidebar-menu a:hover i,
    .sidebar-menu a.active i {
        opacity: 1;
    }

/* =========================
   SIDEBAR GROUPS
========================= */

.sidebar-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    color: rgba(255,255,255,.55);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .72rem;
    font-weight: 600;
    padding: 10px 14px 6px;
    cursor: pointer;
    text-align: left;
}

.sidebar-group.has-active .sidebar-group-header {
    color: rgba(255,255,255,.85);
}

.sidebar-group-chevron {
    margin-left: auto;
    font-size: .7rem;
    transition: transform .15s ease;
}

.sidebar-group.expanded .sidebar-group-chevron {
    transform: rotate(180deg);
}

.sidebar-group-items {
    display: none;
}

.sidebar-group.expanded .sidebar-group-items {
    display: block;
}

.sidebar-group-items a {
    padding-left: 30px;
}

/* =========================
   MAIN CONTENT
========================= */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* =========================
   TOP BAR
========================= */

.top-bar {
    min-height: 60px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    flex-shrink: 0;
    font-weight: 600;
    font-size: .95rem;
    color: var(--color-text-primary);
    letter-spacing: -.2px;
}

/* =========================
   TOP BAR RIGHT / USER MENU
========================= */

.top-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.top-bar-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 5px 10px 5px 6px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    color: var(--color-text-primary);
    font-family: inherit;
}

.top-bar-user-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.top-bar-user-btn::after {
    display: none;
}

.top-bar-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-navy-mid);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: .03em;
}

.top-bar-username {
    font-size: 13.5px;
    font-weight: 500;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-secondary);
}

.top-bar-chevron {
    font-size: 10px;
    color: var(--color-text-muted);
}

/* =========================
   SIDEBAR LOGOUT BUTTON
========================= */

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: none;
    border: none;
    color: rgba(255,255,255,.72);
    padding: 11px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .9rem;
    font-family: inherit;
    white-space: nowrap;
    transition: background .15s, color .15s;
    text-align: left;
}

.sidebar-logout-btn:hover {
    background: rgba(239,68,68,.18);
    color: #fca5a5;
}

.sidebar-logout-btn i {
    width: 20px;
    min-width: 20px;
    text-align: center;
    font-size: 17px;
    flex-shrink: 0;
    opacity: .85;
}

.sidebar-logout-btn:hover i {
    opacity: 1;
}

body.sidebar-collapsed .sidebar-logout-btn {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

body.sidebar-collapsed .sidebar-logout-btn span {
    display: none;
}

/* =========================
   CONTENT AREA
========================= */

.content-area {
    flex: 1;
    overflow: auto;
    padding: 24px;
}

/* =========================
   SIDEBAR TOGGLE BUTTONS
========================= */

.sidebar-toggle,
.mobile-sidebar-toggle {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 22px;
    padding: 0;
    line-height: 1;
}

.mobile-sidebar-toggle {
    display: none;
    color: var(--color-text-primary);
}

/* =========================
   COLLAPSED SIDEBAR
========================= */

body.sidebar-collapsed .sidebar {
    width: 72px;
}

body.sidebar-collapsed .sidebar-title {
    display: none;
}

body.sidebar-collapsed .sidebar-menu a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

    body.sidebar-collapsed .sidebar-menu a span {
        display: none;
    }

body.sidebar-collapsed .sidebar-group-header span,
body.sidebar-collapsed .sidebar-group-chevron {
    display: none;
}

body.sidebar-collapsed .sidebar-group-items {
    display: block;
}

body.sidebar-collapsed .sidebar-group-items a {
    padding-left: 0;
}

/* =========================
   MOBILE
========================= */

@media (max-width: 768px) {

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 1050;
        transform: translateX(-100%);
        box-shadow: 0 0 24px rgba(0,0,0,0.3);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .mobile-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .content-area {
        padding: 18px;
    }

    body.sidebar-collapsed .sidebar {
        width: 250px;
    }

    body.sidebar-collapsed .sidebar-title {
        display: block;
    }

    body.sidebar-collapsed .sidebar-menu a {
        justify-content: flex-start;
        padding-left: 14px;
        padding-right: 14px;
    }

        body.sidebar-collapsed .sidebar-menu a span {
            display: inline;
        }
}
