/* ============================================
   StreamVault IPTV - Premium Design System
   ============================================ */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a25;
    --bg-card-hover: #22223a;
    --bg-sidebar: #0e0e16;
    --bg-input: #16162080;
    --surface: #1e1e2e;
    --surface-hover: #2a2a3e;

    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --accent-dark: #4834d4;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --accent-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);

    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --info: #74b9ff;

    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;

    --border: #2a2a3a;
    --border-light: #35354a;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-round: 50%;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 30px var(--accent-glow);

    --sidebar-width: 320px;
    --topbar-height: 64px;

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

input, button {
    font-family: inherit;
    font-size: inherit;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
}

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

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

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

.hidden {
    display: none !important;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-bg {
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    overflow: hidden;
}

.login-gradient {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 50%, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(162, 155, 254, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(72, 52, 212, 0.1) 0%, transparent 50%);
}

.login-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-light);
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat 8s infinite;
}

@keyframes particleFloat {
    0% { opacity: 0; transform: translateY(100vh) scale(0); }
    10% { opacity: 0.6; }
    90% { opacity: 0.6; }
    100% { opacity: 0; transform: translateY(-100px) scale(1); }
}

.login-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: rgba(18, 18, 26, 0.8);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(108, 92, 231, 0.15);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(108, 92, 231, 0.1);
    animation: cardAppear 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-lg);
    background: var(--accent-gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    margin-bottom: 16px;
    box-shadow: var(--shadow-glow);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(108, 92, 231, 0.3); }
    50% { box-shadow: 0 0 40px rgba(108, 92, 231, 0.5); }
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
    font-weight: 400;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
    transition: color var(--transition);
    z-index: 2;
}

.input-group input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    transition: all var(--transition);
    outline: none;
}

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

.input-group input:focus {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.05);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
}

.input-group input:focus ~ .input-icon,
.input-group input:focus + .input-line + .input-icon {
    color: var(--accent);
}

.input-group:focus-within .input-icon {
    color: var(--accent);
}

.input-line {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--accent-gradient);
    transition: all var(--transition);
    transform: translateX(-50%);
    border-radius: 1px;
}

.input-group input:focus ~ .input-line {
    width: 100%;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    text-align: center;
    min-height: 0;
    transition: all var(--transition);
    overflow: hidden;
}

.login-error.show {
    min-height: 20px;
    animation: shakeError 0.5s ease;
}

@keyframes shakeError {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.login-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.login-btn:hover::before {
    transform: translateX(100%);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.login-btn:active {
    transform: translateY(0);
}

.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 12px;
}

.login-footer i {
    color: var(--success);
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    z-index: 100;
    overflow: hidden;
}

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

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.sidebar-brand {
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-close {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all var(--transition-fast);
}

.sidebar-close:hover {
    background: var(--surface);
    color: var(--text-primary);
}

/* Playlist Section */
.playlist-section,
.saved-playlists-section,
.categories-section {
    padding: 16px 16px 8px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding: 0 4px;
}

.section-title i {
    font-size: 14px;
    color: var(--accent-light);
}

.playlist-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.playlist-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    transition: all var(--transition);
    outline: none;
}

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

.playlist-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.add-playlist-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
}

.add-playlist-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Saved Playlists */
.saved-playlists {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: transparent;
}

.playlist-item:hover {
    background: var(--surface);
}

.playlist-item.active {
    background: rgba(108, 92, 231, 0.15);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.playlist-item-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-light);
    font-size: 16px;
    flex-shrink: 0;
}

.playlist-item.active .playlist-item-icon {
    background: var(--accent-gradient);
    color: white;
}

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

.playlist-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item-count {
    font-size: 11px;
    color: var(--text-muted);
}

.playlist-item-delete {
    opacity: 0;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--danger);
    font-size: 14px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.playlist-item:hover .playlist-item-delete {
    opacity: 1;
}

.playlist-item-delete:hover {
    background: rgba(225, 112, 85, 0.15);
}

/* Category List */
.categories-section {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1;
    padding-bottom: 8px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 13px;
    color: var(--text-secondary);
}

.category-item:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.category-item.active {
    background: rgba(108, 92, 231, 0.12);
    color: var(--accent-light);
    font-weight: 500;
}

.category-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.category-item-count {
    margin-left: auto;
    font-size: 11px;
    background: var(--surface);
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--text-muted);
}

.category-item.active .category-item-count {
    background: rgba(108, 92, 231, 0.2);
    color: var(--accent-light);
}

/* Sidebar Footer */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    margin-top: auto;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-round);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.logout-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 18px;
    transition: all var(--transition-fast);
}

