/* =====================================================
   OKAFLIX — shared.css
   All shared styles used across every page
   ===================================================== */

/* --- CORE --- */
:root {
    --primary: #e50914;
    --dark: #141414;
    --light: #fff;
    --nav-height: 68px;
}
* {
    box-sizing: border-box;
}
body {
    font-family: "Poppins", sans-serif;
    background-color: var(--dark);
    color: var(--light);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .handle {
        display: none !important;
    }
    .slider {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }
}

/* --- NAVBAR --- */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--nav-height);
    padding: 0 4%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
    transition: background 0.3s;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.7) 10%,
        rgba(0, 0, 0, 0) 100%
    );
}
.navbar.black {
    background-color: #141414;
}
.nav-left {
    display: flex;
    align-items: center;
    gap: 30px;
}
.nav-logo {
    cursor: pointer;
    display: flex;
    align-items: center;
}
.nav-logo img {
    height: 35px;
    width: auto;
    object-fit: contain;
    transition: transform 0.2s;
}
.nav-logo img:hover {
    transform: scale(1.05);
}
.nav-links {
    display: flex;
    list-style: none;
    gap: 20px;
    font-size: 14px;
    margin: 0;
    padding: 0;
    align-items: center;
}
.nav-links li {
    cursor: pointer;
    color: #e5e5e5;
    transition: color 0.3s;
}
.nav-links li:hover {
    color: #b3b3b3;
}
.nav-links li.active {
    color: #fff;
    font-weight: bold;
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* TOGGLE */
.mode-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.4);
    user-select: none;
}
.mode-label {
    font-size: 13px;
    font-weight: bold;
    color: #777;
    transition: color 0.3s;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.mode-label.active-mode {
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
    margin: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}
.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: 0.4s;
    border-radius: 22px;
    border: 1px solid #555;
}
.switch-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
input:checked + .switch-slider {
    background-color: #e50914;
    border-color: #e50914;
}
input:checked + .switch-slider:before {
    transform: translateX(20px);
}

.my-list-link {
    border: 1px solid white;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: #e5e5e5;
    transition: color 0.3s;
    white-space: nowrap;
}
.my-list-link:hover {
    color: #fff;
}

/* --- SEARCH WRAPPER (expandable, Netflix-style) --- */
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 260px; /* Locked open by default */
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    height: 36px;
    transition: border-color 0.2s ease;
}
.search-wrapper:focus-within {
    border-color: #e50914; /* Highlight red when user types */
}
.search-trigger-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Purely icon status now, no toggle needed */
}
.search-trigger-btn svg {
    width: 18px;
    height: 18px;
    fill: rgba(255, 255, 255, 0.6);
}
.search-input-field {
    font-family: "Poppins", sans-serif;
    background: transparent;
    border: none;
    color: white;
    outline: none;
    width: 100%;
    padding: 6px 10px 6px 0;
    font-size: 14px;
    opacity: 1;
    pointer-events: auto;
}
.search-input-field::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Responsive tweak to prevent layout overflow on mobile viewport screens */
@media (max-width: 850px) {
    .search-wrapper {
        width: 160px; /* Scales down fluidly on small viewports */
    }
}

.auth-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-family: "Poppins", sans-serif;
    font-size: 14px;
}
.auth-btn:hover {
    background-color: #f40612;
}

.user-menu {
    display: none;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative;
    height: 100%;
    padding: 10px 0;
}
.nav-avatar {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    transition: transform 0.2s;
}
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: #000;
    border: 1px solid #333;
    width: 150px;
    display: none;
    flex-direction: column;
    z-index: 2000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    margin-top: -5px;
    border-radius: 6px;
    overflow: hidden;
}
.user-dropdown::before {
    content: "";
    position: absolute;
    top: -30px;
    left: 0;
    width: 100%;
    height: 30px;
    background: transparent;
}
.user-menu.active .user-dropdown {
    display: flex;
}
.user-dropdown div {
    padding: 12px;
    font-size: 13px;
    color: #ccc;
    transition: 0.2s;
    border-bottom: 1px solid #222;
    cursor: pointer;
}
.user-dropdown div:last-child {
    border-bottom: none;
}
.user-dropdown div:hover {
    background: #333;
    color: #fff;
}

