/* --- Base Styles and Variables --- */
:root {
    --primary: #6c63ff;
    --primary-dark: #4c46b6;
    --secondary: #ff6b6b;
    --accent: #ffd166;
    --dark: #181829;
    --darker: #12121f;
    --light: #f7f7ff;
    --gray: #8c8ca9;
    --gray-light: #e5e5e9;
    --card-bg: rgba(32, 32, 46, 0.9);
    --gradient-primary: linear-gradient(135deg, var(--primary), #4c46b6);
    --gradient-dark: linear-gradient(135deg, var(--darker), var(--dark));
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.2);
    --transition-normal: 0.3s ease;
    --border-radius-sm: 8px; /* Added for consistency */
    --border-radius-md: 12px;
    --border-radius-lg: 50px; /* For rounded inputs */
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--darker);
    color: var(--light);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- Header / Navbar --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    z-index: 1000;
    transition: var(--transition-normal);
}

.nav-container {
    width: 100%;
    height: 100%;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo img {
    height: 40px;
    transition: var(--transition-normal);
}

.logo:hover img {
    transform: scale(1.05);
}

.logo-text {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -1px;
    color: var(--light);
}

/* --- Hero Section --- */
.hero {
    position: relative;
    height: 100vh;
    min-height: 700px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    padding: 0 1rem;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-dark);
    opacity: 0.8;
    z-index: -1;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI1IiBoZWlnaHQ9IjUiPgo8cmVjdCB3aWR0aD0iNSIgaGVpZ2h0PSI1IiBmaWxsPSIjMTIxMjFmIj48L3JlY3Q+CjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiMyMDIwMzAiPjwvcmVjdD4KPC9zdmc+');
    opacity: 0.3;
    z-index: -1;
}

.hero-content {
    max-width: 900px; /* Increased from 800px */
    width: 100%;
    z-index: 1;
}

#main-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.2;
    margin-bottom: 2.5rem;
    transition: all 0.4s ease;
}

#main-title .underline {
    position: relative;
    display: inline-block;
}

#main-title .underline::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    border-radius: 2px;
}

/* --- Search Form --- */
.search-form {
    margin-bottom: 1.5rem;
}

.input-wrapper {
    position: relative;
    max-width: 700px;
    margin: 0 auto;
}

#search-input {
    width: 100%;
    padding: 20px 80px 20px 30px;
    font-size: 1.1rem;
    font-family: 'Poppins', sans-serif;
    color: var(--light);
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-lg);
    backdrop-filter: blur(10px);
    transition: var(--transition-normal);
}

#search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.3);
}

#search-input::placeholder {
    color: var(--gray);
    transition: var(--transition-normal);
}

.submit-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
}

.submit-btn:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(108, 99, 255, 0.6);
}

/* --- Mode Toggle --- */
.mode-toggle {
    display: flex;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-lg);
    width: fit-content;
    margin: 0 auto 2rem;
    padding: 5px;
    position: relative;
}

.toggle-btn {
    padding: 10px 25px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray);
    background: transparent;
    border: none;
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    transition: color var(--transition-normal);
    z-index: 1;
}

.toggle-btn.active {
    color: var(--light);
    background: var(--primary);
    box-shadow: 0 2px 10px rgba(108, 99, 255, 0.4);
}

/* --- Results & Trending Sections --- */
.results-section, .trending-section {
    padding: 60px 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.trending-section .section-title {
    text-align: center;
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 3rem;
    position: relative;
}

.trending-section .section-title::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: -10px;
    height: 3px;
    width: 80px;
    background: var(--gradient-primary);
    border-radius: 3px;
}

.trending-category {
    margin-bottom: 3rem;
}

.category-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--gray-light);
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
}

/* --- Search Page Specific Styles --- */
/* These styles have been moved to /search/styles.css */

/* --- Media Grid & Cards --- */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem;
}

.media-card {
    background: var(--card-bg);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-normal);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
}

.media-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

.card-poster {
    position: relative;
}

.card-poster img {
    width: 100%;
    height: auto;
    display: block;
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(18, 18, 31, 0.98) 20%, rgba(18, 18, 31, 0.7) 50%, transparent 100%);
    color: var(--light);
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

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

.overlay-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 5px;
    line-height: 1.2;
}

.overlay-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.8rem;
    color: var(--gray);
}

.overlay-badge {
    background: var(--primary);
    color: var(--light);
    padding: 2px 8px;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 0.7rem;
}

.overlay-overview {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--gray-light);
    margin: 0;
    /* Text truncation */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4; /* Adjust number of lines shown */
    -webkit-box-orient: vertical;
}

.card-vote {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(18, 18, 31, 0.8);
    backdrop-filter: blur(5px);
    color: var(--accent);
    font-weight: 700;
    padding: 5px 10px;
    border-radius: var(--border-radius-sm); /* Updated roundness */
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-body {
    padding: 15px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--light);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Loading Spinner --- */
.loading-spinner {
    grid-column: 1 / -1; /* Span across all grid columns */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Footer --- */
.site-footer {
    background: var(--dark);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 25px 0;
    color: var(--gray);
    font-size: 0.9rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-left, .footer-right {
    flex: 1;
}

.footer-left {
    text-align: left;
}

.footer-center {
    text-align: center;
}

.footer-right {
    text-align: right;
}

.footer-link {
    color: var(--primary);
    transition: var(--transition-normal);
    text-decoration: none;
    font-weight: 500;
}

.footer-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.tmdb-attribution {
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px 2rem 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    margin-top: 15px;
    padding-top: 15px;
}

.tmdb-logo {
    height: 50px;
    opacity: 0.7;
}

.tmdb-text {
    font-size: 0.75rem;
    color: var(--gray);
    opacity: 0.8;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    .hero {
        min-height: 600px;
    }
    #main-title {
        margin-bottom: 2rem;
    }
    #search-input {
        padding: 15px 65px 15px 20px;
        font-size: 1rem;
    }
    .submit-btn {
        width: 45px;
        height: 45px;
        right: 6px;
    }
    .toggle-btn {
        padding: 8px 18px;
    }
    .footer-content {
        flex-wrap: wrap; /* Allow wrapping on small screens */
        justify-content: center; /* Center items when they wrap */
        gap: 15px;
        right: 6px;
    }
    
    .toggle-btn {
        padding: 8px 18px;
    }
    .footer-content {
        flex-wrap: wrap; /* Allow wrapping on small screens */
        justify-content: center; /* Center items when they wrap */
        gap: 15px;
    }

}