/* ==================== */
/* CSS Variables */
/* ==================== */
:root {
    --primary-color: #1a1a2e;
    --secondary-color: #16213e;
    --accent-color: #e94560;
    --text-color: #ffffff;
    --text-secondary: #b3b3b3;
    --background: #0f0f1e;
    --card-background: #16213e;
    --border-radius: 12px;
    --transition: all 0.3s ease;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 12px rgba(0, 0, 0, 0.4);
}

/* ==================== */
/* Reset & Base Styles */
/* ==================== */
* {
    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(--background);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ==================== */
/* Header */
/* ==================== */
.header {
    background-color: var(--primary-color);
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background: transparent;
    border: 2px solid transparent;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.nav-btn:hover {
    color: var(--text-color);
}

.nav-btn.active {
    color: var(--text-color);
    border-color: var(--accent-color);
    background-color: rgba(233, 69, 96, 0.1);
}

/* ==================== */
/* Main Content */
/* ==================== */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 80px);
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

/* ==================== */
/* Search Box */
/* ==================== */
.search-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--secondary-color);
    border-radius: var(--border-radius);
    background-color: var(--card-background);
    color: var(--text-color);
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.search-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    background-color: var(--accent-color);
    color: var(--text-color);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.search-btn:hover {
    background-color: #d63850;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.search-btn:active {
    transform: translateY(0);
}

/* ==================== */
/* Movies Grid */
/* ==================== */
.movies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* ==================== */
/* Movie Card */
/* ==================== */
.movie-card {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
    position: relative;
}

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

.movie-poster {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    display: block;
}

.movie-poster.placeholder {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 3rem;
}

.movie-info {
    padding: 1rem;
}

.movie-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.movie-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.movie-rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.movie-rating.good {
    color: #4caf50;
}

.movie-rating.average {
    color: #ff9800;
}

.movie-rating.poor {
    color: #f44336;
}

.favorite-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.favorite-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.favorite-btn.active {
    color: var(--accent-color);
}

/* ==================== */
/* Modal */
/* ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: rgba(0, 0, 0, 0.6);
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

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

.modal-header {
    position: relative;
    height: 300px;
    background-size: cover;
    background-position: center;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, var(--card-background) 0%, transparent 100%);
}

.modal-body {
    padding: 2rem;
}

.modal-title {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.modal-details {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    color: var(--text-secondary);
}

.modal-overview {
    line-height: 1.8;
    margin-bottom: 1rem;
}

.modal-genres {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.genre-tag {
    padding: 0.5rem 1rem;
    background-color: rgba(233, 69, 96, 0.2);
    border: 1px solid var(--accent-color);
    border-radius: 20px;
    font-size: 0.85rem;
}

/* ==================== */
/* Loading & Messages */
/* ==================== */
.loading {
    text-align: center;
    padding: 2rem;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.error-message {
    text-align: center;
    padding: 2rem;
    color: var(--accent-color);
    background-color: rgba(233, 69, 96, 0.1);
    border-radius: var(--border-radius);
    margin: 1rem 0;
}

.no-favorites {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* ==================== */
/* Responsive */
/* ==================== */
@media (max-width: 768px) {
    .logo {
        font-size: 1.25rem;
    }

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

    .modal-body {
        padding: 1.5rem;
    }
}
