/* =============================================
   VN Tube — Dailymotion Video Browser
   Premium dark-first UI with glassmorphism
   ============================================= */

/* CSS Custom Properties */
:root {
    --search-bg: #111827;
    --search-border: #1F2937;
    --search-icon-color: #D1D5DB;
    --font: 'Be Vietnam Pro', -apple-system, system-ui, sans-serif;
    
    /* Dark theme (default) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a28;
    --bg-card: #16161f;
    --bg-card-hover: #1e1e2e;
    --bg-glass: rgba(22, 22, 31, 0.85);
    --bg-overlay: rgba(0, 0, 0, 0.7);
    
    --text-primary: #f0f0f5;
    --text-secondary: #9898a8;
    --text-muted: #5e5e72;
    
    --border-color: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    
    --accent: #e23c52;
    --accent-hover: #ff4d6a;
    --accent-glow: rgba(226, 60, 82, 0.3);
    
    --gradient-hero: linear-gradient(135deg, rgba(226, 60, 82, 0.15), rgba(99, 102, 241, 0.1));
    --gradient-card: linear-gradient(145deg, var(--bg-card), var(--bg-tertiary));
    
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);
}

[data-theme="light"] {
    --search-bg: #F8FAFC;
    --search-border: #E2E8F0;
    --search-icon-color: #6B7280;
    --bg-primary: #f5f5fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eeeef4;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f0f8;
    --bg-glass: rgba(255, 255, 255, 0.9);
    --bg-overlay: rgba(0, 0, 0, 0.5);
    
    --text-primary: #1a1a2e;
    --text-secondary: #555570;
    --text-muted: #8888a0;
    
    --border-color: rgba(0, 0, 0, 0.06);
    --border-light: rgba(0, 0, 0, 0.08);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; border: none; background: none; font-family: var(--font); color: var(--text-primary); }
input { font-family: var(--font); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

.material-symbols-rounded {
    font-size: 20px;
    vertical-align: middle;
    line-height: 1;
}

/* ========== LAYOUT ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    min-height: 65px;
}

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

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: white;
    border-radius: 10px;
    font-size: 18px;
    box-shadow: var(--shadow-glow);
}

.logo-text {
    background: linear-gradient(135deg, var(--accent), #ff6b8a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-close {
    display: none;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.sidebar-close:hover {
    background: var(--bg-tertiary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav-section {
    padding: 4px 12px;
    margin-bottom: 4px;
}

.nav-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 12px 6px;
}

.nav-section-title .material-symbols-rounded {
    font-size: 16px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(226, 60, 82, 0.1);
    color: var(--accent);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-item .material-symbols-rounded { font-size: 20px; }

.cat-icon {
    font-size: 18px;
    width: 20px;
    text-align: center;
    line-height: 1;
}

.fav-count {
    margin-left: auto;
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.fav-count:empty { display: none; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== TOPBAR ========== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    height: var(--topbar-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.menu-toggle {
    display: flex;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.menu-toggle:hover {
    background: var(--bg-tertiary);
}


.search-bar {
    flex: 1;
    max-width: 640px;
    display: flex;
    align-items: center;
    position: relative;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    height: 44px;
    background: var(--search-bg, var(--bg-tertiary));
    border: 1px solid var(--search-border, var(--border-color));
    border-radius: 12px;
    transition: all 0.2s ease;
}

.search-input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(226, 60, 82, 0.2);
}


/* Keep search icon visible always, so it acts as submit button */

.search-bar input {
    width: 100%;
    height: 100%;
    padding: 0 88px 0 16px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}




/* JS handles clear button visibility now */

.search-loader {
    position: absolute;
    right: 80px;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: search-spin 0.8s linear infinite;
    display: none;
}
@keyframes search-spin {
    to { transform: rotate(360deg); }
}
.search-bar.loading .search-loader {
    display: block;
}

.topbar-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.topbar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ========== PAGE CONTENT ========== */
.page-content {
    flex: 1;
    padding: 0;
}

/* ========== HERO SECTION ========== */
.hero {
    position: relative;
    height: 420px;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(2px);
    transform: scale(1.05);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--bg-primary) 0%, rgba(10, 10, 15, 0.7) 50%, rgba(10, 10, 15, 0.3) 100%);
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 40px 32px;
    max-width: 700px;
    animation: fadeSlideUp 0.8s ease;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: rgba(226, 60, 82, 0.2);
    border: 1px solid rgba(226, 60, 82, 0.3);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-hover);
    margin-bottom: 12px;
    backdrop-filter: blur(10px);
}

