:root {
    --bg-color: #f7f9fc;
    --card-bg: #ffffff;
    --text-main: #1a1c20;
    --text-secondary: #626c7e;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --border-color: #e2e8f0;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --radius-sm: 8px;
    --radius-md: 12px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;

    /* Layout */
    --container-width: 1200px;
    --header-height: 70px;
}

body.dark-theme {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

body.dark-theme .rating-badge {
    background: rgba(132, 204, 22, 0.2);
    color: #bef264;
}

body.dark-theme .mood-tag {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    min-height: 100vh;
}

/* Header */
.main-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
}

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

.site-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-main), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--text-main);
    color: var(--text-main);
}

.btn-danger {
    background: #fee2e2;
    color: var(--danger-color);
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Filters */
.filters-section {
    margin: 20px 0 40px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.search-bar {
    flex-grow: 1;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

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

.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 42px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 16px;
    background: var(--card-bg);
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filters-dropdown {
    width: 240px;
    flex-shrink: 0;
}

/* Movie Grid */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 30px 20px;
    padding-bottom: 40px;
}

.movie-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: default;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.movie-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-color);
}

.card-info {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-poster {
    width: 100%;
    aspect-ratio: 2/3;
    background: #e2e8f0;
    overflow: hidden;
    position: relative;
    border-bottom: 1px solid var(--border-color);
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 8px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
}

.card-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.dot {
    font-size: 10px;
    opacity: 0.5;
}

.card-mood {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mood-tag {
    font-size: 11px;
    background: var(--bg-color);
    padding: 2px 8px;
    border-radius: 12px;
    color: var(--text-secondary);
    display: inline-block;
}

/* Card Overlay for Description */
.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    backdrop-filter: blur(2px);
}

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

.card-desc {
    font-size: 13px;
    line-height: 1.5;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 8;
    line-clamp: 8;
    -webkit-box-orient: vertical;
}

.rating-badge {
    background: #ecfccb;
    color: #4d7c0f;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

/* Edit Panel */
.edit-mode-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: var(--card-bg);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding: 24px;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.edit-mode-panel.hidden {
    transform: translateX(100%);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.movie-form .form-group {
    margin-bottom: 16px;
}

.movie-form label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.movie-form input,
.movie-form select,
.movie-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-actions {
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Mood Checkboxes Grid */
.mood-checkboxes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    background: var(--bg-color);
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    max-height: 160px;
    overflow-y: auto;
}

.mood-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.mood-checkbox:hover {
    background: rgba(59, 130, 246, 0.1);
}

.mood-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* API Results */
.api-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 10;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 4px;
}

.api-result-item {
    padding: 10px;
    display: flex;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.api-result-item:hover {
    background: var(--bg-color);
}

.api-result-item img {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 320px;
}

.modal h3 {
    margin-bottom: 16px;
}

.modal input {
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Detail Modal specific */
.detail-modal-content {
    max-width: 900px;
    width: 95%;
    padding: 0;
    overflow: hidden;
    position: relative;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.detail-layout {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.detail-poster {
    width: 340px;
    flex-shrink: 0;
    background: #000;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Blurred background layer */
.detail-poster::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background-image: var(--poster-url);
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.5);
    z-index: 1;
}

.detail-poster img {
    position: relative;
    z-index: 2;
    width: auto;
    max-width: 100%;
    height: 100%;
    object-fit: contain;
    /* Don't crop, show full poster */
    display: block;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.detail-info {
    padding: 40px 50px;
    flex-grow: 1;
    overflow-y: auto;
    max-height: 80vh;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 20px;
}

.detail-header h2 {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 16px;
    font-weight: 500;
}

.detail-description {
    font-size: 17px;
    line-height: 1.7;
    color: var(--text-main);
    white-space: pre-wrap;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .detail-modal-content {
        max-height: 85vh;
        width: 90%;
        display: block;
        overflow-y: auto;
        /* Single scrollbar for the whole content */
    }

    .detail-layout {
        flex-direction: column;
    }

    .detail-poster {
        width: 100%;
        height: 250px;
        /* Compact height for mobile header */
        flex-shrink: 0;
    }

    .detail-poster img {
        height: 90%;
        /* Leave some space for the blurred bg to show */
        width: auto;
        border-radius: 8px;
    }

    .detail-info {
        padding: 24px 20px;
        max-height: none;
        /* Let its content contribute to modal scrolling */
        overflow: visible;
    }

    .detail-header h2 {
        font-size: 24px;
    }

    .detail-description {
        font-size: 15px;
        line-height: 1.6;
    }

    .close-btn {
        background: rgba(0, 0, 0, 0.4);
        top: 15px;
        right: 15px;
        z-index: 10;
    }
}

/* Custom Dropdown Styles */
.filters-dropdown {
    position: relative;
    width: 240px;
    flex-shrink: 0;
}

.dropdown-trigger {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 16px;
    background: var(--card-bg);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.dropdown-trigger:hover {
    border-color: var(--text-secondary);
}

.dropdown-trigger.active {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: dropdownSlide 0.2s ease-out;
}

@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dropdown-item:hover {
    background: var(--bg-color);
    color: var(--accent-color);
}

.dropdown-item.active {
    background: var(--accent-color);
    color: white;
}

.dropdown-menu.hidden {
    display: none;
}

.mobile-desc {
    display: none;
}

@media (max-width: 600px) {
    .main-header {
        height: auto;
        flex-wrap: wrap;
        gap: 16px;
        padding: 15px 0;
    }

    .logo {
        flex: 1;
    }

    .controls {
        gap: 8px;
    }

    .main-nav {
        width: 100%;
        order: 3;
        display: flex;
    }

    .nav-btn {
        flex: 1;
        padding: 8px 4px;
        font-size: 13px;
        white-space: nowrap;
    }

    #edit-mode-btn {
        padding: 8px 10px;
        font-size: 12px;
    }

    .filters-section {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .filters-dropdown {
        width: 100%;
    }

    /* Mobile List View */
    .edit-mode-panel {
        width: 100%;
    }

    .movie-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .movie-card {
        display: flex;
        flex-direction: row;
        height: 140px;
        align-items: stretch;
        border-radius: var(--radius-md);
    }

    .card-info {
        padding: 12px;
        justify-content: center;
    }

    .card-poster {
        width: 100px;
        height: 100%;
        flex-shrink: 0;
        border-radius: 0;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        aspect-ratio: auto;
    }

    /* Hide overlay on mobile */
    .card-overlay {
        display: none;
    }

    .card-header {
        margin-bottom: 4px;
    }

    .card-header h3 {
        font-size: 15px;
    }

    .card-meta {
        font-size: 12px;
        margin-bottom: 8px;
    }

    .card-mood {
        margin-top: auto;
    }

    .mobile-desc {
        display: block;
        font-size: 12px;
        color: var(--text-secondary);
        margin-top: 4px;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .mood-text {
        display: none;
    }
}
/* Navigation */
.main-nav {
    display: flex;
    gap: 8px;
    background: var(--border-color);
    padding: 4px;
    border-radius: var(--radius-md);
}

.nav-btn {
    padding: 6px 16px;
    border-radius: calc(var(--radius-md) - 4px);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.2s;
}

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

.nav-btn.active {
    background: var(--card-bg);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

body.dark-theme .main-nav {
    background: rgba(255, 255, 255, 0.05);
}

/* About Section */
.about-section {
    padding: 40px 0;
    max-width: 800px;
    margin: 0 auto;
}

.about-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.about-content h2 {
    margin-bottom: 24px;
    font-size: 28px;
    background: linear-gradient(135deg, var(--text-main), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.about-content p {
    margin-bottom: 16px;
    font-size: 17px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.hidden {
    display: none !important;
}
