@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
    --primary: #6366f1;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --bg-dark: #0a0a1e;
    --bg-card: #1a1a2e;
    --bg-hover: #252538;
    --text-white: #ffffff;
    --text-gray: #a1a1aa;
    --text-muted: #71717a;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-white);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

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

/* ===== NAVBAR - MOBILE OPTIMIZED ===== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 30, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    text-decoration: none;
    z-index: 1001;
}

.logo-icon {
    font-size: 1.75rem;
}

/* Desktop Navigation */
.nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex: 1;
    justify-content: flex-end;
}

.nav-links a {
    color: var(--text-gray);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-links a:hover, .nav-links a:focus {
    color: var(--text-white);
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    align-items: center;
    gap: 1rem;
}

.search-toggle,
.menu-toggle {
    background: transparent;
    border: none;
    color: var(--text-white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.search-toggle:hover,
.menu-toggle:hover {
    color: var(--primary);
}

/* Hamburger Menu Icon */
.menu-toggle {
    width: 40px;
    height: 40px;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 0;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-white);
    transition: var(--transition);
    border-radius: 2px;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: rgba(10, 10, 30, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 99;
}

.mobile-menu.active {
    max-height: 400px;
    border-bottom: 1px solid var(--border);
}

.mobile-menu-content {
    padding: 1rem;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    color: var(--text-white);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    transition: var(--transition);
    margin-bottom: 0.5rem;
}

.mobile-menu-item:hover,
.mobile-menu-item:active {
    background: var(--bg-card);
    color: var(--primary);
}

/* Mobile Search Overlay */
.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 30, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1000;
    display: none;
    padding: 1rem;
    padding-top: 4rem;
}

.mobile-search-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.mobile-search-container {
    position: relative;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#mobileSearchBar {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1rem 1rem 3rem;
    color: var(--text-white);
    font-size: 1rem;
    outline: none;
}

#mobileSearchBar:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.mobile-search-container::before {
    content: '🔍';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
}

.close-search {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    color: var(--text-white);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-search:hover {
    background: var(--primary);
}

/* Desktop Search */
.search-container {
    position: relative;
}

#searchBar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    color: var(--text-white);
    font-size: 0.875rem;
    outline: none;
    width: 180px;
    transition: var(--transition);
}

#searchBar:focus {
    width: 260px;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#searchBar::placeholder,
#mobileSearchBar::placeholder {
    color: var(--text-muted);
}

.search-container::before {
    content: '🔍';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 350px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: none;
    box-shadow: var(--shadow);
    z-index: 1000;
}

.mobile-search-overlay .search-dropdown {
    position: static;
    width: 100%;
    max-height: calc(100vh - 180px);
    margin-top: 0;
}

.search-dropdown.active {
    display: block;
    animation: fadeInDown 0.3s ease;
}

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

.search-item {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.search-item:hover {
    background: var(--bg-hover);
}

.search-item img {
    width: 60px;
    height: 85px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.search-item-info h4 {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.search-item-info p {
    font-size: 0.75rem;
    color: var(--text-gray);
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Tablet and Below */
@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem 0;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .logo-icon {
        font-size: 1.5rem;
    }
    
    /* Hide desktop nav, show mobile controls */
    .desktop-nav {
        display: none;
    }
    
    .mobile-controls {
        display: flex;
    }
}

/* Mobile Portrait */
@media (max-width: 480px) {
    .logo {
        font-size: 1.125rem;
    }
    
    .logo-icon {
        font-size: 1.375rem;
    }
    
    .mobile-menu-item {
        font-size: 0.95rem;
        padding: 0.875rem;
    }
    
    #mobileSearchBar {
        font-size: 0.95rem;
        padding: 0.875rem 0.875rem 0.875rem 2.75rem;
    }
}

/* Desktop Only */
@media (min-width: 769px) {
    .mobile-controls,
    .mobile-menu,
    .mobile-search-overlay {
        display: none !important;
    }
}

/* ===== HERO CAROUSEL ===== */
.hero-section {
    position: relative;
    height: 500px;
    margin-bottom: 3rem;
    overflow: hidden;
    border-radius: 0 0 24px 24px;
}

.hero-carousel {
    display: flex;
    height: 100%;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-slide {
    min-width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    position: relative;
}

.hero-slide::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, rgba(10, 10, 30, 0.95) 0%, rgba(10, 10, 30, 0.7) 40%, transparent 80%);
}

.hero-slide::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg-dark) 0%, transparent 50%);
}

.hero-content {
    position: absolute;
    top: 50%;
    left: 3rem;
    transform: translateY(-50%);
    max-width: 600px;
    z-index: 2;
    animation: fadeInLeft 0.8s ease;
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translate(-30px, -50%);
    }
    to {
        opacity: 1;
        transform: translate(0, -50%);
    }
}

.hero-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.hero-content h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.1;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.7);
}

