* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark Theme (default) */
    --bg-primary: #0a0c12;
    --bg-secondary: #0f1119;
    --bg-tertiary: #14161f;
    --bg-card: #1a1d2a;
    --bg-hover: #232634;
    --border-color: #2a2e3a;
    --text-primary: #eef2ff;
    --text-secondary: #9aa2bf;
    --text-muted: #6a6f8a;
    --accent: #f97316;
    --accent-dark: #ea580c;
    --accent-glow: rgba(249, 115, 22, 0.2);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --gradient-1: linear-gradient(135deg, #1a1d2a, #0f1119);
    --gradient-2: linear-gradient(135deg, #0f1119, #0a0c12);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Light Theme Variables */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #f97316;
    --accent-dark: #ea580c;
    --accent-glow: rgba(249, 115, 22, 0.1);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --gradient-1: linear-gradient(135deg, #ffffff, #f8fafc);
    --gradient-2: linear-gradient(135deg, #f8fafc, #f1f5f9);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* Smooth theme transition */
* {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    background: var(--bg-secondary);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 10px;
}

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

/* ========== PORTRAIT MODE LAYOUT REARRANGEMENT ========== */
@media (max-width: 640px) and (orientation: portrait) {
    .main-layout {
        flex-direction: column;
        gap: 0;
    }
    
    .player-area {
        order: 1;
        flex: 0 0 auto;
        min-height: auto;
        padding-bottom: 0;
    }
    
    .channel-sidebar {
        order: 2;
        width: 100%;
        flex: 1;
        margin-top: 0;
        min-height: 0;
    }
    
    .video-container {
        border-radius: 20px;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .main-layout {
        flex-direction: column !important;
        gap: 0 !important;
    }
    
    .player-area {
        order: 1 !important;
        flex: 0 0 auto !important;
        min-height: auto !important;
        padding: 0 !important;
    }
    
    .channel-sidebar {
        order: 2 !important;
        width: 100% !important;
        max-height: 40vh !important;
        flex: 1 !important;
        margin-top: 0 !important;
        min-height: 0 !important;
    }
    
    .video-container {
        border-radius: 0 !important;
        aspect-ratio: auto !important;
        min-height: 60vh !important;
    }
}

@media (min-width: 641px) and (max-width: 1024px) and (orientation: landscape) {
    .main-layout {
        flex-direction: column !important;
    }
    
    .player-area {
        flex: 0 0 auto !important;
        padding: 0 !important;
    }
    
    .channel-sidebar {
        width: 100% !important;
        max-height: 35vh !important;
    }
}

@media (max-width: 640px) {
    .main-layout {
        flex-direction: column;
        gap: 0;
    }
}

/* Fullscreen Styles */
.website-fullscreen {
    overflow: hidden;
}

.website-fullscreen .app-container {
    height: 100vh;
    overflow: hidden;
}

.website-fullscreen .header {
    background: var(--bg-primary);
}

.website-fullscreen .channel-sidebar {
    background: var(--bg-secondary);
}

.video-fullscreen-mode .channel-sidebar,
.video-fullscreen-mode .header {
    display: none !important;
}

.video-fullscreen-mode .player-area {
    padding: 0 !important;
    margin: 0 !important;
    flex: 1 !important;
}

.video-fullscreen-mode .video-container {
    border-radius: 0 !important;
    height: 100vh !important;
    width: 100vw !important;
    aspect-ratio: auto !important;
    box-shadow: none !important;
}

.video-fullscreen-mode #videoPlayer {
    object-fit: contain !important;
}

/* Transitions */
.app-container,
.header,
.channel-sidebar,
.player-area,
.video-container {
    transition: all var(--transition-normal);
}

/* Fullscreen Experience */
:fullscreen .app-container,
:-webkit-full-screen .app-container,
:-moz-full-screen .app-container {
    overflow: hidden;
    height: 100%;
}

:fullscreen .video-container,
:-webkit-full-screen .video-container,
:-moz-full-screen .video-container {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    width: 100% !important;
    height: 100% !important;
}

:fullscreen #videoPlayer,
:-webkit-full-screen #videoPlayer,
:-moz-full-screen #videoPlayer {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

:fullscreen .header,
:-webkit-full-screen .header,
:-moz-full-screen .header {
    display: flex !important;
}

:fullscreen .channel-sidebar,
:-webkit-full-screen .channel-sidebar,
:-moz-full-screen .channel-sidebar {
    display: flex !important;
}

:fullscreen .app-container,
:-webkit-full-screen .app-container,
:-moz-full-screen .app-container {
    height: 100vh;
    overflow: hidden;
}

/* Prevent overscroll */
body {
    overscroll-behavior: none;
    touch-action: pan-y pinch-zoom;
    -webkit-touch-callout: none;
}

.main-layout {
    transition: height 0.2s ease;
}

.app-container {
    scroll-behavior: smooth;
}

/* iOS Safari 100vh fix */
@supports (height: 100dvh) {
    .app-container {
        height: 100dvh;
    }
    
    body {
        height: 100dvh;
    }
    
    html {
        height: 100dvh;
    }
}

.no-select {
    user-select: none;
    -webkit-user-select: none;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.player-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
    padding: 1.5rem;
    overflow-y: auto;
}

.error-message {
    margin-top: 12px;
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--error);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: #fecaca;
    display: none;
}

.error-message.show {
    display: block;
}

/* ======================== TOAST NOTIFICATION STYLES ======================== */

.juzt-toast {
    position: fixed;
    bottom: 30px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: auto;
    min-width: 120px;
    max-width: 240px;
    background: rgba(249, 115, 22, 0.96);
    backdrop-filter: blur(8px);
    color: white;
    padding: 8px 16px;
    border-radius: 40px;
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, sans-serif;
    pointer-events: none;
    opacity: 0;
    animation: toastSlideUp 0.3s ease forwards;
    text-align: center;
    letter-spacing: 0.2px;
}

.juzt-toast i {
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Light mode toast */
[data-theme="light"] .juzt-toast {
    background: rgba(249, 115, 22, 0.96);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

@keyframes toastSlideUp {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tablet devices */
@media (max-width: 768px) {
    .juzt-toast {
        bottom: 25px;
        padding: 7px 14px;
        font-size: 0.8rem;
        gap: 7px;
        min-width: 110px;
        max-width: 220px;
    }
    
    .juzt-toast i {
        font-size: 0.75rem;
    }
}

/* Mobile devices */
@media (max-width: 640px) {
    .juzt-toast {
        bottom: 20px;
        padding: 6px 12px;
        font-size: 0.75rem;
        gap: 6px;
        min-width: 100px;
        max-width: 200px;
    }
    
    .juzt-toast i {
        font-size: 0.7rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .juzt-toast {
        bottom: 20px;
        padding: 5px 10px;
        font-size: 0.7rem;
        gap: 5px;
        min-width: 90px;
        max-width: 180px;
        border-radius: 35px;
    }
    
    .juzt-toast i {
        font-size: 0.65rem;
    }
}

/* Extra small devices */
@media (max-width: 380px) {
    .juzt-toast {
        bottom: 20px;
        padding: 4px 8px;
        font-size: 0.65rem;
        gap: 4px;
        min-width: 80px;
        max-width: 160px;
    }
    
    .juzt-toast i {
        font-size: 0.6rem;
    }
}

/* Responsive */
@media (max-width: 640px) {
    .player-area {
        padding: 0.8rem 0.8rem 0 0.8rem;
        flex: 0 0 auto;
        height: auto;
        overflow-y: visible;
    }
    
    .error-message {
        margin-top: 6px;
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

@media (min-width: 641px) and (max-width: 1024px) and (orientation: portrait) {
    .player-area {
        padding: 1rem 1rem 0 1rem;
        flex: 0 0 auto;
        height: auto;
        overflow-y: visible;
    }
    
    .error-message {
        margin-top: 8px;
    }
}

@media (max-width: 640px) and (orientation: landscape) {
    .player-area {
        padding: 0;
        flex: 1;
        min-height: 60vh;
    }
    
    .error-message {
        margin-top: 6px;
    }
}

@media (min-width: 1025px) {
    .player-area {
        padding: 1.5rem;
    }
    
    .video-container {
        border-radius: 20px;
    }
}

@media (max-width: 640px) {
    .app-container {
        min-height: -webkit-fill-available;
    }
}

.app-container {
    z-index: 1;
}

.modal {
    z-index: 1000;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.video-container,
.channel-sidebar,
.header {
    will-change: transform;
    backface-visibility: hidden;
}

/* Light theme specific adjustments */
[data-theme="light"] .glass-radio-group {
    --bg: rgba(0, 0, 0, 0.05);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02), inset 0 -1px 2px rgba(0, 0, 0, 0.03), 0 2px 6px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .dropdown-menu-icons {
    background: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: var(--shadow-lg);
}

[data-theme="light"] .channel-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .channel-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

[data-theme="light"] .channel-logo {
    background: var(--bg-tertiary);
    color: var(--accent);
}

[data-theme="light"] .search-input-field {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="light"] .search-input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

[data-theme="light"] .modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

[data-theme="light"] .info-row:not(:last-child) {
    border-bottom-color: var(--border-color);
}

[data-theme="light"] .setting-item:not(:last-child) {
    border-bottom-color: var(--border-color);
}
