/* ===== CSS Variables (Dark Theme) ===== */
:root {
    --bg-primary: #0d0d0f;
    --bg-secondary: #16161a;
    --bg-card: #1a1a1f;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #7c3aed;
    --accent-hover: #8b5cf6;
    --border: #27272a;
    --radius: 8px;
    --header-height: 60px;
    --sidebar-width: 220px;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover {
    color: var(--accent);
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.5rem;
    height: var(--header-height);
    padding: 0 1.5rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-heart {
    width: 32px;
    height: 32px;
    color: #e11d48;
    transition: transform 0.2s;
}

.logo:hover .logo-heart {
    color: #f43f5e;
    transform: scale(1.1);
}

.main-nav ul {
    display: flex;
    gap: 1.5rem;
}

.main-nav a {
    font-size: 0.95rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

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

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-search,
.btn-menu {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
}

.btn-search:hover,
.btn-menu:hover {
    background-color: var(--bg-card);
}

/* ===== Layout (CSS Grid) ===== */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    flex: 1;
    min-height: calc(100vh - var(--header-height));
}

/* ===== Sidebar ===== */
.sidebar {
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.category-list a {
    display: block;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-radius: var(--radius);
    transition: background-color 0.2s, color 0.2s;
}

.category-list a:hover {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* ===== Main Content ===== */
.main-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.content-section {
    margin-bottom: 2rem;
}

.hero {
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.section-footer {
    margin-top: 1.5rem;
}

.btn-link {
    color: var(--accent);
    font-weight: 500;
}

.btn-link:hover {
    text-decoration: underline;
}

.loading,
.error {
    color: var(--text-muted);
    padding: 1rem 0;
}

/* ===== Video Grid (3 columns) ===== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.video-card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.video-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.video-thumbnail {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    background-color: var(--bg-secondary);
    overflow: hidden;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
}

.placeholder-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%);
}

.video-duration {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.4rem;
    background-color: rgba(0, 0, 0, 0.8);
    border-radius: 4px;
}

.video-info {
    padding: 0.75rem 1rem;
}

.video-info h3 {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.video-info h3 a:hover {
    color: var(--accent);
}

.video-info .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== Video Box (YouTube embeds) ===== */
.video-embeds {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Video import list (Title|Description|BBCode format) */
.video-import-list .video-import-item {
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.video-import-list .video-import-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.video-import-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.video-import-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1rem;
}

.video-box {
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
}

.video-embed-title {
    font-size: 1rem;
    font-weight: 600;
    padding: 1rem 1.25rem;
    margin: 0;
    border-bottom: 1px solid var(--border);
}

.video-box iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
}

.watch-page .video-box {
    max-width: 900px;
}

.watch-back {
    margin-top: 1.5rem;
}

.watch-back a {
    color: var(--text-secondary);
}

.watch-back a:hover {
    color: var(--accent);
}

/* Content cards (generate_site.php) */
.video-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.content-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.content-card-stars {
    font-size: 0.9rem;
    color: #fbbf24;
    margin-bottom: 0.5rem;
}

.content-card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.content-card-tags {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.content-card-embed {
    margin-top: 0.75rem;
}

.content-card-embed iframe {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 4px;
}

/* ===== Article Cards ===== */
.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.article-card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.article-card h2 a:hover {
    color: var(--accent);
}

.article-card .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.article-card p:last-child {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

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

/* ===== Tablet (2 columns) ===== */
@media (max-width: 1024px) {
    .video-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .layout {
        grid-template-columns: 180px 1fr;
    }

    .sidebar {
        padding: 1rem 0.75rem;
    }
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .main-nav {
        display: none;
    }

    .btn-menu {
        display: inline-flex;
    }

    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        display: none; /* Shown when .sidebar-open on mobile */
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        bottom: auto;
        z-index: 99;
        max-height: calc(100vh - var(--header-height));
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 1rem;
        background: var(--bg-secondary);
    }

    .sidebar.sidebar-open {
        display: block;
    }

    .sidebar-title {
        margin-bottom: 0.75rem;
    }

    .category-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .category-list li {
        flex: 0 0 auto;
    }

    .category-list a {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
        background-color: var(--bg-card);
        border-radius: 9999px;
    }

    .video-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .main-content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .site-header {
        padding: 0 1rem;
    }

    .main-content {
        padding: 0.75rem;
    }
}