.hero-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.hero-meta span {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
}

.hero-content p {
    color: var(--text-gray);
    margin-bottom: 1.5rem;
    line-height: 1.6;
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.75rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover, .btn-primary:focus {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--border);
}

.btn-secondary:hover, .btn-secondary:focus {
    background: rgba(255, 255, 255, 0.15);
}

.carousel-controls {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 1.5rem;
    transform: translateY(-50%);
    z-index: 3;
}

.carousel-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.carousel-btn:hover, .carousel-btn:focus {
    background: var(--primary);
    transform: scale(1.1);
}

.carousel-indicators {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    z-index: 3;
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.indicator.active {
    width: 28px;
    border-radius: 4px;
    background: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.6);
}

/* ===== CONTENT SECTIONS ===== */
.content-section {
    margin: 3rem 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    position: relative;
    padding-left: 1rem;
}

.section-header h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: var(--primary);
    border-radius: 2px;
}

.view-all {
    color: var(--text-gray);
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
}

.view-all:hover, .view-all:focus {
    color: var(--primary);
}

/* ===== ANIME GRID - RESPONSIVE ===== */
.anime-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1.25rem;
}

/* Desktop Large */
@media (max-width: 1400px) {
    .anime-grid { grid-template-columns: repeat(5, 1fr); }
}

/* Desktop */
@media (max-width: 1200px) {
    .anime-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Tablet */
@media (max-width: 900px) {
    .anime-grid { 
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

/* Mobile Landscape */
@media (max-width: 640px) {
    .anime-grid { 
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }
}

/* Mobile Portrait */
@media (max-width: 480px) {
    .anime-grid { 
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

/* ===== ANIME CARD ===== */
.anime-card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
}

.anime-card:hover, .anime-card:focus {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.3);
    border-color: var(--primary);
}

.anime-card-image {
    position: relative;
    padding-top: 140%;
    overflow: hidden;
    background: var(--bg-dark);
}

.anime-card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.anime-card:hover .anime-card-image img {
    transform: scale(1.1);
}

.episode-badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 0.25rem 0.65rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.5);
}

.quality-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(0, 0, 0, 0.8);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.anime-card-info {
    padding: 0.875rem;
}

.anime-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    min-height: 2.3rem;
}

.anime-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-gray);
}

.anime-type {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 3rem 0 1.5rem;
    margin-top: 5rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.footer-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.footer-section p {
    color: var(--text-gray);
    line-height: 1.6;
    font-size: 0.875rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: var(--text-gray);
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
}

.footer-section ul li a:hover, .footer-section ul li a:focus {
    color: var(--primary);
}

.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-gray);
    font-size: 0.875rem;
}

/* ===== LOADING STATE ===== */
.loading {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-gray);
    font-size: 1rem;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 5px;
    border: 2px solid var(--bg-dark);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .container { padding: 0 0.75rem; }
    .navbar { padding: 0.75rem 0; }
    .logo { font-size: 1.25rem; }
    .logo-icon { font-size: 1.5rem; }
    
    .nav-links { gap: 1rem; }
    .nav-links a { font-size: 0.875rem; }
    
    #searchBar { width: 140px; font-size: 0.8rem; }
    #searchBar:focus { width: 180px; }
    .search-dropdown { width: 280px; }
    
    .hero-section { height: 400px; }
    .hero-content { 
        left: 1.5rem; 
        right: 1.5rem;
        max-width: calc(100% - 3rem); 
    }
    .hero-content h1 { font-size: 2rem; }
    .hero-content p { font-size: 0.875rem; }
    
    .section-header h2 { font-size: 1.25rem; }
    .content-section { margin: 2rem 0; }
}

@media (max-width: 480px) {
    .logo { font-size: 1.125rem; }
    .nav-links a:not(:first-child):not(:nth-child(2)) { display: none; }
    
    #searchBar { width: 110px; padding: 0.5rem 0.75rem 0.5rem 2rem; }
    
    .hero-section { height: 350px; border-radius: 0 0 16px 16px; }
    .hero-content { left: 1rem; right: 1rem; max-width: calc(100% - 2rem); }
    .hero-badge { font-size: 0.65rem; padding: 0.3rem 0.75rem; }
    .hero-content h1 { font-size: 1.5rem; }
    .hero-meta span { font-size: 0.75rem; padding: 0.3rem 0.6rem; }
    .hero-content p { font-size: 0.8rem; }
    .btn { font-size: 0.875rem; padding: 0.625rem 1.25rem; }
    
    .carousel-btn { width: 38px; height: 38px; font-size: 1.25rem; }
    .carousel-controls { padding: 0 0.75rem; }
    
    .section-header h2 { font-size: 1.125rem; }
    .anime-card-title { font-size: 0.8rem; }
}

/* ===== ACCESSIBILITY ===== */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