/* SEARCH DROPDOWN */
.search-dropdown {
    position: absolute;
    top: 45px;
    right: 0;
    width: 300px;
    background: #181818;
    border: 1px solid #333;
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 2000;
    display: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.search-dropdown.active {
    display: block;
}
.search-item {
    display: flex;
    gap: 10px;
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #222;
    transition: background 0.2s;
}
.search-item:hover {
    background: #2a2a2a;
}
.search-item img {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}
.search-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* MOBILE MENU */
.hamburger {
    display: none;
    font-size: 28px;
    cursor: pointer;
    color: white;
    margin-right: 20px;
}
.mobile-menu-dropdown {
    display: none;
    position: fixed;
    top: 68px;
    left: 0;
    width: 100%;
    background: #141414;
    border-top: 1px solid #333;
    flex-direction: column;
    z-index: 1900;
}
.mobile-menu-dropdown div {
    padding: 15px 20px;
    color: #e5e5e5;
    border-bottom: 1px solid #222;
    font-size: 16px;
    cursor: pointer;
}
.mobile-menu-dropdown div:hover {
    background: #222;
    color: white;
}

/* POSTERS */
.poster {
    flex: 0 0 auto;
    width: 200px;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s;
}
.poster:hover {
    transform: scale(1.08);
    z-index: 30;
}
.poster img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    background: #222;
}
.poster-title {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 40px 8px 15px;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.95) 0%,
        rgba(0, 0, 0, 0.6) 40%,
        transparent 100%
    );
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    z-index: 25;
    pointer-events: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    line-height: 1.2;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}
.ep-tag {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.75);
    padding: 4px 8px;
    font-size: 13px;
    border-radius: 4px;
    color: #fff;
    font-weight: bold;
}
.heart-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    opacity: 0;
    transition: 0.2s;
    z-index: 60;
}
.heart-btn svg {
    width: 20px;
    height: 20px;
    fill: transparent;
    stroke: #fff;
    stroke-width: 2px;
}
.poster:hover .heart-btn,
.heart-btn.active {
    opacity: 1;
}
.heart-btn.active svg {
    fill: #e50914;
    stroke: #e50914;
}
.heart-btn:hover svg {
    stroke: #e50914;
}
.info-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    font-family: serif;
    font-weight: bold;
    z-index: 60;
    transition: 0.2s;
    cursor: pointer;
}
.poster:hover .info-btn {
    opacity: 1;
}
.info-btn:hover {
    background: #fff;
    color: #000;
    transform: scale(1.1);
}
.remove-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
    z-index: 60;
    cursor: pointer;
}
.remove-btn:hover {
    background: #e50914;
    border-color: #e50914;
}
.poster:hover .remove-btn {
    opacity: 1;
}
.poster-progress-bg {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
    z-index: 50;
}
.poster-progress-fill {
    height: 100%;
    background: #e50914;
    width: 0%;
    transition: width 0.3s ease;
}
.poster-finish-btn {
    position: absolute;
    bottom: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s;
    z-index: 60;
    cursor: pointer;
    font-weight: bold;
}
.poster-finish-btn:hover {
    background: #00e676;
    border-color: #00e676;
    transform: scale(1.1);
}
.poster:hover .poster-finish-btn {
    opacity: 1;
}

/* SLIDERS */
.category-row {
    margin: 0 0 30px 0;
    padding-left: 4%;
    position: relative;
    z-index: 20;
}
.category-title {
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 10px;
    color: #e5e5e5;
}
.row-container {
    position: relative;
}
.slider {
    display: flex;
    overflow-x: auto;
    gap: 10px;
    padding: 10px 0;
    scroll-behavior: smooth;
    scrollbar-width: none;
}
.slider::-webkit-scrollbar {
    display: none;
}
.handle {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 60px;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 30px;
    cursor: pointer;
    z-index: 40;
    opacity: 0;
    transition: 0.2s;
    user-select: none;
    border-radius: 4px;
}
.row-container:hover .handle {
    opacity: 1;
}
.handle:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}
.handle.left {
    left: 0;
}
.handle.right {
    right: 0;
}

/* BROWSE GRID */
.browse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    width: 100%;
}
.browse-grid .poster,
.rec-grid .poster {
    width: 100%;
    aspect-ratio: 2 / 3;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    background-color: #222;
}
.browse-grid .poster img,
.rec-grid .poster img {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    object-fit: cover;
}
/* BROWSE FILTER BAR */
.browse-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    width: 100%;
}
.genre-tag {
    background-color: rgba(255, 255, 255, 0.05);
    color: #e5e5e5;
    padding: 8px 18px;
    border-radius: 30px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
    font-weight: 500;
}
.genre-tag:hover,
.genre-tag.active {
    background-color: #fff;
    color: #000;
    border-color: #fff;
}