.hero-badge .material-symbols-rounded { font-size: 16px; }

.hero-title {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 10px;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.hero-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.hero-meta .material-symbols-rounded { font-size: 16px; }

.hero-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hero-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--accent);
    color: white;
    border-radius: 28px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-glow);
}

.hero-play-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 0 40px var(--accent-glow);
}

.hero-play-btn .material-symbols-rounded { font-size: 24px; }

/* ========== QUICK CATEGORIES ========== */
.quick-categories {
    display: flex;
    gap: 10px;
    padding: 24px 32px;
    overflow-x: auto;
    scrollbar-width: none;
}

.quick-categories::-webkit-scrollbar { display: none; }

.quick-cat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-width: 90px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.quick-cat:hover {
    background: var(--bg-card-hover);
    border-color: var(--cat-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.quick-cat-icon { font-size: 24px; }
.quick-cat-name { font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }

/* ========== VIDEO SECTIONS ========== */
.video-section {
    padding: 12px 32px 28px;
}

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

.section-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.15rem;
    font-weight: 700;
}

.section-icon { font-size: 22px; }
.section-icon.fire { color: #ef4444; }
.section-icon.sparkle { color: #8b5cf6; }
.section-icon-emoji { font-size: 22px; }

.see-all {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent);
    transition: all 0.2s;
}

.see-all:hover {
    color: var(--accent-hover);
    gap: 8px;
}

.see-all .material-symbols-rounded { font-size: 18px; }

/* ========== VIDEO GRID ========== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

/* ========== VIDEO CARD ========== */
.video-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeIn 0.5s ease;
}

.video-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-light);
}

.video-card-link { display: block; }

