/**
 * Betformatics Mobile Navigation Styles
 * Context-aware bottom bar with direct links
 *
 * Dependencies: betformatics-variables (loaded via PHP)
 *
 * @package Betformatics
 * @subpackage Assets/CSS
 */

/* ========================================================================
   CSS CUSTOM PROPERTIES - Mobile-specific overrides
   ======================================================================== */
:root {
    /* Bottom bar height */
    --bf-mobile-bar-height: 64px;

    /* Z-index (high to stay above cookie buttons) */
    --bf-mobile-z-bar: 2147483640;
    --bf-desktop-menu-z: 2147483645;
    --bf-desktop-overlay-z: 2147483644;
}

/* ========================================================================
   HIDE ON DESKTOP
   ======================================================================== */
.bf-mobile-bar,
.bf-mobile-overlay {
    display: none;
}

@media screen and (max-width: 1024px) {
    .bf-mobile-bar {
        display: flex;
    }
}

/* ========================================================================
   BOTTOM NAVIGATION BAR
   ======================================================================== */
.bf-mobile-bar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: var(--bf-mobile-bar-height, 64px);
    min-height: var(--bf-mobile-bar-height, 64px);
    background: var(--bf-white, #ffffff);
    border-top: 1px solid var(--bf-border, #e5e7eb);
    display: flex !important;
    align-items: center;
    justify-content: space-around;
    z-index: var(--bf-mobile-z-bar, 2147483640);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    transform: translateZ(0); /* Force GPU layer for better positioning */
    -webkit-transform: translateZ(0);
}

/* Navigation Button */
.bf-mobile-bar__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    height: 100%;
    padding: 8px 4px;
    background: none;
    border: none;
    color: var(--bf-text-muted, #6b7280);
    text-decoration: none;
    cursor: pointer;
    position: relative;
    min-width: 44px;
    min-height: 44px;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.bf-mobile-bar__btn:hover,
.bf-mobile-bar__btn:focus {
    color: var(--bf-primary, #1848A0);
    outline: none;
}

.bf-mobile-bar__btn:focus-visible {
    outline: 2px solid var(--bf-primary, #1848A0);
    outline-offset: -2px;
    border-radius: 8px;
}

.bf-mobile-bar__btn.is-active {
    color: var(--bf-primary, #1848A0);
}

.bf-mobile-bar__btn svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* Button Label */
.bf-mobile-bar__label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}

/* Badge for count indicators */
.bf-mobile-bar__badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(calc(50% + 12px));
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--bf-error, #ef4444);
    color: var(--bf-white, #ffffff);
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    box-sizing: border-box;
}

/* ========================================================================
   ACCESSIBILITY
   ======================================================================== */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

@media (prefers-reduced-motion: reduce) {
    .bf-mobile-bar__btn {
        transition: none;
    }
}

/* ========================================================================
   IUBENDA ADJUSTMENTS
   ======================================================================== */
@media screen and (max-width: 1024px) {
    /* Move Iubenda cookie button above mobile nav bar */
    .iubenda-tp-btn[data-tp-float="bottom-right"],
    .iubenda-tp-btn[data-tp-float="bottom-left"] {
        bottom: calc(var(--bf-mobile-bar-height, 64px) + 16px + env(safe-area-inset-bottom, 0)) !important;
    }
}

/* ========================================================================
   BODY PADDING FOR BOTTOM BAR
   ======================================================================== */
@media screen and (max-width: 1024px) {
    body {
        padding-bottom: calc(var(--bf-mobile-bar-height, 64px) + env(safe-area-inset-bottom, 0));
    }
}

/* ========================================================================
   DESKTOP SLIDE-IN MENU PANEL (#menu hash trigger)
   ======================================================================== */

/* Desktop Menu Overlay */
.bf-desktop-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--bf-desktop-overlay-z);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.bf-desktop-menu-overlay.is-visible {
    display: block;
}

.bf-desktop-menu-overlay.is-active {
    opacity: 1;
}

/* Desktop Slide-in Panel */
.bf-desktop-menu-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bf-white, #ffffff);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: var(--bf-desktop-menu-z, 2147483645);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bf-desktop-menu-panel.is-open {
    transform: translateX(0);
}

/* Prevent body scroll when menu is open */
body.bf-menu-open {
    overflow: hidden;
}

/* Panel Header - Hidden on desktop, visible on mobile for close button */
.bf-desktop-menu-header {
    display: none; /* Hidden on desktop */
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--bf-border, #e5e7eb);
    flex-shrink: 0;
}

.bf-desktop-menu-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--bf-gray-800, #1f2937);
}

/* Show header on mobile/tablet for close button */
@media (max-width: 1024px) {
    .bf-desktop-menu-header {
        display: flex;
    }
}

.bf-desktop-menu-close,
.bf-desktop-menu-panel .bf-desktop-menu-close,
.bf-desktop-menu-panel button.bf-desktop-menu-close {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    background: var(--bf-bg-light, #f8fafc) !important;
    border: none !important;
    border-radius: 10px !important;
    color: var(--bf-primary, #1848A0) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    text-decoration: none !important;
}

.bf-desktop-menu-close:hover,
.bf-desktop-menu-panel .bf-desktop-menu-close:hover,
.bf-desktop-menu-panel button.bf-desktop-menu-close:hover {
    background: var(--bf-primary, #1848A0) !important;
    color: var(--bf-white, #ffffff) !important;
}

.bf-desktop-menu-close:focus,
.bf-desktop-menu-panel .bf-desktop-menu-close:focus,
.bf-desktop-menu-panel button.bf-desktop-menu-close:focus {
    outline: none !important;
    box-shadow: 0 0 0 2px var(--bf-primary, #1848A0) !important;
}

.bf-desktop-menu-close:active,
.bf-desktop-menu-panel .bf-desktop-menu-close:active {
    background: var(--bf-primary-hover, #133a80) !important;
    color: var(--bf-white, #ffffff) !important;
}

.bf-desktop-menu-close svg,
.bf-desktop-menu-panel .bf-desktop-menu-close svg {
    width: 20px !important;
    height: 20px !important;
    color: currentColor !important;
    stroke: currentColor !important;
    fill: none !important;
}

/* Navigation Container */
.bf-desktop-menu-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

/* Desktop close button - hidden on mobile, shown on desktop */
.bf-desktop-menu-close-desktop {
    display: none; /* Hidden by default (mobile has header with close button) */
}

/* Desktop: Close button positioned top-right inside panel */
@media (min-width: 1025px) {
    .bf-desktop-menu-panel {
        padding-top: 16px;
    }

    /* Show close button at top-right on desktop */
    .bf-desktop-menu-close-desktop {
        position: absolute;
        top: 16px;
        right: 16px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: var(--bf-bg-light, #f8fafc);
        border: none;
        border-radius: 10px;
        color: var(--bf-primary, #1848A0);
        cursor: pointer;
        transition: all 0.2s ease;
        z-index: 10;
    }

    .bf-desktop-menu-close-desktop:hover {
        background: var(--bf-primary, #1848A0);
        color: var(--bf-white, #ffffff);
    }

    .bf-desktop-menu-close-desktop svg {
        width: 20px;
        height: 20px;
    }
}

/* Section Title */
.bf-desktop-menu-section {
    padding: 8px 24px 4px;
}

.bf-desktop-menu-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bf-gray-400, #9ca3af);
}

/* Menu List */
.bf-desktop-menu-list {
    list-style: none;
    margin: 0;
    padding: 0 12px 16px;
    border-bottom: 1px solid var(--bf-border, #e5e7eb);
    margin-bottom: 8px;
}

.bf-desktop-menu-list:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.bf-desktop-menu-list li {
    margin: 0;
}

/* Socials section - horizontal square icons (desktop) */
.bf-desktop-menu-list--socials {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 12px 16px;
    justify-content: flex-start;
}

.bf-desktop-menu-list--socials li {
    flex: 0 0 auto;
}

.bf-desktop-menu-link--social {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    background: var(--bf-bg-light, #f8fafc);
    border-radius: 10px;
    gap: 0;
}

.bf-desktop-menu-link--social:hover {
    background: var(--bf-primary, #1848A0);
}

.bf-desktop-menu-link--social:hover svg {
    color: var(--bf-white, #ffffff);
}

.bf-desktop-menu-link--social svg {
    width: 24px;
    height: 24px;
    color: var(--bf-primary, #1848A0);
}

/* Hide text labels for social links */
.bf-desktop-menu-link--social span {
    display: none;
}

/* Menu Link */
.bf-desktop-menu-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 12px;
    color: var(--bf-gray-700, #374151);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s ease;
    position: relative;
}

.bf-desktop-menu-link:hover {
    background: var(--bf-gray-100, #f3f4f6);
    color: var(--bf-primary, #1848A0);
}

.bf-desktop-menu-link:focus {
    outline: none;
    background: var(--bf-gray-100, #f3f4f6);
}

.bf-desktop-menu-link svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    color: var(--bf-text-muted, #6b7280);
    transition: color 0.2s ease;
}

.bf-desktop-menu-link:hover svg {
    color: var(--bf-primary, #1848A0);
}

.bf-desktop-menu-link span:not(.bf-desktop-menu-badge) {
    font-size: 15px;
    font-weight: 500;
    flex: 1;
}

/* Badge */
.bf-desktop-menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    background: var(--bf-error, #ef4444);
    color: var(--bf-white, #ffffff);
    font-size: 11px;
    font-weight: 700;
    border-radius: 11px;
    margin-left: auto;
}

/* =============================================================================
   MOBILE COMPACT VIEW - Reduce spacing to fit without scrolling
   ============================================================================= */
@media (max-width: 768px) {
    /* Panel width on mobile - use min-width to ensure usable size */
    .bf-desktop-menu-panel {
        width: 85vw !important;
        max-width: 320px !important;
        min-width: 280px !important; /* Ensure minimum usable width */
    }

    /* Socials section - horizontal square icons */
    .bf-desktop-menu-list--socials {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 8px 12px 12px !important;
        justify-content: flex-start !important;
    }

    .bf-desktop-menu-list--socials li {
        flex: 0 0 auto !important;
    }

    .bf-desktop-menu-link--social {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 44px !important;
        height: 44px !important;
        padding: 0 !important;
        background: var(--bf-bg-light, #f8fafc) !important;
        border-radius: 10px !important;
        gap: 0 !important;
    }

    .bf-desktop-menu-link--social:hover {
        background: var(--bf-primary, #1848A0) !important;
    }

    .bf-desktop-menu-link--social:hover svg {
        color: var(--bf-white, #ffffff) !important;
    }

    .bf-desktop-menu-link--social svg {
        width: 22px !important;
        height: 22px !important;
        color: var(--bf-primary, #1848A0) !important;
    }

    /* Hide text labels for social links on mobile */
    .bf-desktop-menu-link--social span {
        display: none !important;
    }

    /* Smaller header */
    .bf-desktop-menu-header {
        padding: 12px 16px;
    }

    .bf-desktop-menu-title {
        font-size: 16px;
    }

    .bf-desktop-menu-close,
    .bf-desktop-menu-panel .bf-desktop-menu-close,
    .bf-desktop-menu-panel button.bf-desktop-menu-close {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
    }

    .bf-desktop-menu-close svg,
    .bf-desktop-menu-panel .bf-desktop-menu-close svg {
        width: 18px !important;
        height: 18px !important;
    }

    /* Tighter navigation container */
    .bf-desktop-menu-nav {
        padding: 8px 0;
    }

    /* Smaller section titles */
    .bf-desktop-menu-section {
        padding: 4px 16px 2px;
    }

    .bf-desktop-menu-section-title {
        font-size: 10px;
    }

    /* Compact menu list */
    .bf-desktop-menu-list {
        padding: 0 8px 8px;
        margin-bottom: 4px;
    }

    /* Compact menu links */
    .bf-desktop-menu-link {
        gap: 10px;
        padding: 8px 10px;
        border-radius: 8px;
    }

    .bf-desktop-menu-link svg {
        width: 18px;
        height: 18px;
    }

    .bf-desktop-menu-link span:not(.bf-desktop-menu-badge) {
        font-size: 13px;
    }

    /* Smaller badge */
    .bf-desktop-menu-badge {
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        font-size: 10px;
        border-radius: 9px;
    }
}

/* Extra compact for very small screens */
@media (max-width: 480px) {
    .bf-desktop-menu-header {
        padding: 10px 12px;
    }

    .bf-desktop-menu-title {
        font-size: 15px;
    }

    .bf-desktop-menu-nav {
        padding: 6px 0;
    }

    .bf-desktop-menu-section {
        padding: 3px 12px 1px;
    }

    .bf-desktop-menu-section-title {
        font-size: 9px;
    }

    .bf-desktop-menu-list {
        padding: 0 6px 6px;
        margin-bottom: 3px;
    }

    .bf-desktop-menu-link {
        gap: 8px;
        padding: 6px 8px;
        border-radius: 6px;
    }

    .bf-desktop-menu-link svg {
        width: 16px;
        height: 16px;
    }

    .bf-desktop-menu-link span:not(.bf-desktop-menu-badge) {
        font-size: 12px;
    }

    .bf-desktop-menu-badge {
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        font-size: 9px;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .bf-desktop-menu-panel,
    .bf-desktop-menu-overlay {
        transition: none;
    }
}
