:root {
    --primary: #e50914;
    --primary-dark: #b20710;
    --bg: #0f0f0f;
    --bg-light: #1a1a1a;
    --bg-lighter: #2a2a2a;
    --text: #ffffff;
    --text-secondary: #b3b3b3;
    --border: #333;
    --radius: 8px;
    --shadow: 0 4px 20px rgba(0,0,0,0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
.header {
    background: rgba(15,15,15,0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
}

.nav {
    display: flex;
    gap: 8px;
}

.nav-item {
    padding: 8px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    transition: all 0.3s;
}

.nav-item:hover, .nav-item.active {
    color: var(--text);
    background: var(--bg-lighter);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
}

.mobile-menu {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
    padding: 10px;
    z-index: 99;
    flex-direction: column;
    gap: 5px;
}

.mobile-menu a {
    padding: 12px 16px;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius);
}

.mobile-menu a:hover {
    background: var(--bg-lighter);
}

/* Main */
.main-content {
    min-height: calc(100vh - 64px - 80px);
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hero */
.hero {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f0f 100%);
    padding: 80px 20px;
    text-align: center;
    margin-bottom: 40px;
}

.hero-content h1 {
    font-size: 2.5rem;
    margin-bottom: 16px;
    background: linear-gradient(90deg, #fff, #e50914);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 32px;
}

.hero-search {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg-lighter);
    border-radius: 50px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.hero-search input {
    flex: 1;
    padding: 14px 24px;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
    outline: none;
}

.hero-search button {
    padding: 14px 24px;
    background: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    transition: background 0.3s;
}

.hero-search button:hover {
    background: var(--primary-dark);
}

/* Category Section */
.category-section {
    margin: 40px 0 20px;
}

.category-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 14px;
}

.category-card {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.category-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.category-card .cat-icon {
    font-size: 1.8rem;
}

.category-card .cat-name {
    font-size: 0.9rem;
    color: var(--text);
}

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

.section-header h2 {
    font-size: 1.5rem;
}

.more {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}

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

.movie-card {
    background: var(--bg-light);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid var(--border);
}

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

.movie-card .poster {
    width: 100%;
    aspect-ratio: 2/3;
    background: var(--bg-lighter);
    position: relative;
    overflow: hidden;
}

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

.movie-card .poster .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(229,9,20,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.movie-card:hover .play-icon {
    opacity: 1;
}

.movie-card .info {
    padding: 12px;
}

.movie-card .info h3 {
    font-size: 0.95rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-card .info .meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Live Grid */
.live-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.live-card {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.live-card:hover {
    border-color: var(--primary);
    background: var(--bg-lighter);
}

.live-card .live-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-lighter);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: bold;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.live-card .live-info h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.live-card .live-info span {
    font-size: 0.8rem;
    color: #4caf50;
}

/* Search Page */
.search-box {
    display: flex;
    gap: 10px;
    margin: 30px 0;
    max-width: 700px;
}

.search-box input {
    flex: 1;
    padding: 14px 20px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    outline: none;
}

.search-box input:focus {
    border-color: var(--primary);
}

.search-box button {
    padding: 14px 32px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.search-box button:hover {
    background: var(--primary-dark);
}

/* Filter Panel */
.filter-panel {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    position: relative;
}

.filter-toggle-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: var(--bg-lighter);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 2;
}

.filter-toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

#filterPanelContent {
    transition: all 0.3s ease;
}

/* Pagination */
.pagination-wrap {
    margin-top: 32px;
    padding-bottom: 20px;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination-pages {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination-btn:hover:not(:disabled):not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

.pagination-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-nav {
    padding: 0 14px;
    white-space: nowrap;
}

.pagination-ellipsis {
    color: var(--text-secondary);
    padding: 0 4px;
    font-size: 0.9rem;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    margin-left: 8px;
}

.filter-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.filter-row:last-child {
    margin-bottom: 0;
}

.filter-row label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    padding-top: 6px;
    min-width: 40px;
}

.filter-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.filter-btn {
    padding: 6px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

.filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 16px;
    opacity: 0.5;
}

.search-results {
    min-height: 300px;
}

/* Player */
.player-back-bar {
    display: flex;
    align-items: center;
    margin: 16px 0 8px;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-back:hover {
    background: var(--bg-lighter);
    border-color: var(--primary);
    color: var(--primary);
}

.player-wrapper {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin: 8px 0 20px;
}

#dplayer, #livePlayer {
    width: 100%;
    height: 500px;
}

.player-info {
    margin: 20px 0;
}

.player-info h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.player-info p {
    color: var(--text-secondary);
}

.episode-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0 40px;
}

.episode-list button {
    padding: 8px 16px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s;
}

.episode-list button:hover, .episode-list button.active {
    background: var(--primary);
    border-color: var(--primary);
}

/* Live Page */
.live-player-section {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    margin: 20px 0;
}

.live-video-wrapper {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
}

.live-channel-info {
    padding: 16px;
    background: var(--bg-light);
}

.live-channel-info h3 {
    margin-bottom: 4px;
}

.live-channel-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.live-channel-list {
    background: var(--bg-light);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    max-height: 600px;
    display: flex;
    flex-direction: column;
}

.live-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.live-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.live-tab.active, .live-tab:hover {
    color: var(--text);
    background: var(--bg-lighter);
}

.live-tab.active {
    border-bottom: 2px solid var(--primary);
}

/* 地区选择栏 */
.live-region-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.live-region-bar label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.live-region-bar select {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    max-width: 160px;
}

.live-region-bar select:focus {
    border-color: var(--primary);
}

.live-region-bar .region-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.live-channels {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
}

.live-channel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.3s;
}

.live-channel-item:hover, .live-channel-item.active {
    background: var(--bg-lighter);
}

.live-channel-item .ch-num {
    width: 36px;
    height: 36px;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--primary);
    flex-shrink: 0;
}

.live-channel-item .ch-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bg);
}