.video-thumb {
    position: relative;
    padding-top: 56.25%;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.video-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.video-card:hover .video-thumb img {
    transform: scale(1.08);
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    backdrop-filter: blur(4px);
}

.video-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-card:hover .video-play-overlay { opacity: 1; }

.video-play-overlay .material-symbols-rounded {
    font-size: 48px;
    color: white;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.video-card:hover .video-play-overlay .material-symbols-rounded {
    transform: scale(1);
}

.video-info {
    padding: 12px 14px 14px;
}

.video-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}

.video-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.video-owner {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.video-stats {
    display: flex;
    gap: 12px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.video-stats span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.video-stats .material-symbols-rounded { font-size: 14px; }

/* Favorite button on card */
.video-fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border-radius: 50%;
    color: white;
    opacity: 0;
    transition: all 0.3s;
    z-index: 5;
}

.video-card:hover .video-fav-btn { opacity: 1; }

.video-fav-btn:hover {
    background: var(--accent);
    transform: scale(1.15);
}

.video-fav-btn .material-symbols-rounded { font-size: 18px; }
.video-fav-btn.is-fav .material-symbols-rounded { color: var(--accent); }

/* ========== VIDEO PAGE ========== */
.video-page {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    padding: 24px 32px;
}

.player-container {
    position: relative;
    padding-top: 56.25%;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.player-container iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.player-fullscreen-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease, background 0.2s ease, transform 0.2s ease;
    backdrop-filter: blur(6px);
}

.player-fullscreen-btn .material-symbols-rounded {
    font-size: 24px;
}

.player-container:hover .player-fullscreen-btn {
    opacity: 1;
}

.player-fullscreen-btn:hover {
    background: rgba(226, 60, 82, 0.9);
    transform: scale(1.1);
}

/* Fullscreen: container approach */
.player-container:fullscreen,
.player-container:-webkit-full-screen,
.player-container:-moz-full-screen,
.player-container:-ms-fullscreen {
    padding-top: 0;
    border-radius: 0;
    width: 100vw;
    height: 100vh;
}

.player-container:fullscreen iframe,
.player-container:-webkit-full-screen iframe,
.player-container:-moz-full-screen iframe,
.player-container:-ms-fullscreen iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.player-container:fullscreen .player-fullscreen-btn,
.player-container:-webkit-full-screen .player-fullscreen-btn,
.player-container:-moz-full-screen .player-fullscreen-btn,
.player-container:-ms-fullscreen .player-fullscreen-btn {
    opacity: 0;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
}

.player-container:fullscreen:hover .player-fullscreen-btn,
.player-container:-webkit-full-screen:hover .player-fullscreen-btn,
.player-container:-moz-full-screen:hover .player-fullscreen-btn,
.player-container:-ms-fullscreen:hover .player-fullscreen-btn {
    opacity: 1;
}

/* Fullscreen: iframe direct approach (priority) */
#videoPlayer:fullscreen,
#videoPlayer:-webkit-full-screen,
#videoPlayer:-moz-full-screen,
#videoPlayer:-ms-fullscreen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    border: none;
    border-radius: 0;
}

.video-detail {
    padding: 20px 0;
}

.video-detail-title {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 14px;
}

.video-detail-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.video-detail-stats {
    display: flex;
    gap: 18px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.video-detail-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.video-detail-stats .material-symbols-rounded { font-size: 18px; }

.video-detail-actions {
    display: flex;
    gap: 6px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.action-btn .material-symbols-rounded { font-size: 18px; }

/* Owner Info */
.video-owner-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.owner-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.owner-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.owner-avatar-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.owner-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
}

.owner-channel {
    font-size: 0.75rem;
    color: var(--accent);
}

.owner-channel:hover { text-decoration: underline; }

/* Description */
.video-description {
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.description-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.7;
    max-height: 80px;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.description-content.expanded { max-height: 2000px; }

.desc-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    transition: color 0.2s;
}

.desc-toggle:hover { color: var(--accent-hover); }
.desc-toggle .material-symbols-rounded { font-size: 18px; transition: transform 0.3s; }
.description-content.expanded ~ .desc-toggle .material-symbols-rounded { transform: rotate(180deg); }

/* Video Sidebar (Related) */
.video-sidebar {
    position: sticky;
    top: calc(var(--topbar-height) + 24px);
    max-height: calc(100vh - var(--topbar-height) - 48px);
    overflow-y: auto;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.sidebar-title .material-symbols-rounded { font-size: 22px; color: var(--accent); }

.related-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.related-card {
    display: flex;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.related-card:hover {
    background: var(--bg-card-hover);
}

.related-thumb {
    position: relative;
    width: 160px;
    min-width: 160px;
    aspect-ratio: 16/9;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.related-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-info {
    flex: 1;
    min-width: 0;
}

.related-info h4 {
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.related-owner {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.related-views {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.related-views .material-symbols-rounded { font-size: 13px; }

/* ========== SEARCH PAGE ========== */
.search-page { padding: 24px 32px; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    font-size: 64px !important;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.search-suggestions-grid {
    margin-top: 40px;
    text-align: center;
}

.search-suggestions-grid h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.suggestion-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 500px;
    margin: 0 auto;
}

.suggestion-tag {
    padding: 8px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.25s;
}

.suggestion-tag:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
}

.results-header {
    margin-bottom: 24px;
}

.results-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 14px;
}

.highlight { color: var(--accent); }

.sort-options {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.sort-btn {
    padding: 7px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.sort-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.sort-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ========== LISTING / CATEGORY PAGE ========== */
.listing-page, .category-page { padding: 24px 32px; }

.listing-header, .category-header {
    margin-bottom: 28px;
}

.listing-header h1, .category-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.listing-header p, .category-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--cat-color);
}

.category-icon { font-size: 40px; }

/* ========== USER CHANNEL PAGE ========== */
.user-page { padding: 24px 32px; }

.user-profile-header {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 28px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.user-cover {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.user-cover-default {
    background: linear-gradient(135deg, var(--accent) 0%, #6366f1 50%, #8b5cf6 100%);
}

.user-cover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.5));
}

.user-profile-info {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 0 24px 24px;
    margin-top: -50px;
    position: relative;
    z-index: 1;
}

.user-profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--bg-card);
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.user-profile-avatar-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--bg-card);
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.user-profile-avatar-placeholder .material-symbols-rounded {
    font-size: 48px;
    color: var(--text-secondary);
}

.user-profile-details {
    flex: 1;
    padding-top: 56px;
}

.user-profile-name {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.user-profile-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
    max-width: 600px;
}

.user-profile-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.user-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.user-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.user-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-dm-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    margin-top: 56px;
    flex-shrink: 0;
}

.user-dm-link:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

/* Owner link styles */
.video-owner-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    position: relative;
    z-index: 2;
}

.video-owner-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.owner-name-link {
    text-decoration: none;
    color: var(--text-primary);
    transition: color 0.2s;
}

.owner-name-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.related-owner-link {
    text-decoration: none;
    transition: color 0.2s;
    position: relative;
    z-index: 2;
}

.related-owner-link:hover {
    color: var(--accent) !important;
    text-decoration: underline;
}

/* ========== PAGINATION ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 32px 0;
}

.page-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.page-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.page-btn .material-symbols-rounded { font-size: 18px; }

.page-info {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ========== MODAL ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-header h2 .material-symbols-rounded { color: var(--accent); }

.modal-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-outline {
    padding: 6px 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.modal-close {
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.modal-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.history-item, .fav-item {
    display: flex;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.history-item:hover, .fav-item:hover { background: var(--bg-tertiary); }

.history-item img, .fav-item img {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.history-item .item-info, .fav-item .item-info { flex: 1; min-width: 0; }

.history-item .item-title, .fav-item .item-title {
    font-size: 0.85rem;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.history-item .item-duration, .fav-item .item-duration {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.item-remove {
    align-self: center;
    padding: 6px;
    border-radius: 50%;
    color: var(--text-muted);
    transition: all 0.2s;
}

.item-remove:hover {
    background: rgba(226, 60, 82, 0.1);
    color: var(--accent);
}

/* ========== BACK TO TOP ========== */
.back-to-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 44px;
    height: 44px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 80;
    pointer-events: none;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.back-to-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 0 40px var(--accent-glow);
}

/* ========== FOOTER ========== */
.footer {
    padding: 32px;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.footer-inner {
    text-align: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.footer-brand .logo-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.footer-links {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.footer-links a {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}

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

/* ========== LANGUAGE SWITCHER ========== */
.lang-switch-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-bottom: 4px;
}

.lang-switch-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.lang-flag { font-size: 18px; line-height: 1; }

.lang-btn {
    font-size: 18px;
    line-height: 1;
}

.lang-btn .lang-flag { font-size: 20px; }

/* ========== SIDEBAR COLLAPSED (DESKTOP) ========== */
.sidebar-collapsed .sidebar {
    width: 0;
    overflow: hidden;
    border-right: none;
}

.sidebar-collapsed .main-content {
    margin-left: 0;
}

.sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content {
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== SIDEBAR OVERLAY (MOBILE) ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(4px);
}

.sidebar-overlay.active { display: block; }

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Staggered card animation */
.video-card:nth-child(1) { animation-delay: 0.02s; }
.video-card:nth-child(2) { animation-delay: 0.06s; }
.video-card:nth-child(3) { animation-delay: 0.1s; }
.video-card:nth-child(4) { animation-delay: 0.14s; }
.video-card:nth-child(5) { animation-delay: 0.18s; }
.video-card:nth-child(6) { animation-delay: 0.22s; }
.video-card:nth-child(7) { animation-delay: 0.26s; }
.video-card:nth-child(8) { animation-delay: 0.3s; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .video-page { grid-template-columns: 1fr; }
    .video-sidebar { 
        position: static; 
        max-height: none; 
    }
    .related-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    .related-card { flex-direction: column; }
    .related-thumb { width: 100%; min-width: auto; }
}

@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-width) !important;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-close { display: flex; }

    .main-content { margin-left: 0 !important; }
    .menu-toggle { display: flex; }

    .topbar { padding: 0 16px; }
    .hero { height: 320px; }
    .hero-content { padding: 24px 20px; }
    .hero-title { font-size: 1.3rem; }

    .quick-categories { padding: 16px 20px; gap: 8px; }
    .quick-cat { padding: 10px 14px; min-width: 76px; }

    .video-section { padding: 8px 16px 20px; }
    .video-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }

    .video-page { padding: 16px; gap: 16px; }
    .video-detail-title { font-size: 1.1rem; }
    .video-detail-meta { flex-direction: column; }
    .video-detail-actions { flex-wrap: wrap; }

    .search-page, .listing-page, .category-page, .user-page { padding: 16px; }
    .listing-header h1, .category-header h1 { font-size: 1.2rem; }
    .category-header { padding: 16px; flex-direction: column; text-align: center; }

    .user-profile-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 0 16px 20px;
    }
    .user-profile-avatar, .user-profile-avatar-placeholder {
        width: 80px;
        height: 80px;
    }
    .user-profile-details { padding-top: 10px; }
    .user-profile-name { font-size: 1.3rem; }
    .user-profile-stats { justify-content: center; }
    .user-dm-link { margin-top: 0; }
    .user-cover { height: 150px; }
    .user-cover-overlay { height: 150px; }

    .pagination { flex-direction: column; gap: 10px; }
    .page-btn { width: 100%; justify-content: center; }

    .footer { padding: 24px 16px; }
}

