/* Radio Insular Web Popup - Main Styles */
/* Spotify-like Dark Theme */

:root {
    /* Colors */
    --primary: #1DB954;
    --primary-light: #1ED760;
    --primary-dark: #1AA34A;
    --background: #121212;
    --surface: #181818;
    --surface-variant: #282828;
    --text-primary: #FFFFFF;
    --text-secondary: #B3B3B3;
    --text-tertiary: #6A6A6A;
    --accent: #1DB954;
    --error: #E61E32;
    --warning: #FF5722;
    --divider: #2A2A2A;
    --border: #333333;
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.3);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container - Fixed 9:16 Aspect Ratio */
.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 500px;
    height: 889px; /* 9:16 aspect ratio: 500 ÷ 9 × 16 = 889px */
    margin: 0 auto;
    background: var(--background);
    position: relative;
    overflow: hidden;
    border-radius: 0;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* PWA Standalone Mode - Mobile First (eliminates margins) */
@media (display-mode: standalone) and (max-width: 520px) {
    html, body {
        height: 100vh !important;
        height: 100dvh !important;
        overflow: hidden;
        margin: 0;
        padding: 0;
        background: var(--background);
    }
    
    body {
        display: block !important;
        align-items: unset !important;
        justify-content: unset !important;
    }
    
    .app-container {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        position: relative;
    }
    
    .footer {
        max-width: 100vw !important;
        width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
    }
}

/* PWA Standalone Mode - Desktop/Tablet */
@media (display-mode: standalone) and (min-width: 521px) {
    html, body {
        height: 100vh;
        overflow: hidden;
        margin: 0;
        padding: 0;
        background: #000;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .app-container {
        width: 500px !important;
        height: 889px !important;
        max-width: 500px !important;
        max-height: 889px !important;
        border-radius: 0;
        box-shadow: none;
        position: relative;
        flex-shrink: 0;
    }
}

/* Mobile Viewport Optimization - Maintain 9:16 (PRIORITY) */
@media screen and (max-width: 480px) {
    html, body {
        margin: 0;
        padding: 0;
        overflow: hidden;
        background: var(--background);
        height: 100vh;
        height: 100dvh;
    }
    
    .app-container {
        width: 100vw !important;
        height: calc(100vw / 9 * 16) !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
    }
    
    .footer {
        max-width: 100vw !important;
        width: 100vw !important;
        left: 0 !important;
        right: 0 !important;
    }
}

/* Browser Mode Styles for larger screens */
@media screen and (min-width: 481px) {
    body {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        background: #000;
        padding: 0px;
    }
    
    .app-container {
        border-radius: 20px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
        position: relative;
    }
}

/* Very small screens - adapt to screen */
@media screen and (max-width: 320px) {
    .app-container {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
    }
}

/* Large screens - keep fixed size */
@media screen and (min-width: 768px) {
    .app-container {
        width: 500px;
        height: 889px;
    }
}

/* Header */
.header {
    background: var(--background);
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--divider);
    flex-shrink: 0;
    height: 60px;
    display: flex;
    align-items: center;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.report-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    opacity: 0.7;
}

.report-btn:hover {
    background: var(--surface-variant);
    color: var(--text-primary);
    opacity: 1;
}

/* Player Section */
.player-section {
    background: var(--surface);
    padding: var(--spacing-sm);
    border-bottom: 1px solid var(--divider);
    flex-shrink: 0;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    position: relative;
    overflow: hidden;
}

.player-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.1) 100%);
    z-index: 1;
    pointer-events: none;
}

.player-section > * {
    position: relative;
    z-index: 2;
}

/* Visualizer */
.visualizer-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#visualizer {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.visualizer-fallback {
    display: none;
    justify-content: center;
    align-items: flex-end;
    gap: 3px;
    height: 60px;
    width: 100%;
    max-width: 300px;
}

.visualizer-fallback .bar {
    width: 4px;
    background: var(--primary);
    border-radius: 2px;
    animation: pulse 1.5s ease-in-out infinite;
}

