/* AgroGM topbar — light + dark */
#page-topbar {
    --ag-top-teal: #0ab39c;
    --ag-top-teal-dark: #088f7d;
    --ag-top-text: #17332e;
    --ag-top-muted: #5d6f6b;
    --ag-top-border: rgba(15, 40, 36, 0.08);
    --ag-top-chip: #ffffff;
    --ag-top-action: rgba(15, 40, 36, 0.06);
    --ag-top-action-hover: rgba(10, 179, 156, 0.12);
    --ag-top-icon: #3d524e;
    border: 0;
    border-bottom: 1px solid var(--ag-top-border);
    box-shadow: 0 8px 24px rgba(16, 38, 34, 0.05);
    backdrop-filter: blur(12px);
}

#page-topbar .navbar-header {
    gap: 0.5rem;
    min-width: 0;
}

.ag-topbar-left {
    min-width: 0;
    flex: 1 1 auto;
}

.ag-topbar-hamburger {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0 !important;
    border-radius: 12px !important;
    color: var(--ag-top-icon);
}

.ag-topbar-hamburger:hover,
.ag-topbar-hamburger:focus {
    background: var(--ag-top-action-hover) !important;
}

.ag-topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
    text-decoration: none;
}

.ag-topbar-brand:hover,
.ag-topbar-brand:focus {
    text-decoration: none;
}

.ag-topbar-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    height: 48px;
    padding: 0.3rem 0.7rem;
    background: var(--ag-top-chip);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 20px rgba(11, 61, 54, 0.08);
}

.ag-topbar-logo img {
    display: block;
    height: 38px;
    width: auto;
    max-width: 168px;
    object-fit: contain;
}

.ag-topbar-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
}

.ag-topbar-kicker {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ag-top-muted);
}

.ag-topbar-company {
    display: block;
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--ag-top-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(42vw, 420px);
}

.ag-topbar-actions {
    flex-shrink: 0;
}

.ag-topbar-actions .btn-topbar {
    width: 40px;
    height: 40px;
    border-radius: 12px !important;
    color: var(--ag-top-icon) !important;
}

.ag-topbar-actions .btn-topbar:hover,
.ag-topbar-actions .btn-topbar:focus {
    background: var(--ag-top-action-hover) !important;
    color: var(--ag-top-teal-dark) !important;
}

.ag-topbar-user {
    display: flex !important;
    align-items: center;
    gap: 0.65rem;
    height: auto !important;
    padding: 0.28rem 0.55rem 0.28rem 0.28rem !important;
    margin: 0 0.35rem 0 0.15rem;
    border-radius: 999px !important;
    border: 1px solid var(--ag-top-border) !important;
    background: var(--ag-top-action) !important;
    box-shadow: none !important;
}

.ag-topbar-user:hover,
.ag-topbar-user:focus,
.ag-topbar-user[aria-expanded="true"] {
    background: var(--ag-top-action-hover) !important;
}

.ag-topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--ag-top-teal) 0%, var(--ag-top-teal-dark) 100%);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.ag-topbar-user-meta {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    line-height: 1.15;
    text-align: left;
}

.ag-topbar-user-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--ag-top-text);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ag-topbar-user-role {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--ag-top-muted);
}

.ag-topbar-user-caret {
    font-size: 1rem;
    color: var(--ag-top-muted);
}

#page-topbar .topbar-user {
    background: transparent !important;
}

@media (min-width: 992px) {
    .ag-topbar-user-meta {
        display: flex;
    }
}

@media (max-width: 767.98px) {
    .ag-topbar-logo {
        height: 42px;
        padding: 0.22rem 0.5rem;
    }

    .ag-topbar-logo img {
        height: 32px;
        max-width: 118px;
    }

    .ag-topbar-company {
        font-size: 0.86rem;
        max-width: 34vw;
    }

    .ag-topbar-kicker {
        font-size: 0.6rem;
    }

    .ag-topbar-user-caret {
        display: none;
    }
}

@media (max-width: 420px) {
    .ag-topbar-kicker {
        display: none;
    }

    .ag-topbar-copy {
        display: none;
    }
}

/* Dark layout or dark topbar */
html[data-layout-mode="dark"] #page-topbar,
html[data-topbar="dark"] #page-topbar {
    --ag-top-text: #f4f7f6;
    --ag-top-muted: rgba(255, 255, 255, 0.62);
    --ag-top-border: rgba(255, 255, 255, 0.08);
    --ag-top-chip: #ffffff;
    --ag-top-action: rgba(255, 255, 255, 0.06);
    --ag-top-action-hover: rgba(10, 179, 156, 0.22);
    --ag-top-icon: rgba(255, 255, 255, 0.82);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

html[data-layout-mode="dark"] #page-topbar .hamburger-icon span,
html[data-topbar="dark"] #page-topbar .hamburger-icon span {
    background-color: rgba(255, 255, 255, 0.82);
}

html[data-layout-mode="light"][data-topbar="light"] #page-topbar .hamburger-icon span {
    background-color: #4b5c58;
}