/* FILTER DROPDOWNS */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 30px;
    width: 100%;
    align-items: center;
}
.filter-select {
    background: rgba(30, 30, 30, 0.85);
    color: #e5e5e5;
    padding: 9px 36px 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.2s;
    font-weight: 500;
    font-family: "Poppins", sans-serif;
    outline: none;
    min-width: 150px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23e5e5e5' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    backdrop-filter: blur(4px);
}
.filter-select:hover {
    border-color: rgba(229, 9, 20, 0.6);
    background: rgba(40, 40, 40, 0.9);
}
.filter-select:focus {
    border-color: #e50914;
    background: rgba(40, 40, 40, 0.95);
    box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.2);
}
.filter-select option {
    background: #1a1a1a;
    color: #e5e5e5;
    padding: 8px;
}

@media (max-width: 600px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-select {
        width: 100%;
        min-width: unset;
    }
}

/* SMALL AUTH/CONFIRM MODALS */
#auth-modal,
#avatar-modal,
#confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 4000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}
.auth-content {
    background: #111;
    padding: 40px;
    border-radius: 12px;
    width: 350px;
    position: relative;
    border: 1px solid #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}
.auth-close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    cursor: pointer;
    font-size: 28px;
    z-index: 100;
    transition: color 0.2s;
    line-height: 1;
}
.auth-close:hover {
    color: #e50914;
}
.auth-title {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 20px;
}
.auth-input {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    background: #222;
    border: 1px solid #333;
    border-radius: 6px;
    color: white;
    outline: none;
    font-family: "Poppins", sans-serif;
    transition: border-color 0.2s;
}
.auth-input:focus {
    border-color: #e50914;
}
.auth-submit {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    border: none;
    color: white;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-family: "Poppins", sans-serif;
    transition: background 0.2s;
}
.auth-submit:hover {
    background: #bd060e;
}
.auth-switch {
    margin-top: 15px;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    text-align: center;
}
.auth-switch:hover {
    text-decoration: underline;
    color: #fff;
}
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 20px;
}
.avatar-opt {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid transparent;
}
.avatar-opt:hover {
    transform: scale(1.1);
    border-color: #fff;
}

/* PAGE WRAPPER */
.page-wrapper {
    padding: 100px 4% 40px;
    min-height: 100vh;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 20px;
    width: 100%;
}
.page-title {
    font-size: 24px;
    font-weight: bold;
    text-transform: capitalize;
}
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s;
    text-decoration: none;
    border: 1px solid #444;
    padding: 7px 14px;
    border-radius: 8px;
}
.back-btn:hover {
    color: #fff;
    border-color: #fff;
}

/* MOBILE */
@media (max-width: 850px) {
    :root {
        --nav-height: 60px;
    }
    .navbar {
        padding: 0 15px;
        background: rgba(20, 20, 20, 0.95);
        backdrop-filter: blur(10px);
    }
    .nav-left {
        gap: 15px;
    }
    .nav-logo img {
        width: 85px !important;
    }
    .hamburger {
        display: block;
        font-size: 24px;
        margin-right: 0;
    }
    .search-wrapper {
        height: 32px;
    }
    .search-trigger-btn {
        width: 32px;
        height: 32px;
    }
    .search-trigger-btn svg {
        width: 18px;
        height: 18px;
    }
    .search-input-field {
        font-size: 13px;
    }
    .search-dropdown {
        width: 100vw;
        position: fixed;
        top: 60px;
        right: 0;
        border-radius: 0;
        max-height: calc(100vh - 60px);
    }
    .nav-links,
    .my-list-link,
    .desktop-toggle {
        display: none !important;
    }
    .auth-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    .mobile-menu-dropdown {
        position: fixed;
        top: 0;
        left: -260px;
        width: 260px;
        height: 100vh;
        background: #141414;
        z-index: 2000;
        display: flex !important;
        transition: transform 0.3s ease-in-out;
        border-top: none;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.8);
    }
    .mobile-menu-dropdown.active {
        transform: translateX(260px);
    }
    .poster {
        width: 130px;
    }
    .browse-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }
}

.ep-progress-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 10;
}
.ep-progress-fill {
    height: 100%;
    background: #e50914;
    transition: width 0.3s ease;
}
.ep-watched-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}
.ep-watched-overlay::after {
    content: "✓";
    font-size: 24px;
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Skeleton Loading Animations ── */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}
.skeleton {
    background: linear-gradient(90deg, #222 25%, #333 50%, #222 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}
.skeleton-poster {
    composes: skeleton;
    width: 100%;
    aspect-ratio: 2 / 3;
}