@media (max-width: 480px) {
    .hero { height: 260px; }
    .hero-title { font-size: 1.1rem; }
    .hero-play-btn { padding: 10px 20px; font-size: 0.82rem; }
    .video-grid { grid-template-columns: 1fr; }
    .search-bar input { font-size: 0.85rem; }
}

/* ========== TOAST NOTIFICATION ========== */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 300;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast .material-symbols-rounded { color: var(--accent); font-size: 20px; }

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-card-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===== Language Dropdown ===== */
.lang-dropdown-wrapper {
    position: relative;
}

.lang-dropdown-wrapper .lang-switch-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    width: 100%;
}

.lang-dropdown-wrapper .lang-switch-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

.lang-arrow {
    margin-left: auto;
    font-size: 18px !important;
    transition: transform 0.2s ease;
}

.lang-dropdown-wrapper.open .lang-arrow {
    transform: rotate(180deg);
}

.lang-dropdown-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    margin-bottom: 6px;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.96);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    scrollbar-width: thin;
    scrollbar-color: rgba(150, 150, 170, 0.2) transparent;
    padding: 8px;
}

.lang-dropdown-menu::-webkit-scrollbar {
    width: 5px;
}

.lang-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

.lang-dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(150, 150, 170, 0.2);
    border-radius: 10px;
}

