/* ===== Mobile App Download Banner ===== */

/*
 * Sticky banner prompting users to download the mobile app
 * Only visible on small/medium screens (mobile/tablet)
 * Auto-detects iOS vs Android for appropriate store link
 */

/* Hidden by default (desktop) */
.app-download-banner {
    display: none;
}

/* Mobile-only display */
@media (max-width: 991.18px) {
    .app-download-banner {
        display: flex;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 10px 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        z-index: var(--z-fixed, 1030);
        gap: 10px;
        transform: translateY(0);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);

        /* iOS safe area support */
        padding-top: calc(10px + env(safe-area-inset-top, 0));
    }

    /* Hidden state - no transition initially to prevent flash */
    .app-download-banner.hidden {
        transform: translateY(-100%);
        pointer-events: none;
        transition: none;
    }

    /* Enable transition only after JS initialization */
    .app-download-banner.initialized {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .app-download-banner.initialized.hidden {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Close button */
    .app-banner-close {
        flex-shrink: 0;
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--gray-500, #6b7280);
        cursor: pointer;
        padding: 0;
        border-radius: 50%;
        transition: background-color 0.2s ease, color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .app-banner-close:hover,
    .app-banner-close:active {
        background-color: var(--gray-100, #f5f5f4);
        color: var(--gray-700, #44403c);
    }

    .app-banner-close i {
        font-size: 14px;
    }

    /* App icon */
    .app-banner-icon {
        flex-shrink: 0;
        width: 44px;
        height: 44px;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    .app-banner-icon img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Text content */
    .app-banner-content {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .app-banner-title {
        font-size: 0.9375rem;
        font-weight: 600;
        color: var(--gray-900, #1c1917);
        margin: 0;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .app-banner-subtitle {
        font-size: 0.8125rem;
        color: var(--gray-600, #57534e);
        margin: 0;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Download button */
    .app-banner-btn {
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 8px 16px;
        background: var(--primary-blue, #0966ff);
        color: white;
        font-size: 0.875rem;
        font-weight: 600;
        border: none;
        border-radius: 6px;
        text-decoration: none;
        cursor: pointer;
        transition: background-color 0.2s ease, transform 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        white-space: nowrap;
    }

    .app-banner-btn:hover {
        background: var(--primary-blue-dark, #1d4ed8);
        color: white;
        text-decoration: none;
    }

    .app-banner-btn:active {
        transform: scale(0.98);
    }

    /* Adjust main content when banner is visible */
    body.app-banner-visible main {
        padding-top: calc(64px + env(safe-area-inset-top, 0));
    }

    body.app-banner-visible .navbar-new {
        top: calc(64px + env(safe-area-inset-top, 0));
    }
}

/* Smaller screens - more compact layout */
@media (max-width: 374px) {
    .app-download-banner {
        padding: 8px 10px;
        gap: 8px;
    }

    .app-banner-icon {
        width: 38px;
        height: 38px;
    }

    .app-banner-title {
        font-size: 0.875rem;
    }

    .app-banner-subtitle {
        font-size: 0.75rem;
    }

    .app-banner-btn {
        padding: 6px 12px;
        font-size: 0.8125rem;
    }

    body.app-banner-visible main {
        padding-top: calc(56px + env(safe-area-inset-top, 0));
    }

    body.app-banner-visible .navbar-new {
        top: calc(54px + env(safe-area-inset-top, 0)); /* 56px - 1px overlap to eliminate sub-pixel gap */
    }
}

/* Landscape mobile adjustments */
@media (max-width: 767px) and (orientation: landscape) {
    .app-download-banner {
        padding: 6px 10px;
    }

    .app-banner-icon {
        width: 36px;
        height: 36px;
    }

    .app-banner-title {
        font-size: 0.8125rem;
    }

    .app-banner-subtitle {
        font-size: 0.75rem;
    }

    body.app-banner-visible main {
        padding-top: calc(48px + env(safe-area-inset-top, 0));
    }

    body.app-banner-visible .navbar-new {
        top: calc(48px + env(safe-area-inset-top, 0));
    }
}

/* Accessibility - reduced motion */
@media (prefers-reduced-motion: reduce) {
    .app-download-banner {
        transition: none;
    }

    .app-banner-btn {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .app-download-banner {
        border-bottom: 2px solid var(--gray-300);
    }

    .app-banner-btn {
        border: 2px solid var(--primary-blue-dark);
    }
}
