/* ============================================
   MediaMTX Web Playlist - Optimized Styles
   ============================================ */

/* Base Styles */
body {
    background-color: #0f172a;
    color: #e2e8f0;
    overflow: hidden;
}

/* Animated Background Blobs */
.ambient-light {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: blob 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: #4c1d95;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 50vw;
    height: 50vw;
    background: #1e3a8a;
    animation-delay: 2s;
}

.blob-3 {
    bottom: 20%;
    left: 20%;
    width: 30vw;
    height: 30vw;
    background: #0f766e;
    animation-delay: 4s;
}

@keyframes blob {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

@keyframes blob {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Glassmorphism Components */
.glass-panel {
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.glass-sidebar {
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    transition: all 0.3s ease;
}

.glass-input:focus {
    background: rgba(0, 0, 0, 0.5);
    border-color: #3b82f6;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.glass-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}

.glass-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: #94a3b8;
}

.calendar-day:hover:not(.empty) {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.calendar-day.active {
    background: #3b82f6;
    color: white;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.calendar-day.today {
    border: 1px solid #3b82f6;
}

.calendar-day.empty {
    cursor: default;
}

/* Loading Spinners */
.loader,
.loader-small {
    border-radius: 50%;
    border-style: solid;
    border-color: rgba(255, 255, 255, 0.1);
    border-bottom-color: #3b82f6;
    display: inline-block;
    animation: rotation 1s linear infinite;
}

.loader {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

.loader-small {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

@keyframes rotation {
    to { transform: rotate(360deg); }
}

/* Privacy Blur */
.privacy-blur {
    filter: blur(6px);
    user-select: none;
    transition: filter 0.2s;
}

.privacy-blur:hover {
    filter: blur(4px);
}

/* Active Items */
.active-item {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2) 0%, transparent 100%);
    border-left: 3px solid #3b82f6;
}

/* Channel Items */
.channel-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    cursor: pointer;
}

.channel-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.channel-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2) 0%, transparent 100%);
    border-left: 3px solid #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out forwards;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Latency Badges */
.latency-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-family: monospace;
}

.latency-good {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.latency-medium {
    background: rgba(251, 191, 36, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.latency-bad {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.latency-unknown {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

/* Fix scrolling in playlist panel */
#playlistPanel {
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Desktop: make sure panel has full height */
@media (min-width: 768px) {
    #playlistPanel {
        height: 100% !important;
        max-height: 100% !important;
    }
}

/* Mobile: constrain height */
@media (max-width: 767px) {
    #playlistPanel {
        max-height: 80vh !important;
    }
}

#playlistContainer {
    overflow-y: scroll !important; /* Always show scrollbar */
    overflow-x: hidden !important;
    flex: 1 1 0% !important;
    min-height: 0 !important; /* Critical for flexbox scrolling */
    max-height: 100% !important;
    -webkit-overflow-scrolling: touch !important; /* Smooth scrolling on iOS */
    position: relative !important;
}

/* Custom scrollbar styling for playlist */
#playlistContainer::-webkit-scrollbar {
    width: 8px;
}

#playlistContainer::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#playlistContainer::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 4px;
}

#playlistContainer::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.7);
}

/* General Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