.lang-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(150, 150, 170, 0.4);
}

.lang-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.lang-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 400;
    transition: all 0.15s ease;
    border-radius: 8px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.lang-dropdown-item:last-child {
    margin-bottom: 0;
}

.lang-dropdown-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.lang-dropdown-item.active {
    color: var(--accent);
    font-weight: 600;
    background: rgba(226, 60, 82, 0.08);
}

.lang-dropdown-item .lang-flag {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    line-height: 1;
}

.lang-check {
    margin-left: auto;
    font-size: 16px !important;
    color: var(--accent);
    flex-shrink: 0;
}

/* Topbar language dropdown */
.topbar-lang-wrapper {
    position: relative;
}

.topbar-lang-menu {
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    bottom: auto;
    width: 230px;
    margin-top: 8px;
    margin-bottom: 0;
    max-height: 380px;
}

[data-theme="light"] .lang-dropdown-menu {
    background: #fff;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .lang-dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .lang-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .lang-dropdown-item:hover {
    background: #f0f0f5;
}

[data-theme="light"] .lang-dropdown-item.active {
    background: rgba(226, 60, 82, 0.06);
}

/* ===== Ad Slots ===== */
.ad-slot {
    width: 100%;
    text-align: center;
    overflow: hidden;
    margin: 0;
    padding: 0;
    min-height: 0;
}

