/**
 * DONGNIME — Responsive CSS
 * Mobile-first, breakpoint-driven
 * Theme: Dark/Neon Red Cinematic
 */

/* ═══════════════════════════════════════════════════
   BREAKPOINTS (Scaffold)
   ═══════════════════════════════════════════════════ */
/*
 * xs: 0px       — mobile (default)
 * sm: 640px     — large phone
 * md: 768px     — tablet
 * lg: 1024px    — desktop
 * xl: 1280px    — large desktop
 * 2xl: 1536px   — widescreen
 */

/* ═══════════════════════════════════════════════════
   0. BASE RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    :root { --nav-height: 56px; }
    .container { padding: 0 16px; }
}

@media (min-width: 768px) {
    .container { padding: 0 24px; }
}

@media (min-width: 1024px) {
    .container { padding: 0 40px; }
}

/* ═══════════════════════════════════════════════════
   1. NAVBAR
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .navbar {
        position: fixed;
        bottom: 0;
        top: auto;
        width: 100%;
        z-index: 1000;
        background: rgba(9,9,11,0.95);
        backdrop-filter: blur(20px);
        border-top: 1px solid rgba(229,9,20,0.2);
        border-bottom: none;
        height: var(--nav-height);
        padding: 0;
    }
    .nav-container {
        flex-direction: row;
        justify-content: space-around;
        padding: 0 8px;
        gap: 0;
        height: 100%;
    }
    .nav-logo { display: none; }
    .nav-links {
        display: flex;
        width: 100%;
        justify-content: space-around;
        align-items: center;
        height: 100%;
        gap: 0;
    }
    .nav-links a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 8px 4px;
        font-size: 0.65rem;
        color: var(--text-muted);
        text-decoration: none;
        border-top: 2px solid transparent;
        transition: all var(--transition-fast);
    }
    .nav-links a:hover,
    .nav-links a.active {
        color: var(--accent);
        border-top-color: var(--accent);
        background: var(--accent-soft);
    }
    .nav-links .nav-icon { font-size: 1.2rem; }
    .nav-right { display: none; }
    .search-desktop { display: none; }
    body { padding-bottom: calc(var(--nav-height) + 8px); }
}

@media (min-width: 768px) {
    .navbar {
        position: fixed;
        top: 0;
        bottom: auto;
        width: 100%;
        z-index: 1000;
        background: rgba(10,10,10,0.85);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(196,30,30,0.2);
        height: var(--nav-height);
    }
    .nav-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 20px;
        height: 100%;
    }
    .nav-logo { display: flex; }
    .nav-links {
        display: flex;
        gap: 4px;
    }
    .nav-links a {
        padding: 8px 16px;
        color: var(--text-secondary);
        font-size: 0.9rem;
        font-weight: 500;
        border-radius: var(--radius);
        transition: all var(--transition-fast);
    }
    .nav-links a:hover,
    .nav-links a.active {
        color: var(--accent);
        background: var(--accent-soft);
    }
    .nav-right { display: flex; align-items: center; gap: 12px; }
    .search-desktop { display: block; }
    body { padding-bottom: 0; }
}

/* ═══════════════════════════════════════════════════
   2. HERO SECTION
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .hero {
        height: 420px;
        padding: 0;
    }
    .hero-overlay {
        background: linear-gradient(
            to top,
            var(--bg-primary) 0%,
            rgba(9,9,11,0.7) 40%,
            rgba(9,9,11,0.2) 100%
        );
    }
    .hero-content {
        padding: 0 16px 120px;
        max-width: 100%;
    }
    .hero-title { font-size: 1.6rem; }
    .hero-meta { font-size: 0.78rem; flex-wrap: wrap; gap: 8px; }
    .hero-desc {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-size: 0.82rem;
        max-height: 4.8em;
    }
    .hero-actions { flex-direction: column; gap: 10px; }
    .hero-actions .btn { width: 100%; justify-content: center; }
    .hero-cat-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        padding: 16px;
    }
    .hero-cat-icon { font-size: 1.2rem; }
    .hero-cat-label { font-size: 0.65rem; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .hero { height: 500px; }
    .hero-title { font-size: 2.2rem; }
    .hero-desc { font-size: 0.9rem; max-height: 7.2em; -webkit-line-clamp: 4; }
    .hero-cat-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (min-width: 1024px) {
    .hero { height: 600px; }
    .hero-content { padding-left: 80px; max-width: 55%; }
    .hero-title { font-size: 2.8rem; }
    .hero-desc { font-size: 1rem; max-height: 9.6em; -webkit-line-clamp: 6; }
}

/* ═══════════════════════════════════════════════════
   3. CONTENT GRID
   ═══════════════════════════════════════════════════ */
.donghua-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
}

@media (max-width: 479px) {
    .donghua-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (min-width: 480px) and (max-width: 639px) {
    .donghua-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
}

@media (min-width: 640px) and (max-width: 767px) {
    .donghua-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 14px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .donghua-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 16px;
    }
}

@media (min-width: 1024px) {
    .donghua-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1280px) {
    .donghua-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 22px;
    }
}

/* ═══════════════════════════════════════════════════
   4. CARD SIZES (responsive)
   ═══════════════════════════════════════════════════ */
