/* Movies Page Styles */

.movies-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--bg-color, #fff);
    color: var(--text-color, #333);
}

/* Override theme's article max-width for movies page */
article.movies-container {
    max-width: 100% !important;
    width: 100%;
}

/* Header */
.movies-header {
    text-align: center;
    margin-bottom: 30px;
}

.movies-title {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 20px;
    font-weight: 700;
}

/* Year Navigation */
.movies-years-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.year-nav-link {
    padding: 8px 20px;
    background: #f5f5f5;
    border-radius: 20px;
    color: #666;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.year-nav-link:hover {
    background: #e8f5e9;
    color: #2d8c3c;
}

.year-nav-link.active {
    background: #2d8c3c;
    color: white;
    border-color: #2d8c3c;
}

/* Stats */
.movies-stats {
    text-align: center;
    font-size: 1rem;
    color: #666;
    margin-bottom: 25px;
}

.movies-stats strong {
    color: #2d8c3c;
    font-weight: 600;
}

.movies-stats .divider {
    margin: 0 15px;
    color: #ddd;
}

/* Controls (Filters & Sort) */
.movies-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 12px 15px;
    background: #f9f9f9;
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 12px;
}

.movies-filters,
.movies-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

.movies-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #555;
}

.movies-controls select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
    color: #333;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.3s;
}

.movies-controls select:hover {
    border-color: #2d8c3c;
}

.movies-controls select:focus {
    outline: none;
    border-color: #2d8c3c;
    box-shadow: 0 0 0 3px rgba(45, 140, 60, 0.1);
}

/* Movies Grid */
.movies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
    max-width: 100%;
}

