:root {
    /* Paleta de Colores Curada */
    --bg-darkest: #0b0b14;
    --bg-darker: #121224;
    --bg-glass: rgba(18, 18, 36, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-focus: rgba(139, 92, 246, 0.4);
    
    --primary: #8b5cf6;       /* Violeta Eléctrico */
    --primary-glow: rgba(139, 92, 246, 0.3);
    --primary-hover: #a78bfa;
    
    --secondary: #06b6d4;     /* Cyan */
    --secondary-glow: rgba(6, 182, 212, 0.3);
    
    --accent-red: #f43f5e;    /* Coral */
    --accent-red-glow: rgba(244, 63, 94, 0.3);
    
    --accent-green: #10b981;  /* Esmeralda */
    
    --text-white: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --font-heading: 'Space Grotesk', sans-serif;
    --font-body: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-darkest);
    color: var(--text-white);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Fondos Orbitales en Movimiento */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.15;
    pointer-events: none;
    z-index: -1;
    animation: pulse 12s infinite alternate ease-in-out;
}

.bg-glow-1 {
    top: -10%;
    left: -10%;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
}

.bg-glow-2 {
    bottom: -10%;
    right: -10%;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    animation-delay: -6s;
}

@keyframes pulse {
    0% {
        transform: scale(1) translate(0, 0);
    }
    100% {
        transform: scale(1.2) translate(50px, 50px);
    }
}

/* Contenedor Principal */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

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

.logo-icon {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.logo-text span {
    font-weight: 300;
    color: var(--secondary);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Layout Grid */
.grid-layout {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 24px;
    flex-grow: 1;
    align-items: start;
}

@media (max-width: 1024px) {
    .grid-layout {
        grid-template-columns: 1fr;
    }
}

/* Glass Cards */
.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.panel-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.creation-card {
    margin-bottom: 24px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-white);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Formularios */
.creation-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 8px;
}

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

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

input[type="text"], input[type="url"] {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    color: var(--text-white);
    padding: 12px 16px;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    outline: none;
}

input[type="text"]:focus, input[type="url"]:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 12px var(--primary-glow);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-white);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--text-muted);
}

.btn-control {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-white);
    border: 1px solid var(--border-glass);
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.1rem;
}

.btn-control:hover:not(:disabled) {
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    transform: translateY(-2px);
    border-color: transparent;
}

.btn-danger {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-danger:hover {
    background: var(--accent-red);
    color: white;
    box-shadow: 0 4px 10px var(--accent-red-glow);
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Lista de Canales */
.channels-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-glass) transparent;
}

.channels-list::-webkit-scrollbar {
    width: 6px;
}

.channels-list::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 10px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
}

.empty-state span {
    font-size: 0.8rem;
    margin-top: 4px;
}

/* Tarjetas de Canal Activo */
.channel-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: var(--transition-smooth);
    cursor: pointer;
}

.channel-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.channel-card.active {
    background: rgba(139, 92, 246, 0.08);
    border-color: var(--primary);
    box-shadow: inset 0 0 10px rgba(139, 92, 246, 0.15);
}

.channel-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.channel-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 70%;
}

.channel-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-url {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-badge {
    background: rgba(6, 182, 212, 0.1);
    color: var(--secondary);
    border: 1px solid rgba(6, 182, 212, 0.2);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.channel-card.active .channel-badge {
    background: rgba(139, 92, 246, 0.2);
    color: var(--primary-hover);
    border-color: var(--primary);
}

.channel-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
}

.card-action-left {
    display: flex;
    gap: 8px;
}

.btn-card-action {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-card-action:hover {
    color: var(--secondary);
}

/* Panel de Teatro (Reproductor) */
.theatre-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
}

.theatre-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.player-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background-color: #000;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
}

#stream-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Elementos del Placeholder en el Player */
.player-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    gap: 16px;
    z-index: 10;
}

.placeholder-icon {
    font-size: 4rem;
    background: linear-gradient(135deg, #ff9f43, #ff5252);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(255, 82, 82, 0.3));
    animation: bounce 4s infinite ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.player-placeholder h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--text-white);
}

.player-placeholder p {
    max-width: 450px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.player-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 20;
}

.player-loader p {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Controles Remotos */
.remote-controls {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: var(--transition-smooth);
}

.remote-controls.disabled {
    opacity: 0.3;
    pointer-events: none;
}

.controls-header h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-white);
}

.active-channel-url {
    font-size: 0.8rem;
    color: var(--secondary);
    word-break: break-all;
}

.control-groups {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 30px;
    border-top: 1px solid var(--border-glass);
    padding-top: 20px;
}

@media (max-width: 768px) {
    .control-groups {
        grid-template-columns: 1fr;
    }
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-group h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.button-row {
    display: flex;
    gap: 12px;
}

.redirect-form {
    display: flex;
    gap: 10px;
}

.redirect-form input {
    flex-grow: 1;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 24px;
    transition: var(--transition-smooth);
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-color: var(--border-glass-focus);
}

.modal-content h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-content p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 10px;
}

/* Spinner animado */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(139, 92, 246, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.hidden {
    display: none !important;
}

:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

/* Botones de Modo (Pipeline / Directo) */
.mode-btn {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    text-align: center;
    transition: var(--transition-smooth);
    line-height: 1.4;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-white);
}

.mode-btn-active[data-mode="pipeline"] {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

.mode-btn-active[data-mode="direct"] {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

/* Badges de modo en tarjetas de canal */
.badge-pipeline {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.4);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-direct {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.4);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Acciones dentro de tarjetas de canal */
.channel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.channel-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pulse-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: blink 2s infinite;
    flex-shrink: 0;
}

.btn-view-channel {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary-hover);
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 6px 14px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.btn-view-channel:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 10px var(--primary-glow);
}

.btn-action-card {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border-glass);
    padding: 6px 10px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.btn-action-card:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-white);
}

.btn-close-card:hover {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-red);
    border-color: rgba(244, 63, 94, 0.3);
}
