/* ================= RESET Y BASE ================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

/* ================= PANTALLA DE LOGIN ================= */
#login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.login-box h1 {
    color: #0f3460;
    margin-bottom: 10px;
    font-size: 2rem;
}

.login-box h2 {
    color: #555;
    margin-bottom: 15px;
    font-size: 1.5rem;
    font-weight: 400;
}

.login-info {
    color: #666;
    margin-bottom: 25px;
    font-size: 0.95rem;
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.input-group input:focus {
    outline: none;
    border-color: #0f3460;
    box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.1);
}

.login-button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(15, 52, 96, 0.3);
}

.error-message {
    color: #c0392b !important;  /* Rojo más oscuro e intenso */
    background-color: #ffeaea;   /* Fondo rojo muy claro para resaltar */
    border: 2px solid #e74c3c;   /* Borde rojo */
    padding: 12px 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 0.95rem;
    font-weight: bold;           /* Texto en negrita */
    min-height: 20px;
    display: none;               /* Oculto por defecto, se muestra con JS */
    text-align: center;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.2); /* Sombra sutil roja */
}

/* Cuando tiene contenido (se muestra) */
.error-message:not(:empty) {
    display: block;
    animation: shake 0.4s ease-in-out; /* Animación opcional de atención */
}

/* Animación de shake para llamar la atención */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.login-footer {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    color: #888;
    font-size: 0.85rem;
}

/* ================= HEADER Y NAVEGACIÓN ================= */
#app {
    padding-bottom: 40px;
}

header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

header h1 {
    color: white;
    margin-bottom: 15px;
    font-size: 1.8rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.user-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

#current-user {
    color: #ffd700;
    font-weight: 600;
    font-size: 1rem;
}

.logout-button {
    padding: 8px 20px;
    background: rgba(231, 76, 60, 0.8);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.logout-button:hover {
    background: #c0392b;
    transform: scale(1.05);
}

/* ================= INFORMACIÓN DE CUENTA ================= */
.account-panel {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    margin: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.account-panel h3 {
    margin-bottom: 15px;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Estado colapsado (inicial) */
.account-panel.collapsed {
    padding: 15px 20px;
}

.account-panel.collapsed .info-grid {
    display: none;
}

/* Estado expandido */
.account-panel:not(.collapsed) {
    padding: 20px;
}

.account-panel:not(.collapsed) .info-grid {
    display: grid;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
    animation: slideDown 0.3s ease;
}

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

.info-item {
    background: rgba(255, 255, 255, 0.15);
    padding: 12px 15px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    flex-wrap: wrap;
}

.info-item .icon {
    font-size: 1.3rem;
}

.info-item .label {
    opacity: 0.9;
    font-size: 0.85rem;
    font-weight: 600;
}

.info-item .value {
    font-weight: 600;
    margin-left: auto;
    word-break: break-word;
}

.toggle-info-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 10px;
}

.toggle-info-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.account-panel.collapsed {
    padding: 15px 20px;
}

.account-panel.collapsed .info-grid {
    display: none;
}

/* ================= BUSCADOR ================= */
.search-container {
    position: relative;
    max-width: 600px;
    margin: 20px auto;
    padding: 0 20px;
}

#search {
    width: 100%;
    padding: 15px 50px 15px 20px;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

#search:focus {
    outline: none;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
}

.clear-btn {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    background: #e74c3c;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: none;
    align-items: center;
    justify-content: center;
}

.clear-btn.visible {
    display: flex;
}

/* ================= BOTONES DE FILTRO ================= */
.button-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 0 20px;
    margin-bottom: 20px;
}

