/**
 * Mobile Toolbar - Minimal header for mobile devices
 * Pattern: Logo (left) | Context (center) | Hamburger (right)
 *
 * This component is hidden on desktop (769px+) and shown on mobile (768px-)
 */

/* ==================== MOBILE TOOLBAR (hidden on desktop) ==================== */
.mobile-toolbar {
    display: none; /* Hidden by default, shown via media query */
}

/* Hidden token counter for JS compatibility */
.mobile-hidden-token-counter {
    display: none !important;
    visibility: hidden !important;
    position: absolute !important;
    left: -9999px !important;
}

@media (max-width: 768px) {
    .mobile-toolbar {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: var(--hh-color-base-white, #ffffff);
        border-bottom: 1px solid var(--hh-color-borders-subtle, #e5e7eb);
        box-shadow: var(--hh-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.06));
    }

    .mobile-toolbar-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 16px;
        min-height: 52px;
    }

    /* ==================== LEFT: LOGO ==================== */
    .mobile-toolbar-left {
        flex-shrink: 0;
    }

    .mobile-toolbar-brand {
        display: flex;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        min-width: 44px;
        min-height: 44px;
        padding: 6px;
        border-radius: 8px;
        transition: background-color 0.2s ease;
    }

    .mobile-toolbar-brand:hover,
    .mobile-toolbar-brand:active {
        background-color: var(--hh-color-base-cloud, #f5f5f5);
    }

    .mobile-toolbar-logo {
        height: 32px;
        width: 32px;
        object-fit: contain;
    }

    /* ==================== CENTER: CONTEXT ==================== */
    .mobile-toolbar-center {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0 8px;
        overflow: hidden;
    }

    .mobile-toolbar-center:empty {
        display: none;
    }

    /* ==================== RIGHT: HAMBURGER ==================== */
    .mobile-toolbar-right {
        flex-shrink: 0;
    }

    .mobile-hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: background-color 0.2s ease;
        color: var(--hh-color-text-primary, #1a1a1a);
    }

    .mobile-hamburger-btn:hover,
    .mobile-hamburger-btn:active {
        background-color: var(--hh-color-base-cloud, #f5f5f5);
    }

    .mobile-hamburger-icon,
    .mobile-close-icon {
        width: 24px;
        height: 24px;
    }

    /* ==================== MENU OVERLAY ==================== */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1001;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* ==================== MENU PANEL ==================== */
    .mobile-menu {
        position: absolute;
        top: 0;
        right: 0;
        width: 280px;
        max-width: 85vw;
        height: 100%;
        background: var(--hh-color-base-white, #ffffff);
        transform: translateX(100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    }

    .mobile-menu-overlay.active .mobile-menu {
        transform: translateX(0);
    }

    .mobile-menu-items {
        padding: 68px 0 20px 0; /* Top padding accounts for toolbar height (52px) + margin */
    }

    /* ==================== MENU ITEMS ==================== */
    .mobile-menu-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 20px;
        color: var(--hh-color-text-primary, #1a1a1a);
        text-decoration: none;
        font-size: 15px;
        font-weight: 500;
        background: transparent;
        border: none;
        width: 100%;
        text-align: left;
        cursor: pointer;
        transition: background-color 0.2s ease;
    }

    .mobile-menu-item:hover,
    .mobile-menu-item:active {
        background-color: var(--hh-color-base-cloud, #f5f5f5);
    }

    .mobile-menu-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        flex-shrink: 0;
        color: var(--hh-color-text-secondary, #6b7280);
    }

    .mobile-menu-icon img {
        width: 20px;
        height: 20px;
        object-fit: contain;
    }

    .mobile-menu-icon svg {
        width: 20px;
        height: 20px;
    }

    .mobile-menu-text {
        flex: 1;
    }

    .mobile-menu-divider {
        height: 1px;
        background: var(--hh-color-borders-subtle, #e5e7eb);
        margin: 8px 20px;
    }

    /* Logout button styling */
    .mobile-menu-logout-btn {
        color: var(--hh-color-status-error, #dc3545);
    }

    /* Hidden state for auth-dependent menu items - must override !important rules */
    .mobile-menu-item.auth-hidden {
        display: none !important;
    }

    .mobile-menu-logout-btn .mobile-menu-icon {
        color: var(--hh-color-status-error, #dc3545);
    }

    /* ==================== BODY OFFSET FOR FIXED TOOLBAR ==================== */
    body.has-mobile-toolbar {
        padding-top: 52px;
    }
}

/* ==================== ULTRA-SMALL SCREENS ==================== */
@media (max-width: 380px) {
    .mobile-toolbar-container {
        padding: 6px 12px;
        min-height: 48px;
    }

    .mobile-toolbar-logo {
        height: 28px;
        width: 28px;
    }

    .mobile-hamburger-btn {
        width: 40px;
        height: 40px;
    }

    .mobile-menu {
        width: 260px;
    }

    .mobile-menu-item {
        padding: 12px 16px;
        font-size: 14px;
    }

    body.has-mobile-toolbar {
        padding-top: 48px;
    }
}
