/* Host element - make topbar a block element */
:host {
    display: block;
    /* Reserve space for the fixed topbar */
}

/* Ensure body doesn't have horizontal overflow from fixed topbar */
:host-context(body) {
    overflow-x: hidden;
}

#topbar {
    background: #333;
    color: #fff;
    padding: 0.5em 1em;
    text-align: right;
    box-sizing: border-box;
    height: 56px;
    min-height: 0;
    margin: 0;
    display: flex;
    align-items: center;
    width: 100%;

    /* Fixed positioning to stay at top when scrolling */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;

    /* Ensure full width coverage, especially on iOS Safari */
    min-width: 100vw;
    max-width: 100vw;

    /* Prevent iOS Safari from shrinking topbar during rotation */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* iOS Safari fixes for viewport width during rotation */
@supports (-webkit-touch-callout: none) {
    #topbar {
        width: 100vw;
        left: 0;
        right: 0;
    }
}

/* Additional fix for orientation changes */
@media (orientation: landscape) {
    #topbar {
        width: 100vw;
    }
}

@media (orientation: portrait) {
    #topbar {
        width: 100vw;
    }
}



#topbar #dashboardBtn {
    background: #4a90e2;
    color: #fff;
}

#topbar button {
    background: #fff;
    color: #333;
    border: none;
    padding: 0.5em 1em;
    border-radius: 4px;
    cursor: pointer;
}

#topbar a {
    color: #fff;
    background-color: rgb(155, 146, 130);
    text-decoration: underline;
    font-size: smaller;
    margin-right: .2em;
}

#toast-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 0;
    position: relative;
    height: 2.5em;
}

.toast-notification {
    position: relative;
    background: #fffbe6;
    color: #222;
    padding: 0.35em 1em;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    font-size: 1em;
    transition: opacity 0.3s, top 0.3s;
    min-width: 0;
    max-width: 80vw;
    width: fit-content;
    white-space: pre-line;
    text-align: center;
    margin: 0 0.5em;
    border: 2px solid #4a90e2;
    box-shadow: 0 4px 16px rgba(74, 144, 226, 0.25), 0 2px 8px rgba(0, 0, 0, 0.10);
    display: inline-block;
}

.toast-notification+.toast-notification {
    margin-left: 0.5em;
}

.toast-notification.show {
    opacity: 1;
}

.topbar-nav {
    display: flex;
    align-items: center;
    margin-right: auto;
    gap: 0.5em;
}

.topbar-nav a {
    color: #fff;
    text-decoration: none;
    padding: 0.5em 1em;
    border-radius: 4px;
    transition: background 0.3s;
    background-color: rgb(155, 146, 130);
    display: inline-block;
    line-height: 1;
    font-size: 1em;
}

.topbar-nav a:hover {
    background: rgba(155, 146, 130, 0.8);
}

.topbar-nav button {
    background: #fff;
    color: #333;
    border: none;
    padding: 0.5em 1em;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.topbar-nav button:hover {
    background: #f0f0f0;
}

.app-icons {
    display: flex;
    gap: 0.4em;
    align-items: center;
    margin-right: 0.8em;
    padding-right: 0.8em;
}

.app-icon {
    font-size: 1.5em;
    text-decoration: none;
    padding: 0.3em 0.4em;
    border-radius: 6px;
    transition: background 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.app-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.app-icon:active {
    transform: scale(0.95);
}

.app-icon img {
    width: 24px;
    height: 24px;
    display: block;
}

/* Hamburger menu button */
.hamburger-btn {
    display: none;
    background: none !important;
    border: none !important;
    cursor: pointer;
    padding: 0.5em;
    flex-direction: column;
    gap: 4px;
    z-index: 1001;
    align-items: center;
    justify-content: center;
}

.hamburger-btn span {
    display: block;
    width: 24px;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile responsive styles */
@media (max-width: 1047px) {
    .hamburger-btn {
        display: flex;
    }

    .app-icons {
        display: none;
        position: absolute;
        top: 56px;
        right: 0;
        background: #333;
        flex-direction: column;
        padding: 1em;
        border-radius: 0 0 0 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        border: none;
        gap: 0.8em;
        z-index: 1000;
        /* Auto height - grows as tall as needed */
        max-height: none;
        overflow-y: visible;
    }

    .app-icons.show {
        display: flex;
    }

    .nav-category {
        width: 100%;
    }

    .category-btn {
        width: 100%;
        justify-content: flex-start;
        font-size: 0.9em;
    }

    .category-btn::after {
        margin-left: auto;
    }

    .category-dropdown {
        position: static;
        box-shadow: none;
        background: rgba(74, 144, 226, 0.15);
        margin-top: 0.5em;
        border-radius: 6px;
        border: 1px solid rgba(74, 144, 226, 0.3);
    }

    .category-dropdown a {
        padding: 0.6em 1em;
    }

    .app-icon {
        padding: 0.5em;
        justify-content: flex-start;
        width: 100%;
    }

    .app-icon img {
        margin-right: 0.8em;
    }

    /* Show app names on mobile */
    .app-icon::after {
        content: attr(title);
        color: #fff;
        font-size: 0.67em;
        white-space: nowrap;
    }

    .app-icon:hover {
        background: rgba(255, 255, 255, 0.2);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
        transform: none;
    }

    .app-icon:active {
        transform: none;
    }
}

/* Category navigation styles */
.nav-category {
    position: relative;
    display: inline-block;
}

.category-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff;
    padding: 0.5em 1em;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5em;
    transition: background 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.category-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.category-btn::after {
    content: '▼';
    font-size: 0.7em;
    transition: transform 0.2s;
}

.nav-category.active .category-btn::after {
    transform: rotate(180deg);
}

.category-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5em;
    background: #444;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    z-index: 1001;
    overflow: hidden;
}

.nav-category.active .category-dropdown {
    display: block;
}

.category-dropdown a {
    display: flex;
    align-items: center;
    gap: 0.8em;
    padding: 0.75em 1em;
    color: #fff;
    text-decoration: none;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.category-dropdown a:last-child {
    border-bottom: none;
}

.category-dropdown a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.category-dropdown img {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}