.visualizer-fallback .bar:nth-child(1) { animation-delay: 0s; height: 20px; }
.visualizer-fallback .bar:nth-child(2) { animation-delay: 0.1s; height: 35px; }
.visualizer-fallback .bar:nth-child(3) { animation-delay: 0.2s; height: 45px; }
.visualizer-fallback .bar:nth-child(4) { animation-delay: 0.3s; height: 55px; }
.visualizer-fallback .bar:nth-child(5) { animation-delay: 0.4s; height: 40px; }
.visualizer-fallback .bar:nth-child(6) { animation-delay: 0.5s; height: 30px; }
.visualizer-fallback .bar:nth-child(7) { animation-delay: 0.6s; height: 25px; }

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

.status-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-indicator.playing .status-text {
    color: var(--primary);
}

.status-indicator.error .live-dot {
    background: var(--error);
}

.status-indicator.error .status-text {
    color: var(--error);
}

/* Current Show */
.current-show {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    width: 100%;
    max-width: 280px;
}

.show-image {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface-variant);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.show-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.show-placeholder {
    font-size: 24px;
    opacity: 0.5;
}

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

.show-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.show-info p {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Track Info (LunaRadio style) */
.track-info-container {
    width: 100%;
    max-width: 280px;
    text-align: center;
    margin: var(--spacing-sm) 0;
    position: relative;
    z-index: 2;
}

.track-info {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.current-artist {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.current-title {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-info-container.playing .current-title {
    color: #7fff00;
    text-shadow: 0 0 10px rgba(127, 255, 0, 0.3);
}

.track-info-container.playing .track-info {
    border-color: rgba(127, 255, 0, 0.2);
    background: rgba(127, 255, 0, 0.05);
}

/* Player Controls */
.player-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    width: 100%;
    max-width: 280px;
    justify-content: center;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid var(--primary);
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.control-btn:hover {
    background: var(--primary);
    color: black;
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(29, 185, 84, 0.4);
}

.control-btn:active {
    transform: scale(0.95);
}

.volume-control {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
    max-width: 120px;
}

.volume-control svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.volume-slider {
    flex: 1;
    height: 4px;
    background: var(--surface-variant);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--divider);
    flex-shrink: 0;
    height: 50px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: var(--spacing-md) var(--spacing-sm);
    transition: all var(--transition-fast);
    position: relative;
}

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

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #E61E32;
    color: white;
    font-size: 10px;
    font-weight: 600;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badge-pulse 2s ease-in-out infinite;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes badge-pulse {
    0%, 100% { 
        transform: scale(1); 
        opacity: 1; 
    }
    50% { 
        transform: scale(1.1); 
        opacity: 0.8; 
    }
}

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    background: var(--background);
    padding-bottom: 80px; /* Espacio para el footer fijo */
    min-height: 0; /* Permitir que se encoja */
}

.tab-content {
    display: none;
    padding: var(--spacing-md);
    height: 100%;
    overflow-y: auto;
}

.tab-content.active {
    display: block;
}

/* Loading States */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--surface-variant);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--spacing-md);
}

/* Footer */
.footer {
    background: var(--surface);
    padding: var(--spacing-md);
    border-top: 1px solid var(--divider);
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-shrink: 0;
    height: 60px;
    gap: var(--spacing-sm);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    max-width: 500px;
    margin: 0 auto;
}

.whatsapp-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-xl);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    transition: all var(--transition-fast);
}

.whatsapp-btn:hover {
    background: var(--primary);
    color: black;
}

.app-download-btn {
    background: transparent;
    border: 1px solid #888888;
    color: #888888;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-xl);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.app-download-btn:hover {
    background: #888888;
    color: black;
}

.app-download-btn svg {
    fill: currentColor;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

.connection-status.disconnected .status-dot {
    background: var(--error);
}

/* Scrollbar Styling */
.content-area::-webkit-scrollbar {
    width: 6px;
}

.content-area::-webkit-scrollbar-track {
    background: var(--surface);
}

.content-area::-webkit-scrollbar-thumb {
    background: var(--surface-variant);
    border-radius: 3px;
}

.content-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Responsive Design */
@media (max-width: 375px) {
    .app-container {
        max-width: 100%;
    }
    
    .header {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .player-section {
        padding: var(--spacing-md);
    }
    
    .tab-content {
        padding: var(--spacing-sm);
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scaleY(0.4); }
    50% { opacity: 1; transform: scaleY(1); }
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.fade-in {
    animation: fadeIn 0.3s ease-out;
}
