/* ====================================
   WordPress IPTV Sync - 前端样式（优化版本）
   现代化设计 + 性能优化
   ==================================== */

/* ============ 性能优化：CSS变量 ============ */
:root {
    --iptv-primary: #667eea;
    --iptv-secondary: #764ba2;
    --iptv-gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --iptv-gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --iptv-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --iptv-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --iptv-radius: 12px;
    --iptv-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ 通用容器优化 ============ */
.iptv-grid {
    display: grid;
    gap: 16px;
    margin: 30px 0;
    will-change: contents;
}

.iptv-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.iptv-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.iptv-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* 响应式优化 */
@media (max-width: 1200px) {
    .iptv-grid {
        gap: 12px;
    }

    .iptv-grid-2,
    .iptv-grid-3,
    .iptv-grid-4 {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .iptv-grid {
        gap: 10px;
        margin: 20px 0;
    }

    .iptv-grid-2,
    .iptv-grid-3,
    .iptv-grid-4 {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

/* ============ 分类卡片（现代化）============ */
.iptv-category-card {
    position: relative;
    background: #fff;
    border-radius: var(--iptv-radius);
    padding: 20px;
    box-shadow: var(--iptv-shadow-sm);
    transition: var(--iptv-transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.iptv-category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--iptv-gradient-1);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.iptv-category-card:hover::before {
    transform: scaleX(1);
}

.iptv-category-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: var(--iptv-shadow-lg);
}

.iptv-category-name {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
    letter-spacing: -0.5px;
}

.iptv-category-id {
    margin: 0;
    font-size: 13px;
    color: #a0aec0;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============ 直播频道卡片（精美）============ */
.iptv-stream-card {
    position: relative;
    background: #fff;
    border-radius: var(--iptv-radius);
    overflow: hidden;
    box-shadow: var(--iptv-shadow-sm);
    transition: var(--iptv-transition);
}

.iptv-stream-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--iptv-shadow-lg);
}

.iptv-stream-icon {
    width: 100%;
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #e0e7ff 0%, #cffafe 100%);
    overflow: hidden;
    position: relative;
}

.iptv-stream-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.iptv-stream-card:hover .iptv-stream-icon::after {
    opacity: 1;
}

.iptv-stream-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.iptv-stream-card:hover .iptv-stream-icon img {
    transform: scale(1.1);
}

.iptv-stream-name {
    margin: 18px 16px;
    font-size: 16px;
    font-weight: 600;
    color: #1a202c;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.iptv-stream-meta {
    margin: 0 16px 18px;
    font-size: 13px;
    color: #718096;
}

/* ============ 加载动画（流畅）============ */
.iptv-loading {
    text-align: center;
    padding: 40px 20px;
}

.iptv-loading::after {
    content: '';
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid var(--iptv-primary);
    border-radius: 50%;
    animation: iptv-spin 0.8s linear infinite;
}

@keyframes iptv-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============ 加载更多按钮（吸睛）============ */
.iptv-load-more {
    text-align: center;
    margin: 40px 0;
}

.iptv-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 32px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: none;
    transition: var(--iptv-transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.iptv-load-more-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.iptv-load-more-btn:active {
    transform: translateY(-1px) scale(1.02);
}

.iptv-load-more-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============ 动画效果 ============ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.iptv-grid>* {
    animation: fadeIn 0.5s ease backwards;
}

.iptv-grid>*:nth-child(1) {
    animation-delay: 0.05s;
}

.iptv-grid>*:nth-child(2) {
    animation-delay: 0.1s;
}

.iptv-grid>*:nth-child(3) {
    animation-delay: 0.15s;
}

.iptv-grid>*:nth-child(4) {
    animation-delay: 0.2s;
}

.iptv-grid>*:nth-child(5) {
    animation-delay: 0.25s;
}

.iptv-grid>*:nth-child(6) {
    animation-delay: 0.3s;
}

.iptv-grid>*:nth-child(7) {
    animation-delay: 0.35s;
}

.iptv-grid>*:nth-child(8) {
    animation-delay: 0.4s;
}

/* ============ 性能优化：懒加载图片 ============ */
.iptv-vod-poster img[loading="lazy"],
.iptv-series-cover img[loading="lazy"],
.iptv-stream-icon img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ============ 打印样式优化 ============ */
@media print {

    .iptv-load-more,
    .iptv-loading {
        display: none !important;
    }

    .iptv-grid {
        display: block !important;
    }

    .iptv-grid>* {
        break-inside: avoid;
        margin-bottom: 20px;
    }
}

/* ============ 高对比度模式支持 ============ */
@media (prefers-contrast: high) {

    .iptv-category-card,
    .iptv-stream-card,
    .iptv-vod-card,
    .iptv-series-card {
        border: 2px solid currentColor;
    }
}

/* ============ 减少动画（用户偏好）============ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============ VOD Detail Page Styles ============ */
.iptv-dark-theme-wrapper {
    background-color: #1a202c;
    color: #e2e8f0;
    min-height: 100vh;
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 0;
    box-sizing: border-box;
}

.iptv-hero-section {
    position: relative;
    height: 70vh;
    min-height: 500px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.iptv-hero-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.4);
    z-index: 0;
}

.iptv-hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(26, 32, 44, 0.3) 0%, rgba(26, 32, 44, 1) 100%);
    z-index: 1;
}

.iptv-hero-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.iptv-hero-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 40px;
    align-items: center;
}

