@layer base, layout, components, utilities;

@layer base {
    :root {
        --bg-color: #ffffff;
        --text-color: #1a1a1b;
        --header-bg: rgba(255, 255, 255, 0.9);
        --sidebar-bg: #f8f9fa;
        --border-color: #eaecf0;
        --primary-color: #ff4757;
        --primary-hover: #ff6b81;
        --accent-color: #fff0f3;
        --card-bg: #ffffff;
        --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
        --header-height: 70px;
        --sidebar-width: 260px;
    }

    body.dark-mode {
        --bg-color: #0f0f0f;
        --text-color: #f1f1f1;
        --header-bg: rgba(15, 15, 15, 0.9);
        --sidebar-bg: #1a1a1a;
        --border-color: #2f2f2f;
        --primary-color: #ff4757;
        --accent-color: #2d1b1e;
        --card-bg: #1e1e1e;
        --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    }

    body {
        font-family: 'Inter', system-ui, sans-serif;
        background-color: var(--bg-color);
        color: var(--text-color);
        line-height: 1.6;
        transition: 0.3s;
    }
}

@layer layout {
    .site-header {
        position: sticky; top: 0; height: var(--header-height);
        background-color: var(--header-bg); backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border-color); z-index: 1000;
        padding: 0 2rem;
    }
    .header-content {
        display: flex; align-items: center; max-width: 1400px; margin: 0 auto; height: 100%; gap: 2rem;
    }
    .top-nav { display: flex; gap: 1.5rem; }
    .nav-link { 
        font-weight: 600; color: var(--text-color); opacity: 0.7; font-size: 0.95rem; 
        padding: 0.5rem 0; position: relative;
    }
    .nav-link.active { opacity: 1; color: var(--primary-color); }
    .nav-link.active::after {
        content: ''; position: absolute; bottom: 0; left: 0; width: 100%; height: 2px; background: var(--primary-color);
    }

    .page-container { display: flex; max-width: 1400px; margin: 0 auto; }
    .sidebar {
        width: var(--sidebar-width); border-right: 1px solid var(--border-color);
        background: var(--sidebar-bg); padding: 2rem 1.5rem; height: calc(100vh - var(--header-height));
        position: sticky; top: var(--header-height);
    }
    .content-area { flex-grow: 1; padding: 2.5rem; min-height: 100vh; }
}

