/* MAIN CSS – UPDATED FOR CHANNEL HEART POSITION */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* THEME VARIABLES */
:root {
    --primary: #0a0a0c;
    --secondary: #121216;
    --accent: #1e1e26;
    --highlight: #f43f5e;
    --highlight-soft: rgba(244, 63, 94, 0.2);
    --text: #ffffff;
    --text-dim: #94a3b8;
    --bg: #050507;
    --card-bg: #121216;
    --border: rgba(255, 255, 255, 0.04);
    --border-hover: rgba(255, 255, 255, 0.08);
    --success: #10b981;
    --warning: #f59e0b;
    --glass: rgba(10, 10, 12, 0.7);
    --gradient: linear-gradient(135deg, #f43f5e 0%, #ec4899 100%);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.6);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light {
    --primary: #ffffff;
    --secondary: #f8fafc;
    --accent: #f1f5f9;
    --highlight: #f43f5e;
    --highlight-soft: rgba(244, 63, 94, 0.1);
    --text: #0f172a;
    --text-dim: #64748b;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: rgba(0, 0, 0, 0.05);
    --border-hover: rgba(0, 0, 0, 0.1);
    --glass: rgba(255, 255, 255, 0.8);
}

/* GLOBAL */
html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s ease, color 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
}

/* ANIMATIONS */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

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

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* SPLASH SCREEN - PREMIUM REDESIGN */
.splash {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    /* Deep premium dark background */
    z-index: 10000;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s ease;
}

.splash.hide {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    animation: splashIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes splashIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.splash-logo-container {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.splash-icon {
    width: 64px;
    height: 64px;
    color: var(--highlight);
    filter: drop-shadow(0 0 15px rgba(244, 63, 94, 0.4));
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {

    0%,
    100% {
        transform: translateY(0) rotate(0);
    }

    50% {
        transform: translateY(-10px) rotate(5deg);
    }
}

.splash-logo {
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #fff 0%, rgba(255, 255, 255, 0.7) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.splash-loading-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.splash-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(244, 63, 94, 0.1);
    border-top: 3px solid var(--highlight);
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.2);
}

.splash p {
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.8;
}

/* APP LAYOUT */
.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    background: var(--bg);
}

.content {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    will-change: transform;
    transition: transform 0.3s ease;
}

/* HEADER */
.header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--primary);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--highlight);
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--highlight), #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

#menuBtn {
    background: var(--accent);
    border: none;
    color: var(--text);
    padding: 0.6rem;
    border-radius: 12px;
    transition: var(--transition);
}

#menuBtn:hover {
    background: var(--border-hover);
    transform: none;
}

.header-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.header-btn:hover {
    background: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.header-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
}

/* PWA Install Button - Permanent Top Right */
.install-btn {
    background: linear-gradient(135deg, var(--highlight), #ec4899) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.install-btn:hover {
    box-shadow: 0 6px 20px rgba(244, 63, 94, 0.5) !important;
    transform: translateY(-3px) !important;
}

.install-btn svg {
    color: white;
    stroke: white;
}

.theme-btn {
    position: relative;
}

.theme-btn svg {
    transition: all 0.3s ease;
}

body.light .moon-icon {
    display: none;
}

body.light .sun-icon {
    display: block !important;
}

.btn-text {
    font-size: 0.9rem;
    font-weight: 500;
}

/* CONTENT WRAPPER */
.content {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* OVERLAY */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.show {
    opacity: 1;
    visibility: visible;
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--card-bg);
    color: var(--text);
    padding: 1rem 2rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    font-weight: 500;
    border: 1px solid var(--border);
    max-width: 90%;
}

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

.toast.error {
    background: var(--highlight);
    color: white;
    border-color: var(--highlight);
}

/* MODAL */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 16px;
    min-width: 280px;
    max-width: 90%;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.3s ease;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    font-weight: 600;
}

#qualityOptions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quality-option {
    padding: 0.9rem;
    background: var(--accent);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: var(--transition);
}

.quality-option:hover {
    background: var(--highlight);
    color: white;
    border-color: var(--highlight);
    transform: translateX(5px);
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    color: var(--text-dim);
    padding: 3rem 1rem;
    font-size: 1rem;
    font-weight: 500;
}

/* UTILS */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

/* CLOSE BUTTON */
.close-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--highlight);
    color: white;
    transform: rotate(90deg);
}

.close-btn svg {
    width: 20px;
    height: 20px;
}

/* MODERN SPINNER */
.modern-spinner {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 3px solid rgba(148, 163, 184, 0.45);
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

/* CHANNEL GRID + HEART POSITION */
.channel-grid {
    flex: 0.52;
    padding: 1rem 1rem 1.25rem;
    overflow-y: auto;
    background: var(--secondary);
    border-right: 1px solid var(--border);
}

/* Card row layout */
.channel-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.85rem 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    animation: fadeIn 0.35s ease-out;
    overflow: hidden;
    min-height: 90px;
    margin-bottom: 0.8rem;
}

.channel-card:hover {
    border-color: rgba(248, 113, 113, 0.8);
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.35);
}

/* Logo */
.channel-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    object-fit: contain;
}

/* Info container */
.channel-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.channel-name {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Truncate long names */
    width: 100%;
}

/* meta row under name */
.channel-meta-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.84rem;
    color: var(--text-dim);
}

/* tags */
.channel-tag {
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(15, 23, 42, 0.9);
}

.channel-tag.quality {
    background: var(--highlight-soft);
    color: var(--highlight);
    font-weight: 700;
}

body.light .channel-tag.quality {
    color: #e11d48;
    /* Slightly darker pink for better contrast on light */
}

/* HEART – Instagram-style, right side, centered */
.channel-fav {
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.18s ease;
    margin-left: auto;
}

.channel-fav .fav-icon {
    width: 15px;
    height: 15px;
    fill: transparent;
    transition: transform 0.18s ease, fill 0.18s ease;
}

.channel-fav:hover {
    background: rgba(30, 64, 175, 0.95);
    border-color: rgba(248, 250, 252, 0.9);
}

.channel-fav.fav-active {
    background: rgba(24, 24, 27, 0.96);
    border-color: rgba(248, 113, 113, 0.9);
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.6);
}

.channel-fav.fav-active .fav-icon {
    fill: #f43f5e;
    transform: scale(1.05);
}

/* CUSTOM DROPDOWN (TIVY-SELECT) */
.tivy-select {
    position: relative;
    width: 100%;
}

.tivy-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.9rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    user-select: none;
}

.tivy-select:hover .tivy-select-trigger {
    border-color: var(--highlight);
    background: var(--accent);
}

.tivy-select.open .tivy-select-trigger {
    border-color: var(--highlight);
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--highlight-soft);
}

.tivy-select-trigger svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
    stroke-width: 2.5;
    color: var(--text-dim);
}

.tivy-select.open .tivy-select-trigger svg {
    transform: rotate(180deg);
    color: var(--highlight);
}

.tivy-select-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
}

.tivy-select.open .tivy-select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tivy-select-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    color: var(--text);
}

.tivy-select-option:hover {
    background: var(--highlight-soft);
    color: var(--highlight);
    padding-left: 1.25rem;
}

.tivy-select-option.selected {
    background: var(--highlight);
    color: white;
}

.tivy-select-options::-webkit-scrollbar {
    width: 6px;
}

.tivy-select-options::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 10px;
}

.tivy-select-options::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}