.filter-button {
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.filter-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.filter-button.adult-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

/* ================= CONTADOR DE CANALES ================= */
.channel-counter {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.channel-counter span {
    margin: 0 10px;
}

/* ================= GRUPOS DE CANALES ================= */
#channel-list {
    padding: 0 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.channel-group {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    margin-bottom: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.group-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    user-select: none;
}

.group-header:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.group-header h3 {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.group-count-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
}

.group-toggle {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.channel-group.collapsed .group-toggle {
    transform: rotate(-90deg);
}

.group-content {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    animation: slideDown 0.3s ease;
}

.channel-group.collapsed .group-content {
    display: none;
}

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

/* ================= BOTONES DE CANAL ================= */
.channel-button {
    background: #e6e6ff;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    transition: all 0.3s ease;
    position: relative;
    min-height: 180px;
    border: 2px solid transparent;
}

.channel-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.channel-button img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 10px;
    border-radius: 8px;
}

.channel-button h4 {
    font-size: 0.9rem;
    color: #333;
    text-align: center;
    margin-bottom: 8px;
    line-height: 1.3;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.channel-number {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ================= ESTRELLA DE FAVORITOS ================= */
.favorite-star {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 22px;
    cursor: pointer;
    color: #ddd;
    transition: all 0.3s ease;
    z-index: 10;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.favorite-star:hover {
    transform: scale(1.2);
}

.favorite-star.favorite {
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

/* ================= REPRODUCTOR DE VIDEO ================= */
#player, #iframe-player {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #000;
    width: 90%;
    max-width: 1000px;
    height: 80vh;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow: hidden;
    flex-direction: column;
}

.player-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-header h4 {
    margin: 0;
    font-size: 1.1rem;
    flex-grow: 1;
    text-align: center;
    padding: 0 20px;
}

.player-controls-top {
    display: flex;
    gap: 10px;
}

.player-controls-top button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-controls-top button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

#close-btn {
    background: #e74c3c !important;
}

#video-player, #iframe-element {
    flex-grow: 1;
    width: 100%;
    border: none;
}

/* ================= CONTROLES DE GRABACIÓN ================= */
#record-btn {
    background: rgba(231, 76, 60, 0.8) !important;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

#record-controls {
    position: absolute;
    bottom: 80px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    border-radius: 10px;
    display: none;
    gap: 10px;
}

#record-controls button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

#record-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

#start-record-btn { background: #27ae60 !important; }
#pause-record-btn { background: #f39c12 !important; }
#stop-record-btn { background: #e74c3c !important; }

#recording-indicator {
    display: none;
    position: absolute;
    top: 70px;
    left: 20px;
    width: 12px;
    height: 12px;
    background: #e74c3c;
    border-radius: 50%;
    animation: blink 1s infinite;
}

#recording-timer, #recording-size {
    display: none;
    position: absolute;
    left: 40px;
    color: white;
    font-family: monospace;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.6);
    padding: 5px 10px;
    border-radius: 5px;
}

#recording-timer { top: 65px; }
#recording-size { top: 90px; }

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

/* ================= MENSAJES Y ESTADOS ================= */
.loading-message, .error-message, .empty-message {
    text-align: center;
    padding: 40px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
}

.loading-message::before {
    content: "⏳ ";
}

.error-message::before {
    content: "❌ ";
}

.empty-message::before {
    content: "📭 ";
}

/* ================= RESPONSIVE ================= */
@media (max-width: 768px) {
    .login-box {
        padding: 30px 20px;
    }
    
    .button-container {
        gap: 8px;
    }
    
    .filter-button {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
    
    .group-content {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
        padding: 15px;
    }
    
    .channel-button {
        min-height: 160px;
        padding: 12px;
    }
    
    .channel-button img {
        width: 60px;
        height: 60px;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    #player, #iframe-player {
        width: 95%;
        height: 70vh;
    }
}

@media (max-width: 480px) {
    .group-content {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .channel-button h4 {
        font-size: 0.8rem;
    }
}

/* ================= SCROLLBAR PERSONALIZADO ================= */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* ================= OCULTAR ELEMENTOS ================= */
.hidden {
    display: none !important;
}

/* ================= GRUPO ACTIVO/RESALTADO ================= */
.channel-group.has-results {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    border: 2px solid #ffd700;
}

.channel-group.has-results .group-header {
    background: linear-gradient(135deg, #f39c12 0%, #e74c3c 100%);
}