@layer components {
    /* Hero */
    .hero-banner {
        background: linear-gradient(135deg, #ff4757, #e84393);
        border-radius: 20px; padding: 5rem 3rem; color: white; margin-bottom: 3rem;
        box-shadow: 0 10px 30px rgba(255, 71, 87, 0.2);
    }
    .hero-text h1 { font-size: 3rem; margin-bottom: 1.5rem; }
    .hero-actions { display: flex; gap: 1rem; margin-top: 2rem; }
    .btn-primary { 
        background: white; color: #ff4757; padding: 0.8rem 2rem; border-radius: 30px; 
        font-weight: 700; transition: 0.3s;
    }
    .btn-secondary { 
        background: rgba(255,255,255,0.2); color: white; padding: 0.8rem 2rem; 
        border-radius: 30px; border: 1px solid rgba(255,255,255,0.3);
    }

    /* Video Theater */
    .video-theater {
        display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; background: #000;
        padding: 1rem; border-radius: 16px; margin-top: 2rem;
    }
    .video-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; }
    .video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 8px; }
    .video-sidebar { background: #111; border-radius: 8px; padding: 1rem; color: #eee; }
    .playlist { list-style: none; margin-top: 1rem; }
    .playlist li { 
        padding: 0.75rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; transition: 0.2s;
        border-bottom: 1px solid #222;
    }
    .playlist li:hover { background: #222; }
    .playlist li.active { background: var(--primary-color); color: white; }

    /* Character Cards */
    .character-grid {
        display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 2rem;
    }
    .character-card {
        background: var(--card-bg); border-radius: 16px; overflow: hidden;
        border: 1px solid var(--border-color); cursor: pointer; transition: 0.3s;
    }
    .character-card:hover { transform: translateY(-10px); box-shadow: var(--shadow-md); }
    .card-img-wrap { height: 260px; background: #eee; }
    .card-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
    .card-info { padding: 1.5rem; }

    /* Detail View */
    .btn-back { 
        background: var(--accent-color); color: var(--primary-color); border: none;
        padding: 0.6rem 1.2rem; border-radius: 8px; cursor: pointer; margin-bottom: 2rem;
        font-weight: 600;
    }
    .char-detail-layout { display: grid; grid-template-columns: 400px 1fr; gap: 3rem; }
    .detail-image img { width: 100%; border-radius: 20px; box-shadow: var(--shadow-md); }
    .detail-info h2 { font-size: 3rem; margin-bottom: 1rem; }
    .info-tabs { display: flex; gap: 2rem; border-bottom: 1px solid var(--border-color); margin: 2rem 0; }
    .tab-btn { background: none; border: none; padding: 1rem 0; color: var(--text-color); opacity: 0.6; cursor: pointer; font-weight: 600; }
    .tab-btn.active { opacity: 1; border-bottom: 2px solid var(--primary-color); }

    /* Modal Styles */
    .modal-backdrop {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.6); backdrop-filter: blur(5px);
        display: flex; align-items: center; justify-content: center;
        z-index: 2000; opacity: 0; pointer-events: none; transition: 0.3s;
    }
    .modal-backdrop.active { opacity: 1; pointer-events: all; }
    
    .modal-window {
        background: var(--bg-color); width: 90%; max-width: 900px; max-height: 85vh;
        border-radius: 24px; overflow: hidden; position: relative;
        transform: translateY(20px); transition: 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
        display: flex; flex-direction: column;
        box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    }
    .modal-backdrop.active .modal-window { transform: translateY(0); }

    .modal-close {
        position: absolute; top: 1.5rem; right: 1.5rem; background: rgba(0,0,0,0.1);
        border: none; width: 36px; height: 36px; border-radius: 50%;
        cursor: pointer; display: flex; align-items: center; justify-content: center;
        z-index: 10; color: var(--text-color); transition: 0.2s;
    }
    .modal-close:hover { background: var(--primary-color); color: white; }

    .modal-content { overflow-y: auto; padding: 2rem; }
    
    .char-modal-layout { display: grid; grid-template-columns: 320px 1fr; gap: 2.5rem; }
    .char-modal-image img { width: 100%; border-radius: 16px; object-fit: cover; aspect-ratio: 1; }
    
    @media (max-width: 768px) {
        .char-modal-layout { grid-template-columns: 1fr; }
        .char-modal-image { max-width: 200px; margin: 0 auto; }
        .modal-window { width: 100%; height: 100%; max-height: 100vh; border-radius: 0; }
    }

    /* AdSense Placeholders */
    .ad-placeholder {
        background: var(--border-color); border: 2px dashed #ccc;
        border-radius: 12px; margin: 1rem 0 2.5rem; display: flex;
        align-items: center; justify-content: center;
        color: #999; font-weight: 600; min-height: 200px;
        transition: 0.3s; position: relative;
    }
    .ad-placeholder::after { content: 'AD SPACE'; position: absolute; font-size: 0.8rem; opacity: 0.5; }

    /* News & Info Cards */
    .news-item {
        background: var(--card-bg); border: 1px solid var(--border-color);
        padding: 2rem; border-radius: 16px; margin-bottom: 1.5rem;
        transition: 0.3s;
    }
    .news-item:hover { border-color: var(--primary-color); transform: translateX(5px); }
    .news-date { color: var(--primary-color); font-weight: 700; font-size: 0.85rem; }
    .news-item h3 { margin: 0.5rem 0 1rem; }
    .news-item p { opacity: 0.8; }

    .content-text-card {
        background: var(--card-bg); padding: 3rem; border-radius: 20px;
        border: 1px solid var(--border-color); line-height: 1.8;
    }
    .content-text-card h3 { margin: 2rem 0 1rem; }
    .content-text-card p { margin-bottom: 1rem; }

    /* Footer Links */
    .footer-links { margin-bottom: 1rem; display: flex; justify-content: center; gap: 2rem; }
    .footer-links a { color: var(--text-color); opacity: 0.6; text-decoration: none; font-size: 0.9rem; font-weight: 600; }
    .footer-links a:hover { opacity: 1; color: var(--primary-color); }
}

@media (max-width: 1024px) {
    .video-theater { grid-template-columns: 1fr; }
    .char-detail-layout { grid-template-columns: 1fr; }
}