/* Desktop default: 3 columns */
@media (min-width: 768px) {
    .movies-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large screens: 4 columns */
@media (min-width: 1200px) {
    .movies-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Movie Card */
.movie-card {
    position: relative;
    display: block;
    background: white;
    border-radius: 12px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.movie-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

/* Poster */
.movie-poster {
    position: relative;
    width: 100%;
    padding-bottom: 150%;
    /* 2:3 aspect ratio */
    overflow: hidden;
    background: #f0f0f0;
    border-radius: 12px 12px 0 0;
}

.movie-poster img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.poster-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    font-size: 4rem;
    color: #ccc;
}

/* Overlay */
.movie-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

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

.overlay-content {
    color: white;
    text-align: center;
    max-height: 100%;
    overflow-y: auto;
}

.overlay-info {
    font-size: 0.85rem;
    margin: 8px 0;
    line-height: 1.4;
}

.overlay-info strong {
    display: block;
    margin-bottom: 3px;
    color: #2d8c3c;
}

.overlay-comment {
    font-size: 0.9rem;
    font-style: italic;
    margin: 12px 0;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    line-height: 1.5;
}

.view-douban {
    display: inline-block;
    margin-top: 10px;
    padding: 6px 15px;
    background: #2d8c3c;
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.85rem;
    transition: background 0.3s;
}

.view-douban:hover {
    background: #237a30;
}

/* Movie Info */
.movie-info {
    padding: 10px;
}

.movie-card .movie-title,
.movie-card h3.movie-title {
    font-size: 0.75rem !important;
    font-weight: 600;
    color: var(--text-color, #1a1a1a);
    margin: 0 0 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.2rem;
    /* 两行高度约为 2.2rem */
    line-height: 1.1rem;
    white-space: normal;
}

/* Dark Mode visibility fix */
@media (prefers-color-scheme: dark) {

    .movie-card .movie-title,
    .movie-card h3.movie-title {
        color: #f0f0f0 !important;
    }
}

.movie-card .movie-original-title {
    font-size: 0.75rem !important;
    color: var(--text-light, #999);
    margin: 0 0 8px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Movie Meta (Rating & Date) */
.movie-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.movie-rating {
    display: flex;
    gap: 1px;
}

.movie-rating .star {
    color: #ddd;
    font-size: 0.85rem;
}

.movie-rating .star.filled {
    color: #ffa500;
}

.movie-date {
    font-size: 0.75rem;
    color: #999;
}

/* Empty State */
.movies-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media (max-width: 1200px) {
    .movies-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 768px) {
    .movies-container {
        padding: 10px;
    }

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

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

    .movies-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px;
    }

    .movies-filters {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .movies-filters label {
        flex: 1;
        min-width: 45%;
    }

    .movies-sort {
        width: 100%;
    }

    .movies-controls label {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .movies-controls label span {
        font-size: 0.75rem;
    }

    .movies-controls select {
        width: 100%;
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .movies-view-toggle {
        align-self: flex-end;
    }

    .movie-info {
        padding: 6px;
    }

    .movie-card .movie-title,
    .movie-card h3.movie-title {
        font-size: 0.65rem !important;
        line-height: 1rem;
        height: 2rem;
    }

    .movie-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }

    .movie-rating .star {
        font-size: 0.7rem;
    }

    .movie-date {
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .movies-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .movie-card {
        border-radius: 6px;
    }

    .movie-info {
        padding: 5px;
    }

    .movie-card .movie-title,
    .movie-card h3.movie-title {
        font-size: 0.6rem !important;
    }

    .movie-original-title {
        display: none;
    }

    .movie-meta {
        margin-top: 4px;
    }
}

@media (max-width: 360px) {
    .movies-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
}

/* Year Divider */
.year-divider {
    grid-column: 1 / -1;
    margin: 25px 0 10px 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d8c3c;
    display: flex;
    align-items: center;
}

/* Movie Tooltip */
.movie-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 280px;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.5;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    pointer-events: none;
    margin-bottom: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.movie-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.92);
}

.movie-card:hover .movie-tooltip {
    opacity: 1;
    visibility: visible;
}

.movie-tooltip p {
    margin: 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-indent: 0;
    padding-left: 0;
}

.movie-tooltip p:first-child {
    margin-top: 0;
}

.movie-tooltip p:last-child {
    margin-bottom: 0;
}

.movie-tooltip strong {
    color: #2d8c3c;
}

.movie-tooltip .rating-highlight {
    color: #ffa500;
    font-weight: bold;
}

.movie-tooltip .tooltip-comment {
    font-style: italic;
    color: #ccc;
    white-space: normal;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Hide tooltip on small screens */
@media (max-width: 768px) {
    .movie-tooltip {
        display: none;
    }
}

/* Minimalist Mode */
.movies-grid.minimal-mode {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Color palette for minimal mode rows */
.movies-grid.minimal-mode .movie-card:nth-child(8n+1) {
    background-color: rgba(37, 99, 235, 0.08);
}

.movies-grid.minimal-mode .movie-card:nth-child(8n+2) {
    background-color: rgba(22, 163, 74, 0.08);
}

.movies-grid.minimal-mode .movie-card:nth-child(8n+3) {
    background-color: rgba(202, 138, 4, 0.08);
}

.movies-grid.minimal-mode .movie-card:nth-child(8n+4) {
    background-color: rgba(147, 51, 234, 0.08);
}

.movies-grid.minimal-mode .movie-card:nth-child(8n+5) {
    background-color: rgba(234, 88, 12, 0.08);
}

.movies-grid.minimal-mode .movie-card:nth-child(8n+6) {
    background-color: rgba(8, 145, 178, 0.08);
}

.movies-grid.minimal-mode .movie-card:nth-child(8n+7) {
    background-color: rgba(190, 24, 93, 0.08);
}

.movies-grid.minimal-mode .movie-card:nth-child(8n+8) {
    background-color: rgba(5, 150, 105, 0.08);
}

.movies-grid.minimal-mode .movie-card {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 8px;
    box-shadow: none;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.movies-grid.minimal-mode .movie-card:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: var(--border-color, #e0e0e0);
}

.movies-grid.minimal-mode .movie-poster {
    display: none;
}

.movies-grid.minimal-mode .movie-info {
    flex: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.movies-grid.minimal-mode .movie-card .movie-title,
.movies-grid.minimal-mode .movie-card h3.movie-title {
    height: auto;
    margin: 0;
    font-size: 1rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    color: #1a1a1a !important;
}

/* Dark mode override for minimal mode title */
[data-theme="dark"] .movies-grid.minimal-mode .movie-card .movie-title,
[data-theme="dark"] .movies-grid.minimal-mode .movie-card h3.movie-title {
    color: #f0f0f0 !important;
}

.movies-grid.minimal-mode .movie-original-title {
    display: none;
}

.movies-grid.minimal-mode .movie-meta {
    margin-top: 0;
    gap: 15px;
    flex-shrink: 0;
}

.movies-grid.minimal-mode .movie-date {
    width: 80px;
    text-align: right;
}

/* Tooltip with poster in minimal mode */
.movies-grid.minimal-mode .movie-tooltip {
    display: flex;
    gap: 12px;
    max-width: 380px;
    left: 0;
    transform: none;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.95);
}

.movies-grid.minimal-mode .movie-tooltip::after {
    left: 60px;
}

/* Ensure hovered card is above others */
.movies-grid.minimal-mode .movie-card {
    position: relative;
    z-index: 1;
}

.movies-grid.minimal-mode .movie-card:hover {
    z-index: 100;
}

.tooltip-poster {
    flex-shrink: 0;
    width: 80px;
    border-radius: 4px;
    overflow: hidden;
}

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

.tooltip-content {
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .movies-grid.minimal-mode .movie-card {
        flex-wrap: wrap;
        gap: 5px;
    }

    .movies-grid.minimal-mode .movie-info {
        flex-wrap: wrap;
    }
}


/* View Toggle Buttons */
.movies-view-toggle {
    display: flex;
    gap: 5px;
    align-items: center;
}

.view-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-btn:hover {
    border-color: #2d8c3c;
    background: #f0fff0;
}

.view-btn.active {
    background: #2d8c3c;
    border-color: #2d8c3c;
    color: white;
}

/* Dark Mode Support */
[data-theme="dark"] .movie-card,
.dark-mode .movie-card {
    background: #1e1e1e;
}

[data-theme="dark"] .movie-title,
.dark-mode .movie-title,
[data-theme="dark"] .movie-card h3.movie-title,
.dark-mode .movie-card h3.movie-title {
    color: #999 !important;
}

[data-theme="dark"] .movie-original-title,
.dark-mode .movie-original-title {
    color: #777;
}

[data-theme="dark"] .movies-controls,
.dark-mode .movies-controls {
    background: #2a2a2a;
}

[data-theme="dark"] .movies-controls select,
.dark-mode .movies-controls select {
    background: #333;
    color: #fff;
    border-color: #444;
}

[data-theme="dark"] .view-btn,
.dark-mode .view-btn {
    background: #333;
    border-color: #444;
    color: #fff;
}

[data-theme="dark"] .view-btn.active,
.dark-mode .view-btn.active {
    background: #2d8c3c;
    border-color: #2d8c3c;
}

/* Toggle Switch Styles */
.view-toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.toggle-label {
    font-size: 1.2rem;
}

/* Link Style Mode Toggle */
.view-mode-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.mode-link {
    text-decoration: none;
    color: #999;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.mode-link:hover {
    color: #2d8c3c;
}

.mode-link.active {
    color: #2d8c3c;
    font-weight: 600;
}

.mode-divider {
    color: #ccc;
    font-size: 0.85rem;
}

[data-theme="dark"] .mode-link,
.dark-mode .mode-link {
    color: #777;
}

[data-theme="dark"] .mode-link:hover,
.dark-mode .mode-link:hover,
[data-theme="dark"] .mode-link.active,
.dark-mode .mode-link.active {
    color: #2d8c3c;
}

[data-theme="dark"] .mode-divider,
.dark-mode .mode-divider {
    color: #555;
}
/* Force Light Theme */
[data-theme="light"] .movies-container,
.movies-container[data-theme="light"] {
    background-color: #ffffff !important;
    color: #333333 !important;
}

[data-theme="light"] .movie-card,
.movie-card[data-theme="light"] {
    background: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
}

[data-theme="light"] .movie-card .movie-title,
.movie-card[data-theme="light"] .movie-title {
    color: #333 !important;
}

[data-theme="light"] .movies-header,
.movies-header[data-theme="light"] {
    color: #333 !important;
}

[data-theme="light"] .movies-title,
.movies-title[data-theme="light"] {
    color: #333 !important;
}

[data-theme="light"] .movies-stats,
.movies-stats[data-theme="light"] {
    color: #666 !important;
}

[data-theme="light"] .movies-empty,
.movies-empty[data-theme="light"] {
    color: #666 !important;
}

[data-theme="light"] .year-nav-link,
.year-nav-link[data-theme="light"] {
    background: #f5f5f5 !important;
    color: #666 !important;
}

[data-theme="light"] .year-nav-link:hover,
.year-nav-link[data-theme="light"]:hover {
    background: #e8f5e9 !important;
    color: #2d8c3c !important;
}

[data-theme="light"] .year-nav-link.active,
.year-nav-link.active[data-theme="light"] {
    background: #2d8c3c !important;
    color: white !important;
}

/* Infinite Scroll Loading Spinner */
.infinite-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #666;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2d8c3c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Card click fix - ensure entire card is clickable */
.movie-card {
    position: relative;
    z-index: 1;
}

.movie-card:hover {
    z-index: 100;
}

.movie-card:hover .movie-tooltip {
    z-index: 101;
}
