/* Root Variables */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-card: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --accent: #e50914;
    --accent-hover: #f40612;
    --border: #3a3a3a;
    --shadow: rgba(0, 0, 0, 0.5);
}

.light-theme {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --accent: #e50914;
    --accent-hover: #f40612;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 40px;
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #e50914 0%, #ff6b6b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-toggle {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

.theme-toggle:hover {
    transform: scale(1.05);
    border-color: var(--accent);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.sun-icon {
    animation: rotate 20s linear infinite;
}

/* Search Section */
.search-section {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: 0 4px 20px var(--shadow);
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-select {
    position: relative;
}

.filter-select {
   width: 100%;
    padding: 14px 40px 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.filter-select:hover {
    border-color: var(--accent);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.1);
}

.filter-select option {
    padding: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.filter-select option:hover {
    background: var(--bg-secondary);
}

.select-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.custom-select:hover .select-arrow {
    color: var(--accent);
}

.search-btn {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.search-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(229, 9, 20, 0.3);
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.discover-btn,
.watchlist-btn {
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.discover-btn:hover,
.watchlist-btn:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

/* Results Section */
.results-section,
.watchlist-section {
    margin-bottom: 40px;
}

.section-title {
    font-size: 2rem;
    margin-bottom: 30px;
    font-weight: 700;
}

.movies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 30px;
}

.movie-card {
    background: var(--bg-secondary);
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
}

.movie-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 30px var(--shadow);
}

.movie-poster {
    width: 100%;
    height: 375px;
    object-fit: cover;
    background: var(--bg-card);
}

.movie-info {
    padding: 20px;
}

.movie-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.4;
}

.movie-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.movie-year {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.movie-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #ffd700;
    font-weight: 600;
}

.movie-overview {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.movie-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-watchlist,
.btn-remove {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-watchlist {
    background: var(--accent);
    color: white;
}

.btn-watchlist:hover {
    background: var(--accent-hover);
}

.btn-remove {
    background: #dc3545;
    color: white;
}

.btn-remove:hover {
    background: #c82333;
}

/* Loading */
.loading {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 60px;
}

.loading.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.load-more-btn {
    display: block;
    margin: 40px auto 0;
    padding: 16px 40px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.load-more-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
}

.load-more-btn.hidden {
    display: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: sticky;
    top: 20px;
    right: 20px;
    float: right;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
}

.modal-body {
    padding: 40px;
}

.modal-poster {
    width: 100%;
    border-radius: 15px;
    margin-bottom: 30px;
}

.modal-title {
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.modal-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

.modal-overview {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 20px;
}

.modal-genres {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.genre-tag {
    padding: 8px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Utility */
.hidden {
    display: none !important;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 60px 20px;
}

/* Responsive */
@media (max-width: 768px) and (min-width: 769px) {
   .container {
        padding: 30px;
    }

    .logo {
        font-size: 2.2rem;
    }

    .filters {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-group:last-child {
        grid-column: 1 / -1;
    }

    .movies-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .logo {
        font-size: 2rem;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        grid-template-columns: 1fr;
    }

    .movies-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .movie-poster {
        height: 300px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-title {
        font-size: 1.8rem;
    }

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

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }

    .logo {
        font-size: 1.8rem;
    }

    .header {
        padding: 15px 0;
        margin-bottom: 30px;
    }

    .search-section {
        padding: 20px;
    }

    .movies-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .movie-poster {
        height: 400px;
    }

    .modal-body {
        padding: 15px;
    }

    .modal-title {
        font-size: 1.5rem;
    }

    .section-title {
        font-size: 1.3rem;
    }
}