/* ─── App Topbar (slim, tablet-first) ─── */

.app-topbar {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
    background: #173c5e;
    box-shadow: 0 2px 8px rgba(12, 45, 74, 0.18);
}

.app-topbar-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    padding: 0 0.9rem;
    min-height: 56px;
}

/* Back button */
.app-topbar-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #cbd8e8;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    min-height: 44px;
    transition: background .15s;
}

.app-topbar-back:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
}

.app-topbar-divider {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,.2);
    flex-shrink: 0;
}

/* Brand / title area */
.app-topbar-brand {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
    min-width: 0;
}

.app-topbar-brand-name {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: .01em;
}

.app-topbar-brand-sub {
    color: #8ab4d4;
    font-size: 0.73rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

/* Event chip */
.app-topbar-event {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
    color: #d6e8f7;
    border: 1px solid rgba(255,255,255,.18);
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Institutional logos */
.app-topbar-logos {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.app-topbar-logo {
    max-height: 28px;
    width: auto;
    object-fit: contain;
    opacity: .92;
    display: block;
}

/* Spacer */
.app-topbar-spacer {
    flex: 1;
    min-width: 0;
}

/* Page actions slot */
.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap;
    justify-content: flex-end;
    min-width: 0;
}

.app-topbar-actions:empty {
    display: none;
}

/* Shared topbar button style (matches patient-btn) */
.app-topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,.3);
    background: transparent;
    color: #e0edf8;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 600;
    padding: 0.45rem 0.75rem;
    min-height: 44px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}

.app-topbar-btn:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
}

.app-topbar-btn--primary {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

.app-topbar-btn--primary:hover {
    background: #0b5ed7;
    border-color: #0b5ed7;
    color: #fff;
}

.app-topbar-btn--active {
    background: rgba(16, 185, 129, 0.18);
    border-color: #10b981;
    color: #d1fae5;
}

.app-topbar-btn--active:hover {
    background: rgba(16, 185, 129, 0.32);
    color: #fff;
}

.app-topbar-btn--closed {
    background: rgba(239, 68, 68, 0.18);
    border-color: #ef4444;
    color: #fecaca;
}

.app-topbar-btn--closed:hover {
    background: rgba(239, 68, 68, 0.32);
    color: #fff;
}

.app-topbar-btn--patients {
    background: rgba(59, 130, 246, 0.18);
    border-color: #3b82f6;
    color: #bfdbfe;
}

.app-topbar-btn--patients:hover {
    background: rgba(59, 130, 246, 0.32);
    color: #fff;
}

.app-topbar-btn--dashboard {
    background: rgba(139, 92, 246, 0.18);
    border-color: #8b5cf6;
    color: #ddd6fe;
}

.app-topbar-btn--dashboard:hover {
    background: rgba(139, 92, 246, 0.32);
    color: #fff;
}

.app-topbar-overflow {
    position: relative;
    display: none;
    flex-shrink: 0;
}

.app-topbar-overflow[open] .app-topbar-overflow-summary {
    background: rgba(255,255,255,.18);
}

.app-topbar-overflow-summary {
    list-style: none;
}

.app-topbar-overflow-summary::-webkit-details-marker {
    display: none;
}

.app-topbar-overflow-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.45rem);
    min-width: 230px;
    display: grid;
    gap: 0.35rem;
    padding: 0.55rem;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #d7e2ee;
    box-shadow: 0 14px 30px rgba(12, 45, 74, 0.18);
    z-index: 1100;
}

.app-topbar-overflow-menu .app-topbar-btn,
.app-topbar-overflow-menu form,
.app-topbar-overflow-menu button,
.app-topbar-overflow-menu a {
    width: 100%;
}

.app-topbar-overflow-menu .app-topbar-btn,
.app-topbar-overflow-menu a.app-topbar-btn,
.app-topbar-overflow-menu button.app-topbar-btn {
    justify-content: flex-start;
    color: #173c5e;
    border-color: #d7e2ee;
    background: #f8fbff;
}

.app-topbar-overflow-menu .app-topbar-btn--primary {
    color: #fff;
    border-color: #0d6efd;
    background: #0d6efd;
}

.app-topbar-overflow-menu .app-topbar-btn--active {
    color: #065f46;
    border-color: #10b981;
    background: #d1fae5;
}

