/*
 * Rivrun Bottom Menu - Frontend Styles
 */

/* Container */
.rivrun-bottom-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px; /* Adjust height as needed */
    
    /* MODIFIED: Glass Effect */
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 99998;
    
    /* NEW: Required for animations */
    /* position: relative; -- THIS WAS THE BUG, IT'S REMOVED. position: fixed; is correct. */
    overflow: hidden; 
}

/* FIX: This class now *only* applies the desktop-hide rule */
@media (min-width: 769px) {
    .rivrun-mobile-only {
        display: none;
    }
}

.rivrun-menu-inner {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    height: 100%;
    max-width: 500px; /* Max width for mobile view */
    margin: 0 auto;
    
    /* NEW: Ensure icons/text appear above animations */
    position: relative;
    z-index: 2;
}

/* Menu Button */
.rivrun-menu-button {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    flex-basis: 0;
    padding: 4px 8px;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    color: var(--rivrun-text-color);
    font-size: 10px; /* Base font size, label will override */
    text-align: center;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
}

/* Icon (Container) */
.rivrun-menu-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 28px;
    height: 28px;
    margin-bottom: 2px;
}
/* Icon (Inline SVG) */
.rivrun-menu-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--rivrun-icon-color);
    fill: none; /* Ensure icons are outlines */
}
/* Icon (Image URL) */
.rivrun-menu-icon .rivrun-menu-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Label */
.rivrun-menu-label {
    display: block;
    line-height: 1.2;
    /* font-size: 12px; -- REMOVED, now set from admin */
}

/* --- Top Search Form --- */
.rivrun-top-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--rivrun-bg-color);
    z-index: 100000;
    padding: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);

    /* Hidden by default, slides down */
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}
.rivrun-top-search-overlay.is-visible {
    transform: translateY(0);
}
.rivrun-top-search-container {
    max-width: 600px;
    margin: 0 auto;
}
.rivrun-top-search-overlay .rivrun-search-form {
    display: flex;
    align-items: center;
    position: relative;
}
.rivrun-top-search-overlay input[type="search"] {
    flex-grow: 1;
    padding: 12px 50px 12px 20px; /* Right padding for close button */
    border: 1px solid #ccc;
    border-radius: 25px; /* Rounded */
    font-size: 16px;
    width: 100%;
    -webkit-appearance: none; /* Fix iOS styling */
}
.rivrun-top-search-close {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: #eee;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Dark mode for search */
@media (prefers-color-scheme: dark) {
    .rivrun-top-search-overlay {
        border-bottom: 1px solid #333;
    }
    .rivrun-top-search-overlay input[type="search"] {
        background: #333;
        border-color: #555;
        color: #fff;
    }
    .rivrun-top-search-close {
        background: #444;
        color: #eee;
    }
}


/* --- Grid Popup Styles --- */

.rivrun-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    display: flex;
    
    /* MODIFIED: Removed flex-direction */

    align-items: center;     /* Centers wrapper vertically */
    justify-content: center;   /* Centers wrapper horizontally */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    
    padding: 20px;
    box-sizing: border-box;
}

.rivrun-popup-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* NEW: Wrapper to stack popup and button */
.rivrun-popup-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
}

.rivrun-popup-container {
    /* background-color: var(--rivrun-bg-color); -- REPLACED for glass effect */
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    padding: 20px;
    transform: scale(0.9);
    transition: transform 0.3s ease;

    /* NEW: Glass Effect */
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.rivrun-popup-overlay.is-visible .rivrun-popup-container {
    transform: scale(1);
}

/* NEW: Style for the *outer* close button, positioned BELOW the container */
.rivrun-overlay-close {
    margin-top: 15px; /* Space below the popup container */
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    color: #ffffff;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    opacity: 0.8;
    transition: opacity 0.2s ease, background 0.2s ease;
    padding: 8px 16px;
    flex-shrink: 0; /* Prevent button from shrinking */
}
.rivrun-overlay-close:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}


.rivrun-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    border-radius: 50%;
    font-weight: bold;
    line-height: 1; /* Keep 1 for flex centering */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;

    /* STYLES REMOVED - now set from admin */
}

/* Style close for dark mode */
@media (prefers-color-scheme: dark) {
    /* Dark Glass for Bottom Menu */
    .rivrun-bottom-menu {
        background-color: rgba(30, 30, 30, 0.2);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .rivrun-popup-container {
        /* Dark Glass Effect */
        background-color: rgba(30, 30, 30, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* .rivrun-popup-close is handled by admin settings */
}

.rivrun-popup-content {
    margin-top: 20px;
}

/* Loading Spinner */
.rivrun-popup-content.is-loading {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rivrun-popup-content.is-loading::after {
    content: '';
    display: block;
    width: 30px;
    height: 30px;
    border: 3px solid var(--rivrun-icon-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: rivrun-spin 1s linear infinite;
}
@keyframes rivrun-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Custom Preloader Style */
.rivrun-popup-content .rivrun-custom-preloader {
    display: block;
    margin: 20px auto;
    width: 90px; /* UPDATED default size */
    height: 90px; /* UPDATED default size */
    object-fit: contain;
}

/* --- Popup: Grid (Updated) --- */
.rivrun-popup-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-height: 60vh;
    overflow-y: auto;
}
.rivrun-popup-grid-item {
    text-decoration: none;
    color: var(--rivrun-text-color);
    text-align: center;
    aspect-ratio: 4 / 5;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 6px;
    border-radius: 8px;

    /* background: #f8f8f8; -- REMOVED, now set from admin */
}
.rivrun-popup-grid-item img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 5px;
    background-color: #f0f0f0;
}
.rivrun-popup-grid-item-label {
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;

    /* font-size: 16px; -- REMOVED, now set from admin */
}

/* Dark mode for grid item is handled by admin settings */


/* --- NEW: Infinity Border & 2s Simple Glow --- */

/* 1. The permanent infinity BORDER (thin line) */
.rivrun-bottom-menu::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px; /* Thickness of the animated border */
    z-index: 1; /* Above the background, below the content */
    
    background: linear-gradient(
        90deg, 
        #00FFFF, /* Cyan */
        #FF00FF, /* Magenta */
        #FFFF00, /* Yellow */
        #00FFFF  /* Cyan again to loop seamlessly */
    );
    background-size: 200% auto;
    animation: rivrun-infinity-border 2.5s linear infinite;
}

/* 2. The 2-second simple GLOW (behind the glass) */
.rivrun-bottom-menu::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: 0; /* Behind everything */
    
    /* Simple white radial glow */
    background: radial-gradient(
        circle, 
        rgba(255, 255, 255, 0.4) 0%, 
        rgba(255, 255, 255, 0) 60%
    );
    
    /* This class is added by JS */
    opacity: 0;
    transform: scale(0.5);
    animation: none;
}

.rivrun-bottom-menu.show-glow::after {
    animation: rivrun-glow 2s ease-out;
}

/* 3. The Keyframes */

@keyframes rivrun-infinity-border {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: 0% 0;
    }
}

@keyframes rivrun-glow {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.2);
    }
}