/**
 * App Download Dropdown Component
 * Self-contained, portable component for app download functionality
 * Works across all pages with consistent behavior
 */

/* ==========================================================================
   Base Button Styles
   ========================================================================== */

.app-store-button,
.nav-links .app-store-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    min-width: 160px;
    height: 44px;
    background: linear-gradient(135deg, #3b82f6, #1e40af);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    letter-spacing: normal;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    border: none;
    cursor: pointer;
}

.app-store-button:hover,
.nav-links .app-store-button:hover {
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* ==========================================================================
   Dropdown Container
   ========================================================================== */

.app-download-dropdown {
    position: relative;
    display: inline-flex;
    z-index: 100;
}

.app-download-dropdown .app-store-button {
    position: relative;
}

/* ==========================================================================
   Dropdown Menu
   ========================================================================== */

.app-download-dropdown .download-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    margin-top: 0.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10001;
    padding: 0.75rem;
}

/* Desktop hover behavior */
@media (min-width: 1024px) {
    .app-download-dropdown:hover .download-dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }
}

/* Mobile/Tablet click behavior */
@media (max-width: 1023px) {
    .app-download-dropdown.active .download-dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }
}

/* ==========================================================================
   Download Options (iOS/Android Links)
   ========================================================================== */

.download-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: #1e293b;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: 0.95rem;
}

.download-option:hover {
    background: #f1f5f9;
    transform: translateX(4px);
}

.download-option i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.download-option .fa-apple {
    color: #000000;
}

.download-option .fa-google-play {
    color: #3b82f6;
}

/* ==========================================================================
   Mobile Navigation Adjustments
   ========================================================================== */

@media (max-width: 1023px) {
    /* Centered button in mobile nav */
    .nav-menu .app-download-dropdown {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: 0.5rem;
    }

    .nav-menu .app-download-dropdown .app-store-button {
        width: auto;
        min-width: 200px;
        max-width: 90%;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    /* Visual feedback when dropdown is active */
    .nav-menu .app-download-dropdown.active .app-store-button {
        background: linear-gradient(135deg, #2563eb, #1e3a8a);
    }

    /* Mobile nav menu: inline expansion instead of absolute positioning */
    .nav-menu .app-download-dropdown .download-dropdown-menu {
        position: static !important;
        transform: none !important;
        width: 100%;
        max-width: 400px;
        margin-top: 0;
        padding: 0;
        opacity: 0;
        visibility: hidden;
        max-height: 0;
        overflow: hidden;
        transition: all 0.3s ease, max-height 0.3s ease, margin-top 0.3s ease, padding 0.3s ease;
        background: transparent;
        box-shadow: none;
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .nav-menu .app-download-dropdown.active .download-dropdown-menu {
        opacity: 1 !important;
        visibility: visible !important;
        max-height: 300px !important;
        margin-top: 1rem;
        padding: 0;
    }

    /* For dropdowns outside nav-menu (hero, footer, etc) */
    .app-download-dropdown .download-dropdown-menu {
        position: absolute;
        top: 100%;
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(-10px);
        width: 90%;
        max-width: 280px;
        margin-top: 0.5rem;
        z-index: 10001;
    }

    /* Style download options inside mobile nav menu */
    .nav-menu .app-download-dropdown .download-option {
        width: 100%;
        padding: 1rem;
        border-radius: 12px;
        background: #f8fafc;
        margin-bottom: 0;
        text-align: center;
        font-size: 0.9rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
        font-weight: 600;
    }

    .nav-menu .app-download-dropdown .download-option:hover {
        background: #e2e8f0;
        transform: translateY(-2px);
    }

    .nav-menu .app-download-dropdown .download-option i {
        font-size: 1.5rem;
        margin-right: 0;
        margin-bottom: 0.25rem;
    }
}

/* ==========================================================================
   Hero Section Specific Positioning Fix
   ========================================================================== */

/* Ensure dropdown appears above phone mockup in hero section */
.app-hero .app-download-dropdown,
.hero-content .app-download-dropdown {
    z-index: 200;
}

.app-hero .app-download-dropdown .download-dropdown-menu,
.hero-content .app-download-dropdown .download-dropdown-menu {
    z-index: 10002;
}

/* Make sure hero-content is a positioning context */
.hero-content {
    position: relative;
    z-index: 10;
}

/* ==========================================================================
   Mobile Responsive Styles
   ========================================================================== */

@media (max-width: 768px) {
    .app-store-button,
    .nav-links .app-store-button {
        padding: 0.65rem 1.25rem;
        min-width: 140px;
        height: 42px;
        font-size: 0.9rem;
    }

    .download-option {
        padding: 0.75rem 0.875rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .app-store-button,
    .nav-links .app-store-button {
        padding: 0.6rem 1rem;
        min-width: 130px;
        height: 40px;
        font-size: 0.85rem;
    }

    .app-download-dropdown .download-dropdown-menu {
        width: 95%;
        max-width: 260px;
    }

    .download-option {
        padding: 0.65rem 0.75rem;
        font-size: 0.85rem;
        gap: 0.5rem;
    }

    .download-option i {
        font-size: 1.1rem;
    }
}