.iptv-hero-poster {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    aspect-ratio: 2/3;
}

.iptv-hero-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.iptv-hero-info {
    color: #fff;
}

.iptv-breadcrumbs {
    font-size: 14px;
    color: #a0aec0;
    margin-bottom: 16px;
}

.iptv-breadcrumbs a {
    color: #cbd5e0;
    text-decoration: none;
    transition: color 0.2s;
}

.iptv-breadcrumbs a:hover {
    color: #fff;
}

.iptv-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #cbd5e0;
}

.iptv-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.iptv-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin: 0 0 20px 0;
    background: linear-gradient(to right, #fff, #a0aec0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.iptv-quality {
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.iptv-actions {
    margin-bottom: 30px;
}

.iptv-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 40px;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-decoration: none;
}

.iptv-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4);
}

.iptv-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(118, 75, 162, 0.5);
}

.iptv-plot {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #cbd5e0;
    max-width: 800px;
}

/* Player Modal */
.iptv-player-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.iptv-player-modal.active {
    opacity: 1;
    visibility: visible;
}

.iptv-player-container {
    position: relative;
    width: 90%;
    max-width: 1200px;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.iptv-close-btn {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 40px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.iptv-close-btn:hover {
    opacity: 1;
}

#iptv-video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.iptv-related-section {
    padding: 60px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 30px;
    color: #2d3748;
    border-left: 4px solid #667eea;
    padding-left: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .iptv-hero-section {
        height: auto;
        padding: 100px 0 60px;
    }

    .iptv-hero-grid {
        grid-template-columns: 1fr;
        gap: 30px;
        text-align: center;
    }

    .iptv-hero-poster {
        max-width: 300px;
        margin: 0 auto;
    }

    .iptv-meta-row {
        justify-content: center;
    }

    .iptv-title {
        font-size: 2.5rem;
    }

    .iptv-plot {
        margin: 0 auto;
    }
}

/* ============ VOD Detail Page Styles ============ */

/* ============ VOD Card (Modern Style) ============ */
.iptv-vod-card.style-modern {
    position: relative;
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease;
    aspect-ratio: 3/4;
}

.iptv-vod-card.style-modern:hover {
    transform: translateY(-5px);
    z-index: 10;
}

.iptv-vod-card.style-modern .iptv-vod-poster {
    position: relative;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.iptv-vod-card.style-modern .iptv-vod-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
    transition: transform 0.5s ease;
}

.iptv-vod-card.style-modern:hover .iptv-vod-poster img {
    transform: scale(1.1);
}

.iptv-vod-card.style-modern .iptv-vod-quality {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.iptv-vod-card.style-modern .iptv-vod-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 12px 12px 16px;
    background: #2d3748;
    border-radius: 0 0 12px 12px;
    z-index: 5;
}

.iptv-vod-card.style-modern .iptv-vod-name {
    margin: 5px 0 0 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 55px;
}

.iptv-vod-card.style-modern .iptv-vod-rating-circle {
    position: absolute;
    top: -23px;
    left: 10px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 5;
    /* Background is set inline */
}

.iptv-vod-card.style-modern .rating-inner {
    width: 38px;
    height: 38px;
    background: #1a1a1a;
    /* Dark background matching theme */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iptv-vod-card.style-modern .rating-text {
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}

.iptv-vod-card.style-modern .rating-text small {
    font-size: 10px;
    opacity: 0.7;
}

/* ============ Series Card (Modern Style) ============ */
.iptv-series-card.style-modern {
    position: relative;
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s ease;
    aspect-ratio: 3/4;
}

.iptv-series-card.style-modern:hover {
    transform: translateY(-5px);
    z-index: 10;
}

.iptv-series-card.style-modern .iptv-series-cover {
    position: relative;
    height: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.iptv-series-card.style-modern .iptv-series-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 20%;
    transition: transform 0.5s ease;
}

.iptv-series-card.style-modern:hover .iptv-series-cover img {
    transform: scale(1.1);
}

.iptv-series-card.style-modern .iptv-series-quality {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.iptv-series-card.style-modern .iptv-series-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 12px 12px 16px;
    background: #2d3748;
    border-radius: 0 0 12px 12px;
    z-index: 5;
}

.iptv-series-card.style-modern .iptv-series-name {
    margin: 5px 0 0 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: normal;
    padding-left: 55px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.iptv-series-card.style-modern .iptv-series-rating-circle {
    position: absolute;
    top: -23px;
    left: 10px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 5;
}

.iptv-series-card.style-modern .rating-inner {
    width: 38px;
    height: 38px;
    background: #1a1a1a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iptv-series-card.style-modern .rating-text {
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}

.iptv-series-card.style-modern .rating-text small {
    font-size: 10px;
    opacity: 0.7;
}

/* ============ Category Pills Module ============ */
.iptv-category-pills-wrapper {
    margin-top: 20px;
    padding: 15px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.iptv-category-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-start;
}

.iptv-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Center content when stretched */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 2px 8px 2px 2px;
    text-decoration: none !important;
    color: #cbd5e0;
    font-size: 11px;
    transition: all 0.2s ease;
    line-height: 1.2;
    flex-grow: 1;
    /* Automatically fill gaps */
    text-align: center;
}

.iptv-pill:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
    transform: translateY(-1px);
    text-decoration: none !important;
}

.iptv-pill.active {
    background: rgba(4, 107, 210, 0.1);
    border-color: #046bd2;
    color: #046bd2;
}

.iptv-pill .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #4a5568;
    color: #fff;
    border-radius: 50px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: bold;
    margin-right: 6px;
    min-width: 20px;
    height: 18px;
}

.iptv-pill .count.blue,
.iptv-pill.active .count {
    background: #046bd2;
}

.iptv-pill .label {
    font-weight: 500;
}
/* ============ Category Pills Lazy Load ============ */
.iptv-pill-hidden {
    display: none !important;
}

.iptv-category-pills-wrapper.expanded .iptv-pill-hidden {
    display: inline-flex !important;
}

.iptv-pills-toggle-wrapper {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.iptv-pills-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #a0aec0;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.iptv-pills-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.iptv-pills-toggle-btn .toggle-icon {
    transition: transform 0.3s ease;
}

.iptv-pills-toggle-btn[data-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}
