/**
 * Thanos Theme - Mobile Bottom Navigation
 *
 * Premium mobile navigation with overlays
 * @package Thanos_Theme
 */

/* ==========================================================================
   Bottom Navigation Bar
   ========================================================================== */

.thanos-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--thanos-bg-card);
    border-top: 1px solid var(--thanos-border);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Only show on mobile */
    display: none;
}

@media (max-width: 768px) {
    .thanos-bottom-nav {
        display: block;
    }

    /* Add padding to body when bottom nav is present */
    body {
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }
}

.thanos-bottom-nav.hidden {
    transform: translateY(100%);
}

.bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 60px;
    max-width: 500px;
    margin: 0 auto;
}

/* ==========================================================================
   Navigation Items
   ========================================================================== */

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    padding: 8px 4px;
    color: var(--thanos-text-muted);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:hover,
.bottom-nav-item:focus {
    color: var(--thanos-text);
    outline: none;
}

.bottom-nav-item.active {
    color: var(--thanos-primary);
}

.bottom-nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    max-width: 24px;
    min-height: 24px;
    max-height: 24px;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-icon svg {
    width: 24px;
    height: 24px;
    max-width: 24px;
    max-height: 24px;
    flex-shrink: 0;
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

/* Badge */
.nav-badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(14px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--thanos-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================================
   Overlay Base Styles
   ========================================================================== */

.bottom-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;

    /* Hide completely on desktop */
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav-overlay {
        display: block;
    }
}

.bottom-nav-overlay.open {
    opacity: 1;
    visibility: visible;
}

.overlay-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    background: var(--thanos-bg-card);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bottom-nav-overlay.open .overlay-content {
    transform: translateY(0);
}

/* Drag handle indicator */
.overlay-content::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--thanos-border);
    border-radius: 2px;
}

/* ==========================================================================
   Overlay Header
   ========================================================================== */

.overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--thanos-border);
}

.overlay-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--thanos-text);
}

.overlay-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--thanos-bg-hover);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--thanos-text-muted);
    transition: background 0.2s ease, color 0.2s ease;
}

.overlay-close:hover {
    background: var(--thanos-bg-hover);
    color: var(--thanos-text);
}

.overlay-close svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Overlay Body
   ========================================================================== */

.overlay-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   Search Overlay
   ========================================================================== */

.mobile-search-form {
    margin-bottom: 24px;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--thanos-bg-hover);
    border-radius: 12px;
    overflow: hidden;
}

.search-input-wrapper .search-field {
    flex: 1;
    height: 48px;
    padding: 0 16px;
    background: none;
    border: none;
    font-size: 16px;
    color: var(--thanos-text);
}

.search-input-wrapper .search-field::placeholder {
    color: var(--thanos-text-muted);
}

.search-input-wrapper .search-field:focus {
    outline: none;
}

.search-input-wrapper .search-submit {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--thanos-primary);
    border: none;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s ease;
}

.search-input-wrapper .search-submit:hover {
    background: var(--thanos-primary-hover);
}

.search-input-wrapper .search-submit svg {
    width: 20px;
    height: 20px;
}

/* Search suggestions */
.search-suggestions,
.search-history {
    margin-bottom: 20px;
}

.search-suggestions h4,
.search-history h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--thanos-text-muted);
    margin: 0 0 12px;
}

.suggestion-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-tag {
    padding: 8px 16px;
    background: var(--thanos-bg-hover);
    border-radius: 20px;
    font-size: 14px;
    color: var(--thanos-text);
    text-decoration: none;
    transition: background 0.2s ease;
}

.suggestion-tag:hover {
    background: var(--thanos-primary);
}

/* Search history */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--thanos-bg-hover);
    border-radius: 8px;
    font-size: 14px;
    color: var(--thanos-text);
    text-decoration: none;
    transition: background 0.2s ease;
}

.history-item:hover {
    background: var(--thanos-bg-hover);
}

.history-item::before {
    content: '';
    width: 16px;
    height: 16px;
    margin-right: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cpolyline points='12 6 12 12 16 14'%3E%3C/polyline%3E%3C/svg%3E");
    background-size: contain;
}

.clear-history {
    padding: 8px 16px;
    background: none;
    border: 1px solid var(--thanos-border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--thanos-text-muted);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.clear-history:hover {
    border-color: var(--thanos-primary);
    color: var(--thanos-primary);
}

/* ==========================================================================
   Categories Overlay
   ========================================================================== */

.categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 0.5fr);
    gap: 6px;
    margin-bottom: 24px;
}

.category-item {
    display: flex;
    align-items: center;
    padding: 7px 8px;
    background: var(--thanos-bg-hover);
    border-radius: 12px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
}

.category-item:hover {
    background: var(--thanos-bg-hover);
    transform: translateY(-2px);
}