.logout-btn:hover {
    background: rgba(225, 112, 85, 0.1);
    color: var(--danger);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 22px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.menu-toggle:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.search-container {
    flex: 1;
    position: relative;
    max-width: 500px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 42px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all var(--transition);
}

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

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.search-clear:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.view-toggle {
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 16px;
    transition: all var(--transition-fast);
}

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

.view-btn:not(.active):hover {
    color: var(--text-primary);
}

/* ============================================
   PLAYER AREA
   ============================================ */
.player-area {
    flex-shrink: 0;
    background: #000;
    border-bottom: 1px solid var(--border);
}

.player-wrapper {
    max-width: 100%;
}

.player-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 55vh;
    background: #000;
    overflow: hidden;
}

.player-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Player Overlay */
.player-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 12, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    backdrop-filter: blur(8px);
}

.player-overlay.hidden {
    display: none;
}

/* ── TV ANIMATED LOADER ── */
.player-loading-anim {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.tv-loader {
    position: relative;
    width: 80px;
    height: 80px;
}

.tv-body {
    position: relative;
    width: 72px;
    height: 56px;
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: 8px;
    margin: 16px auto 0;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.3), inset 0 0 15px rgba(108, 92, 231, 0.1);
}

.tv-screen {
    position: absolute;
    inset: 4px;
    border-radius: 4px;
    overflow: hidden;
    background: #0a0a14;
}

.tv-static {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
    background-size: 100px 100px;
    animation: staticNoise 0.15s steps(5) infinite;
    opacity: 0.6;
}

@keyframes staticNoise {
    0%   { background-position: 0 0; }
    20%  { background-position: -30px 20px; }
    40%  { background-position: 15px -40px; }
    60%  { background-position: -20px 35px; }
    80%  { background-position: 40px -15px; }
    100% { background-position: -10px 10px; }
}

.tv-scanline {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(108, 92, 231, 0.5), transparent);
    animation: scanline 2s linear infinite;
    box-shadow: 0 0 8px rgba(108, 92, 231, 0.4);
}

@keyframes scanline {
    0%   { top: -3px; }
    100% { top: 100%; }
}

.tv-antenna {
    position: absolute;
    width: 2px;
    height: 16px;
    background: var(--accent-light);
    top: 0;
    border-radius: 1px;
}

.tv-antenna.left {
    left: 22px;
    transform: rotate(-30deg);
    transform-origin: bottom center;
    animation: antennaWiggle 1.5s ease-in-out infinite;
}

.tv-antenna.right {
    right: 22px;
    transform: rotate(30deg);
    transform-origin: bottom center;
    animation: antennaWiggle 1.5s ease-in-out infinite 0.2s;
}

@keyframes antennaWiggle {
    0%, 100% { transform: rotate(-30deg); }
    50% { transform: rotate(-20deg); }
}

.tv-antenna.right {
    animation-name: antennaWiggleR;
}

@keyframes antennaWiggleR {
    0%, 100% { transform: rotate(30deg); }
    50% { transform: rotate(20deg); }
}

.loading-text {
    text-align: center;
}

.loading-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loading-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-light);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* Signal Bars */
.signal-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 16px;
}

.signal-bars .bar {
    width: 4px;
    background: var(--accent);
    border-radius: 2px;
    animation: signalPulse 1.8s ease-in-out infinite;
}

.signal-bars .bar:nth-child(1) { height: 4px; animation-delay: 0s; }
.signal-bars .bar:nth-child(2) { height: 7px; animation-delay: 0.15s; }
.signal-bars .bar:nth-child(3) { height: 10px; animation-delay: 0.3s; }
.signal-bars .bar:nth-child(4) { height: 13px; animation-delay: 0.45s; }
.signal-bars .bar:nth-child(5) { height: 16px; animation-delay: 0.6s; }

@keyframes signalPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ── SEEK INDICATORS ── */
.seek-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) scale(0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(8px);
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 8;
}

.seek-indicator i {
    font-size: 28px;
}

.seek-indicator.left {
    left: 15%;
}

.seek-indicator.right {
    right: 15%;
}

.seek-indicator.show {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* Generic spinner (for non-player use) */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── ERROR OVERLAY ── */
.player-error {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 12, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 6;
    color: var(--danger);
    backdrop-filter: blur(8px);
}

.player-error i {
    font-size: 48px;
    animation: errorPulse 2s ease-in-out infinite;
}

@keyframes errorPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.95); }
}

.player-error span {
    color: var(--text-secondary);
    font-size: 14px;
}

.retry-btn {
    margin-top: 8px;
    padding: 10px 24px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* ── NOW PLAYING BAR ── */
.now-playing {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    gap: 12px;
}

.now-playing-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.now-playing-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: var(--surface);
    flex-shrink: 0;
}

.now-playing-text {
    min-width: 0;
}

.now-playing-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-group {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── NOW PLAYING CONTROLS ── */
.now-playing-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.np-ctrl-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    transition: all var(--transition-fast);
    position: relative;
}

.np-ctrl-btn:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.np-ctrl-btn:active {
    transform: scale(0.92);
}

.np-ctrl-play {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-round);
    background: var(--accent-gradient);
    color: white;
    font-size: 20px;
    box-shadow: 0 2px 10px rgba(108, 92, 231, 0.3);
}