.ad-slot:empty {
    display: none;
}

.ad-slot-header {
    margin-bottom: 16px;
}

.ad-slot-sidebar {
    margin: 12px 0;
    padding: 0 8px;
}

.ad-slot-content-top {
    margin-bottom: 20px;
}

.ad-slot-content-bottom {
    margin-top: 20px;
}

.ad-slot-video-before {
    margin-bottom: 16px;
}

.ad-slot-video-after {
    margin-top: 16px;
}

.ad-slot-between-cards {
    grid-column: 1 / -1;
    margin: 8px 0;
}

.ad-slot-footer {
    margin-top: 16px;
    margin-bottom: 8px;
}

.ad-slot-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 20px rgba(0,0,0,0.3);
}

.ad-slot-popup .ad-close-btn {
    position: absolute;
    top: 4px;
    right: 8px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* RTL Support */
[dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(100%); }
[dir="rtl"] .sidebar.active { transform: translateX(0); }
[dir="rtl"] .main-content { margin-left: 0; margin-right: var(--sidebar-width); }
[dir="rtl"] .sidebar-collapsed .main-content { margin-left: 0; margin-right: 0; }
[dir="rtl"] .lang-arrow { margin-left: 0; margin-right: auto; }
[dir="rtl"] .lang-check { margin-left: 0; margin-right: auto; }
[dir="rtl"] .topbar-lang-menu { right: 0; left: auto; }


@media (max-width: 768px) {
    [dir="rtl"] .main-content { margin-right: 0; }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    [dir="rtl"] .sidebar.active { transform: translateX(0); }
}

[dir="rtl"] 
[dir="rtl"] .search-bar input { padding: 0 16px 0 88px; }
[dir="rtl"] 
[dir="rtl"] .search-loader { right: auto; left: 88px; }

/* FORCE OVERRIDE FOR SEARCH BAR */
.search-bar .search-input-wrapper {
    position: relative !important;
}

.search-bar 

.search-bar 

.search-bar 



[dir="rtl"] .search-bar 
[dir="rtl"] .search-bar 
[dir="rtl"] 

/* VERY STRONG OVERRIDES FOR SEARCH BAR */
form.search-bar .search-input-wrapper {
    position: relative !important;
}

/* The search icon button on the far right */
form.search-bar button.search-icon {
    position: absolute !important;
    left: auto !important;
    right: 0 !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 24px !important;
    color: var(--text-primary) !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    z-index: 999 !important;
    pointer-events: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}
form.search-bar button.search-icon:hover {
    color: var(--accent) !important;
}

/* The clear button, to the left of search icon */
form.search-bar button.search-clear {
    position: absolute !important;
    left: auto !important;
    right: 44px !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--accent) !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    z-index: 999 !important;
    margin: 0 !important;
    padding: 0 !important;
}
form.search-bar button.search-clear .material-symbols-rounded {
    font-size: 32px !important;
}

/* Input padding to prevent text overlap */
form.search-bar input#searchInput {
    padding-left: 16px !important;
    padding-right: 90px !important;
}

/* RTL overrides */
[dir="rtl"] form.search-bar button.search-icon {
    position: absolute !important;
    left: auto !important;
    right: 0 !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 24px !important;
    color: var(--text-primary) !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    z-index: 999 !important;
    pointer-events: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}
