:root {
    --bg-color: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent-color: #e50914;
    /* Netflix-ish red, or maybe a nice purple/blue? Let's go with a vibrant purple/blue gradient */
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --accent-solid: #764ba2;
    --card-hover-transform: scale(1.05);
    --transition-speed: 0.3s;
    --font-family: 'Outfit', sans-serif;
    --grid-gap: 1.5rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(10px);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.05em;
}

.logo .accent {
    color: var(--accent-solid);
}

/* Search */
.search-container {
    flex: 1;
    max-width: 600px;
    /* Increased width */
    margin: 0 2rem;
}

.search-wrapper {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 50px;
    border: 1px solid #333;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
}

.search-wrapper:focus-within {
    border-color: var(--accent-solid);
    background: #222;
    box-shadow: 0 0 20px rgba(118, 75, 162, 0.3);
    /* Add glow */
    transform: scale(1.02);
    /* Slight zoom */
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    color: var(--text-secondary);
    pointer-events: none;
}

#search-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 1rem 3rem 1rem 3.5rem;
    /* Increased padding */
    font-size: 1.1rem;
    /* Larger font */
    font-family: var(--font-family);
    outline: none;
}

.search-clear {
    position: absolute;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.search-clear:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Badge */
.badge {
    background: rgba(118, 75, 162, 0.2);
    color: #b983ff;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-dot {
    width: 8px;
    height: 8px;
    background-color: #b983ff;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 10px #b983ff;
}

.hidden {
    display: none !important;
}

/* Hero Section */
.hero {
    height: 60vh;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    margin-bottom: 3rem;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: flex-end;
}

.hero-overlay {
    background: linear-gradient(to top, var(--bg-color) 0%, rgba(10, 10, 10, 0.8) 50%, rgba(10, 10, 10, 0) 100%);
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.hero-content {
    position: relative;
    z-index: 10;
    padding: 3rem;
    max-width: 800px;
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 1rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.hero-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: #ddd;
}

.hero-desc {
    font-size: 1.1rem;
    color: #ccc;
    margin-bottom: 2rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(118, 75, 162, 0.4);
}

/* Media Sections */
.media-section {
    margin-bottom: 3rem;
}

.subsection {
    margin-bottom: 2rem;
}

.subsection-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-left: 0.5rem;
    border-left: 3px solid var(--accent-solid);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.section-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.3rem;
    border-radius: 50px;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 500;
    transition: all 0.2s;
}

.tab.active {
    background: #333;
    color: white;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--grid-gap);
}

/* Cards */
.media-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-card);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    cursor: pointer;
    aspect-ratio: 2/3;
}

.media-card:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.card-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.media-card:hover .card-overlay {
    opacity: 1;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.3rem;
    line-height: 1.2;
}

.card-meta {
    font-size: 0.8rem;
    color: #ccc;
    display: flex;
    justify-content: space-between;
}

.rating {
    color: #ffd700;
}