.np-ctrl-play:hover {
    background: var(--accent-gradient);
    color: white;
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.4);
}

.np-ctrl-play:active {
    transform: scale(0.95);
}

.player-close-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 20px;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.player-close-btn:hover {
    background: rgba(225, 112, 85, 0.1);
    color: var(--danger);
}

/* ============================================
   WELCOME STATE
   ============================================ */
.welcome-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.welcome-content {
    text-align: center;
    max-width: 400px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-xl);
    background: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: var(--accent-light);
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.welcome-content h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
}

.welcome-content p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.welcome-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
}

.welcome-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* ============================================
   CHANNELS AREA
   ============================================ */
.channels-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.channels-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.channels-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

.channels-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.channels-title {
    font-size: 20px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channels-count {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--surface);
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Cache Status Badge */
.cache-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface);
    padding: 5px 12px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.cache-status i {
    font-size: 13px;
    color: var(--accent-light);
}

/* Refresh Button */
.refresh-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    transition: all var(--transition);
    border: 1px solid var(--border);
    background: var(--surface);
}

.refresh-btn:hover {
    color: var(--accent-light);
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.1);
    transform: rotate(45deg);
}

.refresh-btn:active {
    transform: rotate(90deg) scale(0.95);
}

.refresh-btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.refresh-btn.spinning i,
.ri-spin {
    animation: spin 1s linear infinite;
}

/* Grid View */
.channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.channels-grid.list-view {
    grid-template-columns: 1fr;
    gap: 8px;
}

/* Channel Card - Grid */
.channel-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.channel-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition);
}

.channel-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.channel-card:hover::before {
    opacity: 0.05;
}

.channel-card:active {
    transform: translateY(-2px);
}

.channel-logo {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    object-fit: contain;
    background: var(--surface);
    padding: 4px;
    position: relative;
    z-index: 1;
}

.channel-logo-placeholder {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    color: white;
    position: relative;
    z-index: 1;
}

.channel-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    position: relative;
    z-index: 1;
}

.channel-group {
    font-size: 11px;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}

/* Channel Card - List View */
.channels-grid.list-view .channel-card {
    flex-direction: row;
    padding: 12px 16px;
    text-align: left;
    gap: 14px;
}

.channels-grid.list-view .channel-logo,
.channels-grid.list-view .channel-logo-placeholder {
    width: 44px;
    height: 44px;
    font-size: 16px;
    flex-shrink: 0;
}

.channels-grid.list-view .channel-name {
    font-size: 14px;
}

.channels-grid.list-view .channel-card:hover {
    transform: translateX(4px);
}

/* Playing indicator */
.channel-card.playing {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.08);
}

.channel-card.playing::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    z-index: 2;
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(0, 184, 148, 0.5); }
    50% { opacity: 0.8; box-shadow: 0 0 0 6px rgba(0, 184, 148, 0); }
}

/* Loading Channels */
.loading-channels {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 400px;
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px);
}

.toast.toast-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

.toast-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--info); }

.toast-message {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        box-shadow: none;
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 20px 0 60px rgba(0,0,0,0.5);
    }

    .sidebar-close {
        display: flex;
    }

    .menu-toggle {
        display: flex;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 199;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition);
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }
}

@media (max-width: 768px) {
    .top-bar {
        padding: 10px 16px;
    }

    .channels-area {
        padding: 16px;
    }

    .channels-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .channel-card {
        padding: 16px 12px;
    }

    .channel-logo,
    .channel-logo-placeholder {
        width: 48px;
        height: 48px;
    }

    .player-container {
        max-height: 40vh;
    }

    .login-card {
        padding: 32px 24px;
    }

    .view-toggle {
        display: none;
    }
}

@media (max-width: 480px) {
    .channels-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .channel-card {
        padding: 14px 10px;
        gap: 8px;
    }

    .channel-logo,
    .channel-logo-placeholder {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .channel-name {
        font-size: 12px;
    }

    .search-container {
        max-width: none;
    }

    .now-playing {
        padding: 8px 12px;
        gap: 8px;
    }

    .now-playing-logo {
        width: 32px;
        height: 32px;
    }

    .now-playing-name {
        font-size: 12px;
    }

    .now-playing-controls {
        gap: 2px;
    }

    .np-ctrl-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .np-ctrl-play {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    #btn-fullscreen {
        display: none;
    }

    .seek-indicator {
        padding: 10px 14px;
    }

    .seek-indicator i {
        font-size: 22px;
    }

    .tv-loader {
        width: 60px;
        height: 60px;
    }

    .tv-body {
        width: 56px;
        height: 44px;
    }

    .loading-title {
        font-size: 12px;
        max-width: 160px;
    }

    .channels-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .channels-header-left {
        width: 100%;
    }

    .channels-header-right {
        width: 100%;
        justify-content: space-between;
    }

    .cache-status {
        font-size: 10px;
        padding: 4px 10px;
    }
}