.live-channel-item .ch-name {
    flex: 1;
    font-size: 0.9rem;
}

.live-channel-item .ch-status {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    flex-shrink: 0;
}

.live-channel-item .ch-status.loading {
    background: #ff9800;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* Config */
.config-section {
    max-width: 900px;
    margin: 30px auto;
}

.config-section h2 {
    margin-bottom: 8px;
}

.config-desc {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.config-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.config-tab {
    padding: 12px 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.3s;
}

.config-tab.active, .config-tab:hover {
    color: var(--text);
    border-bottom-color: var(--primary);
}

.config-panel {
    display: none;
}

.config-panel.active {
    display: block;
}

.config-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

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

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

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

.btn-secondary:hover {
    background: var(--border);
}

.config-item {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.config-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.config-item-header h4 {
    font-size: 1rem;
}

.config-actions {
    display: flex;
    gap: 8px;
}

.config-actions button {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

.config-actions .btn-edit {
    background: #2196f3;
    color: white;
}

.config-actions .btn-delete {
    background: #f44336;
    color: white;
}

.config-actions .btn-test {
    background: #4caf50;
    color: white;
}

.config-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.config-detail p {
    margin-bottom: 4px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    outline: none;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--primary);
}

.form-group textarea {
    min-height: 120px;
    resize: vertical;
    font-family: monospace;
}

/* Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-lighter);
    transition: 0.3s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: 0.3s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider:before {
    transform: translateX(24px);
}

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

.modal.active {
    display: flex;
}

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

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    z-index: 10;
}

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

.modal-body {
    padding: 24px;
}

.modal-body h3 {
    margin-bottom: 20px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-lighter);
    color: var(--text);
    padding: 12px 24px;
    border-radius: 50px;
    border: 1px solid var(--border);
    z-index: 300;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Footer */
.footer {
    background: var(--bg-light);
    border-top: 1px solid var(--border);
    padding: 30px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.footer p {
    margin-bottom: 4px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1024px) {
    .live-player-section {
        grid-template-columns: 1fr;
    }
    .live-channel-list {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    .nav {
        display: none;
    }
    .menu-toggle {
        display: block;
    }
    .mobile-menu.active {
        display: flex;
    }
    .hero-content h1 {
        font-size: 1.8rem;
    }
    #dplayer, #livePlayer {
        height: 260px;
    }
    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    .search-box {
        flex-direction: column;
    }
    .filter-row {
        flex-direction: column;
        gap: 8px;
    }
    .filter-row label {
        padding-top: 0;
    }
    .filter-btns {
        gap: 6px;
    }
    .filter-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    .category-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 10px;
    }
    .category-card {
        padding: 14px 6px;
    }
    .category-card .cat-icon {
        font-size: 1.5rem;
    }
    .live-tabs {
        flex-wrap: wrap;
    }
    .config-tabs {
        flex-wrap: wrap;
    }
    .pagination-bar {
        gap: 6px;
    }
    .pagination-btn {
        min-width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }
    .pagination-info {
        width: 100%;
        text-align: center;
        margin-left: 0;
        margin-top: 4px;
    }
}