[dir="rtl"] form.search-bar button.search-clear {
    position: absolute !important;
    left: 44px !important;
    right: auto !important;
    width: 44px !important;
    height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: var(--accent) !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    z-index: 999 !important;
    margin: 0 !important;
    padding: 0 !important;
}
[dir="rtl"] form.search-bar input#searchInput { padding-left: 90px !important; padding-right: 16px !important; }

/* ========================================================= */  
/* TÙY CHỈNH MÀU NỀN, ĐỘ TƯƠNG PHẢN VÀ HIỆU ỨNG TÌM KIẾM       */  
/* ========================================================= */  
  
/* 1. NỀN VÀ MÀU CHỮ Ở CHẾ ĐỘ SÁNG (LIGHT MODE) MẶC ĐỊNH */  
form.search-bar .search-input-wrapper {  
    background-color: #f1f5f9 !important; /* Xám nhạt nổi bật trên nền trắng */  
    border: 1px solid #cbd5e1 !important;  
    transition: all 0.3s ease !important;  
}  
form.search-bar input#searchInput {  
    color: #0f172a !important; /* Chữ đen xám dễ đọc */  
}  
form.search-bar input#searchInput::placeholder {  
    color: #64748b !important; /* Chữ placeholder mờ vừa phải */  
}  
  
/* 2. NỀN VÀ MÀU CHỮ Ở CHẾ ĐỘ TỐI (DARK MODE) */  
/* (Bắt cả hệ thống tự động đổi màu và nút bật/tắt dark mode của web) */  
@media (prefers-color-scheme: dark) {  
    form.search-bar .search-input-wrapper {  
        background-color: #1e293b !important; /* Xám xanh đậm nổi bật trên nền đen/xám tối */  
        border: 1px solid #334155 !important;  
    }  
    form.search-bar input#searchInput {  
        color: #f8fafc !important; /* Chữ trắng sáng */  
    }  
    form.search-bar input#searchInput::placeholder {  
        color: #94a3b8 !important; /* Chữ placeholder xám bạc */  
    }  
}  
.dark form.search-bar .search-input-wrapper,  
[data-theme="dark"] form.search-bar .search-input-wrapper {  
    background-color: #1e293b !important;  
    border: 1px solid #334155 !important;  
}  
.dark form.search-bar input#searchInput,  
[data-theme="dark"] form.search-bar input#searchInput {  
    color: #f8fafc !important;  
}  
.dark form.search-bar input#searchInput::placeholder,  
[data-theme="dark"] form.search-bar input#searchInput::placeholder {  
    color: #94a3b8 !important;  
}  
  
/* ========================================================= */  
/* 3. HIỆU ỨNG VIỀN ĐỎ & PHÁT SÁNG KHI NHẬP TỪ KHÓA          */  
/* ========================================================= */  
form.search-bar .search-input-wrapper:focus-within,  
form.search-bar .search-input-wrapper:has(input#searchInput:not(:placeholder-shown)) {  
    border-color: #e23c52 !important; /* Viền màu đỏ thương hiệu */  
    box-shadow: 0 0 0 4px rgba(226, 60, 82, 0.15) !important; /* Quầng sáng đỏ tỏa ra */  
}  
  
/* Đổi màu nền lúc đang gõ chữ cho dễ nhìn hơn */  
form.search-bar .search-input-wrapper:focus-within {  
    background-color: #ffffff !important; /* Light Mode: trắng tinh khi gõ */  
}  
@media (prefers-color-scheme: dark) {  
    form.search-bar .search-input-wrapper:focus-within {  
        background-color: #0f172a !important; /* Dark Mode: đen sâu khi gõ */  
    }  
}  
.dark form.search-bar .search-input-wrapper:focus-within,  
[data-theme="dark"] form.search-bar .search-input-wrapper:focus-within {  
    background-color: #0f172a !important;  
}  