.category-icon {
    width: 24px;
    height: 24px;
    margin-right: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--thanos-primary);
    border-radius: 8px;
    color: #fff;
}

.category-icon svg {
    width: 18px;
    height: 18px;
}

.category-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: var(--thanos-text);
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-count {
    font-size: 12px;
    color: var(--thanos-text-muted);
    margin-left: 8px;
}

/* Categories section */
.categories-section {
    margin-top: 20px;
}

.categories-section h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--thanos-text-muted);
    margin: 0 0 12px;
}

/* Actors scroll */
.actors-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.actors-scroll::-webkit-scrollbar {
    display: none;
}

.actor-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.actor-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 8px;
    background: var(--thanos-bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.actor-item:hover .actor-avatar {
    border-color: var(--thanos-primary);
}

.actor-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.actor-avatar svg {
    width: 32px;
    height: 32px;
    color: var(--thanos-text-muted);
}

.actor-name {
    font-size: 12px;
    color: var(--thanos-text);
    text-align: center;
    max-width: 70px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   Menu Overlay
   ========================================================================== */

.menu-section {
    margin-bottom: 24px;
}

.menu-section:last-child {
    margin-bottom: 0;
}

.menu-section h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--thanos-text-muted);
    margin: 0 0 12px;
}

/* User section */
.user-section {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--thanos-border);
}

.user-info {
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--thanos-primary), var(--thanos-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.user-avatar svg {
    width: 24px;
    height: 24px;
    color: #fff;
}

.user-text {
    display: flex;
    flex-direction: column;
}

.user-greeting {
    font-size: 16px;
    font-weight: 600;
    color: var(--thanos-text);
}

.user-subtitle {
    font-size: 12px;
    color: var(--thanos-text-muted);
    margin-top: 2px;
}

/* Menu links */
.menu-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--thanos-bg-hover);
    border: none;
    border-radius: 12px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease;
    width: 100%;
    text-align: left;
}

.menu-link:hover {
    background: var(--thanos-bg-hover);
}

.menu-icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    color: var(--thanos-text-muted);
}

.menu-icon svg {
    width: 100%;
    height: 100%;
}

.menu-text {
    flex: 1;
    font-size: 14px;
    color: var(--thanos-text);
}

/* Toggle switch */
.menu-toggle {
    width: 44px;
    height: 24px;
    background: var(--thanos-bg-hover);
    border-radius: 12px;
    position: relative;
    transition: background 0.3s ease;
}

.menu-link.active .menu-toggle {
    background: var(--thanos-primary);
}

.toggle-switch {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.menu-link.active .toggle-switch {
    transform: translateX(20px);
}

/* Mobile menu list from wp_nav_menu */
.mobile-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-menu-list li {
    margin-bottom: 4px;
}

.mobile-menu-list li:last-child {
    margin-bottom: 0;
}

.mobile-menu-list a {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--thanos-bg-hover);
    border-radius: 12px;
    text-decoration: none;
    transition: background 0.2s ease;
}

.mobile-menu-list a:hover {
    background: var(--thanos-bg-hover);
}

.mobile-menu-list .menu-icon {
    width: 24px;
    height: 24px;
    margin-right: 12px;
    color: var(--thanos-text-muted);
}

.mobile-menu-list .menu-text {
    font-size: 14px;
    color: var(--thanos-text);
}

/* ==========================================================================
   Hide bottom nav during video fullscreen
   ========================================================================== */

.thanos-player.fullscreen ~ .thanos-bottom-nav,
body:fullscreen .thanos-bottom-nav,
body:-webkit-full-screen .thanos-bottom-nav {
    display: none !important;
}

/* Also hide when mini player is active */
.thanos-mini-player-active .thanos-bottom-nav {
    bottom: 100px;
}

/* ==========================================================================
   Theater mode adjustments
   ========================================================================== */

.thanos-theater-active .thanos-bottom-nav {
    background: rgba(0, 0, 0, 0.9);
}

/* ==========================================================================
   Safe area for notched phones (mobile only)
   ========================================================================== */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .thanos-bottom-nav {
            padding-bottom: env(safe-area-inset-bottom);
        }

        .bottom-nav-inner {
            height: 60px;
        }

        body {
            padding-bottom: calc(60px + env(safe-area-inset-bottom));
        }
    }
}

/* ==========================================================================
   Landscape mode
   ========================================================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .thanos-bottom-nav {
        display: none;
    }

    body {
        padding-bottom: 0;
    }
}

/* ==========================================================================
   Animations (mobile only)
   ========================================================================== */

@keyframes bottom-nav-slide-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .thanos-bottom-nav {
        animation: bottom-nav-slide-up 0.3s ease-out;
    }
}