@media (max-width: 479px) {
    .card-body { padding: 8px 10px; }
    .card-title { font-size: 0.8rem; }
    .card-meta { font-size: 0.7rem; }
    .card-ep-badge { font-size: 0.6rem; padding: 2px 6px; }
}

@media (min-width: 480px) and (max-width: 767px) {
    .card-body { padding: 10px 12px; }
    .card-title { font-size: 0.85rem; }
}

/* ═══════════════════════════════════════════════════
   5. SECTION HEADER (scrollable on mobile)
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 16px;
    }
    .section-header h2 { font-size: 1.1rem; }
    .section-header .btn { width: 100%; justify-content: center; }
    .scroll-row { gap: 10px; }
}

@media (min-width: 768px) {
    .section-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 20px 0;
    }
    .section-header h2 { font-size: 1.4rem; }
}

/* ═══════════════════════════════════════════════════
   6. CATEGORY CHIPS (horizontal scroll mobile)
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .category-chips {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding: 16px;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .category-chips::-webkit-scrollbar { display: none; }
    .category-chips .tag { white-space: nowrap; flex-shrink: 0; }
}

@media (min-width: 768px) {
    .category-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        padding: 20px 0;
    }
}

/* ═══════════════════════════════════════════════════
   7. WATCH PAGE (video player)
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .watch-container { padding: 0; }
    .player-wrapper {
        border-radius: 0;
        margin: 0;
    }
    .watch-info { padding: 16px; }
    .watch-title { font-size: 1.2rem; }
    .watch-meta-row { flex-wrap: wrap; gap: 8px; }
    .episodes-panel {
        position: relative;
        top: 0;
        max-height: 280px;
    }
    .server-list {
        flex-wrap: wrap;
        gap: 6px;
    }
    .server-btn { flex: 1; min-width: 80px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .player-wrapper { max-width: 720px; }
    .episodes-panel { max-height: 400px; }
}

@media (min-width: 1024px) {
    .player-wrapper { max-width: 900px; }
    .episodes-panel { max-height: 520px; }
}

/* ═══════════════════════════════════════════════════
   8. FOOTER
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .footer {
        padding: 40px 16px 100px;
    }
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 24px;
        text-align: center;
    }
    .footer-col h3 { font-size: 0.95rem; }
    .footer-bottom {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        font-size: 0.78rem;
    }
    .footer-social { justify-content: center; }
}

@media (min-width: 768px) {
    .footer { padding: 60px 40px 40px; }
    .footer-grid { grid-template-columns: repeat(4, 1fr); gap: 32px; }
    .footer-bottom { flex-direction: row; justify-content: space-between; }
}

/* ═══════════════════════════════════════════════════
   9. SIDEBAR LAYOUT (profile / admin)
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .sidebar-layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        gap: 4px;
        padding: 12px 16px;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .sidebar-nav::-webkit-scrollbar { display: none; }
    .sidebar-nav a {
        white-space: nowrap;
        padding: 8px 14px;
        font-size: 0.82rem;
    }
    .main-content { padding: 16px; }
}

@media (min-width: 768px) {
    .sidebar-layout { display: flex; gap: 0; }
    .sidebar {
        width: 240px;
        flex-shrink: 0;
        border-right: 1px solid var(--border);
    }
    .sidebar-nav {
        flex-direction: column;
        padding: 16px 12px;
    }
    .main-content { padding: 24px; }
}

/* ═══════════════════════════════════════════════════
   10. ADMIN TABLES (scrollable on mobile)
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .admin-table {
        min-width: 500px;
        font-size: 0.82rem;
    }
    .admin-table th, .admin-table td {
        padding: 10px 12px;
        white-space: nowrap;
    }
}

/* ═══════════════════════════════════════════════════
   11. DASHBOARD STATS (grid on mobile)
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.4rem; }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 20px; }
}

/* ═══════════════════════════════════════════════════
   12. TOAST (full width on mobile)
   ═══════════════════════════════════════════════════ */
@media (max-width: 479px) {
    .toast-container {
        bottom: calc(var(--nav-height) + 10px);
        right: 10px;
        left: 10px;
    }
    .toast {
        min-width: unset;
        max-width: none;
        width: 100%;
    }
}

/* ═══════════════════════════════════════════════════
   13. MODAL (fullscreen on mobile)
   ═══════════════════════════════════════════════════ */
@media (max-width: 767px) {
    .modal {
        max-width: none;
        max-height: 100vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin-top: auto;
    }
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
}

/* ═══════════════════════════════════════════════════
   14. ACCESSIBILITY — reduced motion
   ═══════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    html { scroll-behavior: auto; }
}

/* ═══════════════════════════════════════════════════
   15. HIGH CONTRAST
   ═══════════════════════════════════════════════════ */
@media (prefers-contrast: high) {
    :root {
        --border: rgba(255,255,255,0.2);
        --text-muted: #d4d4d4;
    }
    .btn-primary { border-width: 2px; }
}

/* ═══════════════════════════════════════════════════
   16. PRINT
   ═══════════════════════════════════════════════════ */
@media print {
    .navbar, .footer, .pwa-install-banner,
    .toast-container, .dark-mode-toggle { display: none !important; }
    body { background: #fff; color: #000; }
    .card { break-inside: avoid; border: 1px solid #ccc; }
}