.app-topbar-overflow-menu .app-topbar-btn--closed {
    color: #7f1d1d;
    border-color: #ef4444;
    background: #fee2e2;
}

.app-topbar-overflow-menu .app-topbar-btn--patients {
    color: #1e40af;
    border-color: #3b82f6;
    background: #dbeafe;
}

@media (max-width: 1180px) {
    .app-topbar-bar {
        gap: 0.4rem;
        padding: 0.35rem 0.65rem;
    }

    .app-topbar-actions {
        min-width: 0;
    }
}

@media (max-width: 1200px) {
    .app-topbar-btn {
        padding: 0.35rem 0.55rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 1000px) {
    .app-topbar-back {
        padding-inline: 0.45rem;
    }

    .app-topbar-brand-sub {
        max-width: 170px;
    }

    .app-topbar-hub,
    .app-topbar-btn--patients,
    .app-topbar-btn--dashboard,
    .app-topbar-logos {
        display: none;
    }

    .app-header-user-name {
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ─── User menu (details/summary) ─── */

.app-header-user-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.app-header-user-menu[open] .app-header-user-button {
    background: rgba(255,255,255,.22);
}

.app-header-user-button {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.25);
    background: rgba(255,255,255,.1);
    color: #e8f1fa;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.4rem 0.7rem;
    min-height: 44px;
    cursor: pointer;
    white-space: nowrap;
}

.app-header-user-button::-webkit-details-marker {
    display: none;
}

.app-header-user-name {
    display: inline-flex;
    align-items: center;
}

.app-header-user-caret {
    font-size: 0.7rem;
    opacity: .7;
}

.app-header-user-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    min-width: 240px;
    background: #ffffff;
    border: 1px solid #d7e2ee;
    border-radius: 10px;
    box-shadow: 0 14px 30px rgba(12, 45, 74, 0.18);
    padding: 0.6rem 0.7rem;
    z-index: 1100;
}

.app-header-user-row {
    color: #1f2d3a;
    font-size: 0.84rem;
    padding: 0.2rem 0;
}

.app-header-user-type {
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.2rem 0.55rem;
    margin: 0.15rem 0 0.35rem;
    border: 1px solid transparent;
    font-weight: 700;
}

.app-header-user-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

.app-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid #0d6efd;
    background: #0d6efd;
    color: #fff;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.35rem 0.65rem;
    min-height: 40px;
    cursor: pointer;
}

.app-header-btn:hover {
    color: #fff;
    background: #0b5ed7;
}

/* ─── Role colour chips ─── */

.app-chip-user-type { font-weight: 700; }

.app-chip-user-type-doctor    { background: #e6f4ff; color: #0a4a7a; border-color: #b7daf5; }
.app-chip-user-type-nurse     { background: #e9f9ef; color: #145e33; border-color: #bde8cb; }
.app-chip-user-type-psychologist { background: #fff4dd; color: #7a4f08; border-color: #f4ddb0; }
.app-chip-user-type-support   { background: #f1edf9; color: #503b86; border-color: #d8cff1; }
.app-chip-user-type-admin     { background: #fde7ea; color: #842029; border-color: #f5b7c0; }

.app-header-user-type.app-chip-user-type-admin,
.app-header-user-type.app-chip-user-type-doctor,
.app-header-user-type.app-chip-user-type-nurse,
.app-header-user-type.app-chip-user-type-psychologist,
.app-header-user-type.app-chip-user-type-support {
    border-color: inherit;
}

/* ─── Warning banners ─── */

.app-header-warning {
    padding: 0.3rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
}

.app-header-warning-critical {
    background: #f8d7da;
    color: #7b1020;
    border-top: 2px solid #dc3545;
}

.app-header-warning-muted {
    background: #fff4d6;
    color: #8a6d1f;
    border-top: 1px solid #ffe6a8;
}

.app-header-warning-info {
    background: #e6f6ea;
    color: #17613a;
    border-top: 1px solid #98d8aa;
}

.app-header-warning-info:hover {
    background: #d8f0df;
    color: #0f4c2b;
}

/* ─── Responsive ─── */

@media (max-width: 800px) {
    .app-topbar-event {
        display: none;
    }

    .app-topbar-brand-sub {
        display: none;
    }

    .app-topbar-actions {
        display: none;
    }

    .app-topbar-btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.8rem;
    }
}