/* Loading Skeleton */
.loading-skeleton {
    background: #1a1a1a;
    aspect-ratio: 2/3;
    border-radius: 12px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Footer */
.main-footer {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-secondary);
    border-top: 1px solid #222;
    margin-top: 3rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.card-actions {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.media-card:hover .card-actions {
    opacity: 1;
}

.btn-icon-small {
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

.btn-icon-small:hover {
    background: var(--accent-solid);
    transform: scale(1.1);
}

.fav-btn {
    /* Removed absolute positioning as it's now in flex container */
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    z-index: 20;
}

.media-card:hover .fav-btn {
    opacity: 1;
}

.fav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.fav-btn.active {
    color: var(--accent-solid);
    background: rgba(255, 255, 255, 0.1);
}

.card-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.card-genres {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.card-runtime {
    font-variant-numeric: tabular-nums;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 1rem;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-modal:hover {
    background: var(--accent-solid);
}

.modal-layout {
    display: flex;
    gap: 2rem;
    padding: 2rem;
}

.modal-poster-container {
    flex-shrink: 0;
    width: 300px;
}

.modal-poster {
    width: 100%;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.modal-info {
    flex-grow: 1;
}

.modal-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.1;
}

.modal-meta {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.modal-rating {
    color: #fbbf24;
}

.modal-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.modal-desc {
    line-height: 1.6;
    color: var(--text-secondary);
}

.modal-cast {
    color: var(--text-secondary);
}

.modal-actions {
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .modal-layout {
        flex-direction: column;
        padding: 1.5rem;
    }

    .modal-poster-container {
        width: 100%;
        max-width: 250px;
        margin: 0 auto;
    }

    .modal-title {
        font-size: 1.75rem;
        text-align: center;
    }

    .modal-meta {
        justify-content: center;
        font-size: 1rem;
    }

    .modal-genres {
        justify-content: center;
    }
}

.fav-btn svg {
    pointer-events: none;
}

/* Load More */
.load-more-container {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    padding-bottom: 2rem;
}

.btn-secondary {
    padding: 0.8rem 2rem;
    font-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

/* View More Link */
.view-more {
    color: var(--accent-solid);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.view-more:hover {
    color: #9b6bcc;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }

    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }

    .hero-content h1 {
        font-size: 2rem;
    }

    /* Mobile Header Adjustments */
    .search-container {
        display: block;
        margin: 0 0.5rem;
        flex: 1;
        width: auto;
    }

    .search-wrapper {
        height: 40px;
    }

    #search-input {
        padding: 0.5rem 2.5rem 0.5rem 2.5rem;
        font-size: 1rem;
    }

    .search-icon {
        left: 0.8rem;
        width: 18px;
        height: 18px;
        top: 50%;
        transform: translateY(-50%);
    }

    .logo {
        font-size: 1.5rem;
    }

    #app-badge {
        display: none !important;
    }
}

/* Chatbot Styles */
#chat-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--accent-gradient);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    border: none;
    color: white;
}

#chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(118, 75, 162, 0.6);
}

#chat-fab svg {
    width: 32px;
    height: 32px;
    transition: transform 0.3s;
}

#chat-fab.active svg {
    transform: rotate(90deg);
}

/* Chat Panel on Desktop: Right side column, 400px, full height, rounded corners, shadow, z-index, overflow hidden, transform origin, transition, border, pointer events */
#chat-iframe-container {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 400px;
    height: calc(100% - 120px);
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 9998;
    overflow: hidden;
    transform-origin: bottom right;
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s, visibility 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Tablets, Desktop App in Windowed Mode: 50% width, full height, rounded corners, shadow, z-index, overflow hidden, transform origin, transition, border, pointer events */
@media (max-width: 768px) {
    #chat-iframe-container {
        width: 50%;
        right: 20px;
        bottom: 100px;
        height: calc(100% - 120px);
    }
}

/* Native App Banner */
#native-app-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(90deg, #1a1a1a 0%, #2d2d2d 100%);
    border-bottom: 1px solid var(--accent-solid);
    padding: 0.8rem 1.5rem;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.3s ease-in-out;
}

#native-app-banner.hidden {
    display: none !important;
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.banner-icon {
    font-size: 1.5rem;
    color: var(--accent-solid);
}

.banner-text {
    font-size: 0.95rem;
    color: #e0e0e0;
}

.banner-text strong {
    color: white;
    font-weight: 600;
}

.banner-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-banner {
    background: var(--accent-gradient);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: transform 0.2s;
    white-space: nowrap;
}

.btn-banner:hover {
    transform: scale(1.05);
}

.banner-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
}

.banner-close:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 768px) {
    #native-app-banner {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding: 1rem;
    }

    .banner-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .banner-actions {
        width: 100%;
        justify-content: center;
    }

    .banner-close {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
    }
}


#chat-iframe-container.hidden {
    transform: translateY(100%);
    /* Slide down */
}

#chat-fab {
    bottom: 20px;
    right: 20px;
    z-index: 10000;
}


/* Chat Panel on Mobile (Portrait Mode): Full width, full height, rounded corners, shadow, z-index, overflow hidden, transform origin, transition, border, pointer events */
@media (max-width: 480px) {
    #chat-iframe-container {
        width: calc(100% - 40px);
        right: 20px;
        bottom: 100px;
        height: calc(100% - 120px);
    }

    #chat-fab {
        bottom: 20px;
        right: 20px;
    }
}



/* This was an attempt to make chat work while viewing a movie on your phone.
It failed miserably. We should probably hide the chat toggler in this case until we find a solution 
@media (max-width: 900px) and (orientation: landscape) {
    #chat-iframe-container {
        top: 0;
        bottom: 0;
        right: 0;
        width: 33vw;
        height: 100%;
        border-radius: 0;
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        transform-origin: right center;
    }

    #chat-iframe-container.hidden {
        transform: translateX(100%);
    }
} */

#chat-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
}


/* Onboarding Modal */
#onboarding-modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20000;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
}

#onboarding-modal-container.hidden {
    display: none;
}

#onboarding-iframe {
    width: 100%;
    height: 100%;
    border: none;
}