/* style.css */
@font-face {
	font-family: 'Roboto';
	src: url('./fonts/roboto-regular.woff2') format('woff2');
	font-weight: 400;
}

@font-face {
	font-family: 'Material Icons';
	src: url('./fonts/material-icons.woff2') format('woff2');
}

:root {
	--bg-color: #0e0e11;
	--surface: #161d2b;
	--surface-variant: #21293a;
	--accent: #00f2fe;
	--accent-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
	--text-color: #f3f4f6;
	--text-muted: #9ca3af;
	--sidebar-width: 280px;
}

.material-icons {
	font-family: 'Material Icons';
	font-weight: normal;
	font-style: normal;
	display: inline-block;
	line-height: 1;
	text-transform: none;
	letter-spacing: normal;
	word-wrap: normal;
	white-space: nowrap;
	direction: ltr;
}

* {
    -webkit-user-select: none;
    user-select: none; /* Bloquea selección de texto molesta */
    -webkit-tap-highlight-color: transparent; /* Quita el cuadro azul al tocar en móviles */
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
/* Habilitar pegado y selección solo en campos de texto */
input, textarea {
    -webkit-user-select: text !important;
    user-select: text !important;
}

body {
	font-family: 'Roboto', sans-serif;
	background-color: var(--bg-color);
	color: var(--text-color);
	display: flex;
	height: 100vh;
	overflow: hidden;
    -webkit-font-smoothing: antialiased; /* Suavizado de fuentes solicitado */
    -moz-osx-font-smoothing: grayscale;
}

body.is-offline .live-badge {
    display: none !important; /* Nada está en vivo sin internet */
}

body.is-offline #video-container {
    border-color: #374151; /* Borde gris muerto */
    box-shadow: none;
}

.fs-trigger-zone {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 20%;
    width: 15px; 
    z-index: 2500;
    background: transparent;
    /* Evita bloquear clics accidentales si el cursor está en el borde */
    pointer-events: auto; 
}
/* ESTADO: MODO PANTALLA COMPLETA ACTIVADO */
body.mode-fullscreen .fs-trigger-zone {
    display: block;
}

/* Ocultar elementos innecesarios en FullScreen */
body.mode-fullscreen .top-bar,
body.mode-fullscreen .search-area,
body.mode-fullscreen .section-label,
body.mode-fullscreen .gallery {
    display: none !important;
}

/* El reproductor ocupa TODO */
body.mode-fullscreen .stage {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    padding: 0;
    margin: 0;
    z-index: 100;
}

body.mode-fullscreen #video-container {
    border-radius: 0;
    border: none;
    height: 100vh;
    aspect-ratio: auto;
}

/* Ajustes Sidebar en FullScreen */
body.mode-fullscreen #sidebar {
    position: fixed;
    height: 100vh;
    box-shadow: 20px 0 50px rgba(0,0,0,0.9);
}

/* Elementos internos del Sidebar para FullScreen */
body.mode-fullscreen #sidebar-logo-fs,
body.mode-fullscreen #btn-exit-fs-sidebar {
    display: flex !important;
}
body.mode-fullscreen .sidebar-search {
    padding: 5px 15px; /* Reducido de 0 15 15 15 */
    margin-top: 5px;   /* Margin superior menor */
    margin-bottom: 5px; /* Margin inferior menor */
}
body.mode-fullscreen .sidebar-header {
    padding: 10px 15px; /* Reducido de 20px */
}
body.mode-fullscreen .sidebar-search .search-field {
    height: 40px; /* Un poco más estilizado */
}
body.mode-fullscreen .sidebar-title {
    display: none; /* Ocultamos el titulo estático para usar el logo */
}

/* Asegurar que el Sidebar esté sobre el video */
body.mode-fullscreen #sidebar {
    z-index: 2600;
}

.container {
	width: 100%;
	max-width: 940px;
	/* Ancho máximo en escritorio */
	margin: 0 auto;
	/* Centrado automático */
}

/* SIDEBAR */
#sidebar {
	width: var(--sidebar-width);
	min-width: var(--sidebar-width);
	background-color: var(--surface);
	border-right: 1px solid rgba(255, 255, 255, 0.05);
	height: 100%;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	display: flex;
	flex-direction: column;
	z-index: 2000;
    /* Quitamos la sombra de aquí para controlarla por estado */
    box-shadow: none; 
}

body:not(.sidebar-hidden) #sidebar {
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
}

body.mode-fullscreen:not(.sidebar-hidden) #sidebar {
    /* Sombra más profunda para que resalte sobre el video */
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.9);
}

body.sidebar-hidden #sidebar {
	margin-left: calc(var(--sidebar-width) * -1);
    box-shadow: none !important; /* Eliminación total garantizada */
    border-right-color: transparent; /* Opcional: oculta también el borde */
}

.sidebar-header {
	padding: 20px;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.sidebar-header .icon-btn i {
	font-size: 28px;
}

.active-channel {
	border-color: var(--accent) !important;
	background: rgba(0, 242, 254, 0.08) !important;
	box-shadow: 0 0 20px rgba(0, 242, 254, 0.25);
}

.sidebar-title {
	color: var(--accent);
	font-size: 0.95rem;
	/* Sincronizado con section-label */
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 2px;
}
.sidebar-section-title {
    font-size: 0.7rem;
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 15px 15px 5px 15px;
    opacity: 0.7;
}
.backdrop {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.7);
	z-index: 1500;
	opacity: 0;
	/* CRUCIAL: Si no es visible, no debe capturar clics */
	pointer-events: none; 
	transition: opacity 0.4s ease;
}
body:not(.sidebar-hidden) .backdrop {
    opacity: 1;
    pointer-events: auto;
}
#channel-list {
	flex: 1;
	overflow-y: auto;
	padding: 10px;
	scrollbar-width: auto;
	scrollbar-color: #21293a #161d2b;

}
#channel-list .section-label {
    margin: 10px 0 5px 10px;
    color: var(--accent);
    opacity: 0.8;
}
.channel-item {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	padding: 12px 15px;
	border-radius: 16px;
	cursor: pointer;
	margin: 4px 8px;
	transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
	border: 1px solid transparent;
	background: transparent;
}

.channel-item:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

.channel-item span {
	flex: 1;
	font-size: 1.1rem;
	/* Un poco más grande como en la foto */
	font-weight: 400;
	color: var(--text-color);
}

.channel-item.active-channel {
	background: rgba(0, 242, 254, 0.08) !important;
	border-color: var(--accent) !important;
	box-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
	color: var(--accent);
}

.channel-item.active-channel span {
	font-weight: 700;
}

/* En Smart TV, los elementos con foco deben estar por encima para que se vea el anillo */
.channel-item:focus {
    z-index: 10;
    position: relative;
}

/* Estilo especial para el canal activo con foco */
.channel-item.active-channel:focus {
    background: rgba(0, 242, 254, 0.2) !important;
    border-color: var(--accent);
}

.channel-item img {
	width: 32px;
	height: 32px;
	border-radius: 8px;
	margin-right: 15px;
	object-fit: contain;
	background: #000;
}

/* MAIN */
main {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
	height: 100%;
	overflow-x: hidden;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	scroll-behavior: smooth;
}

.top-bar {
	display: grid;
	/* 60px para los botones laterales y el centro flexible */
	grid-template-columns: 60px 1fr 60px;
	align-items: center;
	padding: 0 10px;
	height: 64px;
	background: var(--bg-color);
}

.top-bar-right {
	display: flex;
	justify-content: flex-end;
	align-items: center;
}

.top-bar-right .icon-btn i {
	font-size: 28px;
	/* Tamaño grande solicitado */
}


.app-logo-box {
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.app-logo-box i {
	font-size: 28px;
	/* Tamaño solicitado */
	margin-right: 8px;
	background: var(--accent-gradient);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.4));
}

.app-logo-box h1 {
	font-size: 22px;
	/* Tamaño solicitado */
	font-weight: 500;
	margin: 0;
	letter-spacing: -0.5px;
}

/* Ofuscación visual mínima */
h1 span { color: inherit; font-weight: inherit; }

/* Resaltado para botones y canales cuando tienen el foco del control remoto */
.icon-btn:focus,
.md3-btn-primary:focus,
.md3-btn-secondary:focus,
.multi-source-btn:focus,
#btn-nav-menu:focus {
    outline: none !important;
    box-shadow: none !important;
    transform: none !important;
    background-color: transparent; /* O el color original que tengan */
}
.channel-item:focus,
.card:focus {
    outline: none;
    background-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 0 0 2px var(--accent);
    transform: scale(1.02);
    z-index: 10;
}


/* Iconos de botones uniformes */
.icon-btn i {
	font-size: 26px;
	/* Tamaño equilibrado para MD3 */
}

.icon-btn {
	background: transparent;
	border: none;
	color: var(--text-color);
	cursor: pointer;
	padding: 10px;
	border-radius: 50%;
	display: flex;
	transition: background 0.3s ease;
}

.icon-btn:hover {
	background-color: rgba(255, 255, 255, 0.1);
	/* Color destacado sugerido */
}

body:not(.sidebar-hidden) .top-bar .icon-btn,
body:not(.sidebar-hidden) .top-bar .app-logo-box {
	opacity: 0 !important;
	pointer-events: none !important;
	transition: opacity 0.3s ease;
}

/* REPRODUCTOR */
.stage {
	width: 100%;
	max-width: 1000px;
	margin: 0 auto;
	margin-bottom: 5px;
	padding: 0 15px;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#native-video {
	width: 100%;
	height: 100%;
	background: #000;
	object-fit: contain;
	/* Mantiene la proporción del canal */
}

#video-container {
	width: 100%;
	aspect-ratio: 16 / 9;
	background: #000;
	border-radius: 28px;
	overflow: hidden;
	position: relative;
	/* Borde inicial gris sutil */
	border: 2px solid rgba(255, 255, 255, 0.05);
	transition: all 0.5s ease;
	z-index: 50; /* Por debajo del sidebar pero accesible */
    pointer-events: auto;
}

body.video-active #video-container {
	border-color: rgba(0, 242, 254, 0.3);
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

#player,
#iframe-player {
	width: 100% !important;
	height: 100% !important;
	border: none;
	pointer-events: auto;
}

#modal-settings hr {
	margin: 15px 0;
	border: none;
	border-top: 1px solid var(--border-color);
}

.divider {
    margin: 15px 0;
    border: none;
    border-top: 1px solid var(--border-color);
}

.hidden { display: none !important; }
.v-hidden { visibility: hidden !important; pointer-events: none; }

/* SEARCH & GALLERY */
.search-area {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 20px 0;
}
.search-field {
	background: var(--surface);
	border-radius: 30px;
	display: flex;
	align-items: center;
	padding: 0 20px;
	border: 1px solid rgba(255, 255, 255, 0.08);
}

.search-field:focus-within {
    border-color: var(--accent);
    background-color: var(--surface-variant);
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
}

.search-field input {
	flex: 1;
	background: none;
	border: none;
	padding: 15px 12px;
	color: var(--text-color);
	outline: none;
	font-size: 1rem;
}

.search-field i {
	color: var(--text-muted);
}
.main-search-wrapper {
    flex: 2;
    min-width: 240px;
    height: 48px; /* Altura estándar */
}

.gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
	gap: 15px;
	padding-bottom: 20px;
}

.card {
	position: relative;
	/* Fundamental para el posicionamiento del botón */
	background: var(--surface);
	border-radius: 24px;
	padding: 20px 10px;
	text-align: center;
	cursor: pointer;
	transition: all 0.3s ease;
	border: 1px solid transparent;
}

.card:hover {
	background: var(--surface-variant);
	transform: translateY(-5px);
	border-color: rgba(0, 242, 254, 0.2);
}

.card.active-channel {
	border-color: var(--accent);
	box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
	background: var(--surface-variant);
}

.card-img-wrapper {
	position: relative;
	display: inline-block;
	margin-bottom: 12px;
}

.card img {
	width: 64px;
	height: 64px;
	object-fit: contain;
	background: #000;
	border-radius: 14px;
}

.card h3 {
	font-size: 0.85rem;
	font-weight: 400;
	color: var(--text-muted);
	transition: 0.3s;
}

/* INTERACCIÓN REACTIVA: Resaltado cuando el Popover está abierto */
/* Si la tarjeta tiene un botón cuyo popover está abierto, la iluminamos */
.card:has(.multi-source-btn:popover-open) {
	border-color: var(--accent);
	background: var(--surface-variant);
	box-shadow: 0 0 20px rgba(0, 242, 254, 0.2);
	transform: scale(1.02);
}

/* El botón de número también cambia cuando el popover está abierto */
.multi-source-btn:popover-open {
	background: #fff !important;
	color: #000 !important;
	transform: scale(1.1);
}

/* Resaltado para el menú principal (Botón de 3 puntos) */
#btn-nav-menu:popover-open {
	background: rgba(255, 255, 255, 0.1);
	color: var(--accent);
}

/* Resaltado para el submenú de Enlaces */
.menu-item:has(+ #links-submenu:popover-open),
#btn-links:popover-open {
	background: rgba(0, 242, 254, 0.15) !important;
	color: var(--accent);
}

.active-channel h3 {
	color: var(--accent);
	font-weight: 700;
}

.live-badge {
	position: absolute;
	bottom: -6px;
	/* Ajuste leve */
	left: 50%;
	transform: translateX(-50%);
	/* Centrado perfecto horizontal */
	background: #ff0055;
	color: white;
	font-size: 9px;
	font-weight: 900;
	padding: 3px 10px;
	border-radius: 20px;
	/* Más redondeado MD3 */
	z-index: 150;
	/* Delante del logo */
	box-shadow: 0 0 15px rgba(255, 0, 85, 0.6);
	text-transform: uppercase;
	white-space: nowrap;
	display: none;
	/* Se activa con .active-channel */
}

.active-channel .live-badge {
	display: block;
	animation: pulse 1.5s infinite;
}

@keyframes pulse {
	0% {
		opacity: 1;
	}

	50% {
		opacity: 0.6;
	}

	100% {
		opacity: 1;
	}
}

/* El botón invisible que dispara el menú */
.multi-source-btn {
	all: unset;
	cursor: pointer;
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 110;
	/* Por encima de casi todo */
	background: var(--accent);
	/* Color turquesa para destacar */
	color: var(--bg-color);
	border-radius: 8px;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 900;
	font-size: 0.85rem;
	box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
	transition: transform 0.2s;
}

.multi-source-btn:hover {
	transform: scale(1.1);
}

/* MENU DE FUENTES (Popover) */
.sources-menu {
	position: absolute;
	position-area: bottom center;
	position-try-fallbacks: top center, left center, right center,
	--bottom-span-left, --bottom-span-right, --top-span-left, --top-span-right, --left-span-top;
	inset: auto;
	border: 1px solid rgba(255, 255, 255, 0.2);
	background: var(--surface-variant);
	border-radius: 16px;
	padding: 8px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
	color: white;
	min-width: 160px;
}

.sources-menu:popover-open {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

/* REGLAS DE POSICIÓN BASADAS EN SPAN */
@position-try --left-span-top { position-area: left span-top; }
@position-try --bottom-span-left { position-area: bottom span-left; }
@position-try --bottom-span-right { position-area: bottom span-right; }
@position-try --top-span-left { position-area: top span-left; }
@position-try --top-span-right { position-area: top span-right; }

/* --- ESTILO GLOBITO (TOOLTIP DINÁMICO) --- */
.dynamic-tooltip {
    position: absolute;
    background-color: var(--accent);
    color: var(--bg-color);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    z-index: 5000;
    animation: tooltip-pop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-bottom: 12px; /* Margen solicitado para alejar del textarea */
}

/* Flecha del globo */
.dynamic-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--accent) transparent transparent transparent;
}

@keyframes tooltip-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.8); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Sidebar Search */
.sidebar-search {
	padding: 0 15px 15px 15px;
}

.sidebar-search .search-field {
	background: var(--surface-variant);
	border-radius: 12px;
	height: 42px;
}

.sidebar-search .search-field input {
	font-size: 0.9rem;
}
.sidebar-search .md3-select {
    border-radius: 12px;
    height: 42px;
    font-size: 0.8rem;
    background: var(--surface-variant);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Etiquetas de sección */
.section-label {
	font-size: 0.95rem;
	/* Tamaño base */
	font-weight: 500;
	margin: 20px 0 15px 5px;
	color: #9ca3af;
	/* Gris */
	text-transform: uppercase;
	letter-spacing: 1px;
}

/* Icono de Favorito en Sidebar */
.star-icon {
	margin-left: auto;
	font-size: 24px !important;
	color: var(--text-muted);
	opacity: 0.6;
	transition: 0.2s;
}

.star-icon:hover {
	color: var(--accent);
}

.star-icon.is-fav {
	color: #ffca28;
	opacity: 1;
}

.channel-item:hover .star-icon {
	opacity: 1;
}

/* Truncar texto largo en sidebar */
.truncate {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 150px;
	flex: 1;
	/* Para empujar la estrella */
}

/* Esconder secciones vacías */
.hidden {
	display: none !important;
}

/* --- MODAL SETTINGS MD3 --- */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.8);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 3000;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.modal-overlay.active {
	opacity: 1;
	pointer-events: auto;
}

.modal-content {
	background: var(--surface);
	width: 400px;
	max-width: 100%;
	border-radius: 28px;
	padding: 24px;
	border: 1px solid var(--border-color);
	color: var(--text-color);
}

.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
}

.modal-header h2 {
	font-size: 1.2rem;
	font-weight: 500;
}

.setting-group-title {
	font-size: 0.85rem;
	color: var(--accent);
	text-transform: uppercase;
	letter-spacing: 1px;
	margin: 15px 0 10px 0;
	font-weight: 700;
}

.divider {
	border: none;
	border-top: 1px solid var(--border-color);
	margin: 10px 0;
}

.setting-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 0;
}

.menu-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.version-badge {
    background-color: var(--surface-variant);
    padding: 2px 8px;
    border-radius: 6px;
    color: var(--accent);
    font-family: 'Roboto Mono', monospace;
    border: 1px solid rgba(255,255,255,0.05);
}

/* Inputs MD3 */
.md3-input {
	background: var(--surface-variant);
	border: none;
	color: white;
	padding: 8px;
	border-radius: 8px;
	width: 60px;
	text-align: center;
	font-family: inherit;
}

/* Checkbox estilo Switch MD3 simple */
.switch {
	position: relative;
	display: inline-block;
	width: 45px;
	height: 24px;
}

.switch input {
	opacity: 0;
	width: 0;
	height: 0;
}

.slider {
	position: absolute;
	cursor: pointer;
	inset: 0;
	background-color: #444;
	transition: .4s;
	border-radius: 24px;
}

.slider:before {
	position: absolute;
	content: "";
	height: 18px;
	width: 18px;
	left: 3px;
	bottom: 3px;
	background-color: white;
	transition: .4s;
	border-radius: 50%;
}

input:checked+.slider {
	background-color: var(--accent);
}

input:checked+.slider:before {
	transform: translateX(21px);
}

/* Ajuste del buscador dentro de la sección All */
#sec-all .search-area {
	margin-top: 10px;
	margin-bottom: 20px;
}
#sec-all .group-filter {
    background: var(--surface);
    padding: 0 15px;
    font-weight: 500;
}
.group-select-wrapper {
    flex: 1;
    min-width: 180px;
    height: 48px;
    position: relative;
}
.md3-select-standard {
    width: 100%;
    height: 100%;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    color: var(--text-color);
    padding: 0 40px 0 20px; /* Espacio para el icono de flecha */
    font-size: 1rem;
    outline: none;
    cursor: pointer;
    appearance: none; /* Quita el estilo por defecto del sistema */
    -webkit-appearance: none;
    transition: all 0.3s ease;
}
.select-arrow {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
}
.search-field:focus-within,
.md3-select-standard:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.2);
    background-color: var(--surface-variant);
}

/* REAJUSTE DE DIALOG NATIVO */
dialog {
	margin: auto;
	background: transparent;
	border: none;
	padding: 0;
	max-width: 90%;
	max-height: 90%;
}

dialog::backdrop {
	background: rgba(0, 0, 0, 0.8);
	backdrop-filter: blur(4px);
	/* Opcional: añade profundidad */
}

/* POPOVER SUBMENÚ DE ENLACES */
#btn-links {
	anchor-name: --anchor-links;
	/* Definimos el ancla para el botón Enlaces */
}

#nav-menu,
#links-submenu {
	position: absolute;
	border: 2px solid rgba(255, 255, 255, 0.15);
	/* Borde que combina */
	background: var(--surface-variant);
	border-radius: 16px;
	padding: 8px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
	color: white;
}

/* SUBMENÚ DE ENLACES: Posicionamiento Blindado */
#links-submenu {
	position-anchor: --anchor-links;
	position-area: left span-bottom;
	position-try-fallbacks: --left-span-top, bottom center, top center;
	margin: 1px;
	min-width: 160px;
	text-decoration: none;
	border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Evitar que el submenú se oculte al interactuar con el menú principal */
#links-submenu:popover-open {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

/* POPOVER MENU & ANCHORING */
#btn-nav-menu {
	anchor-name: --menu-anchor;
}

#nav-menu {
	anchor-name: --menu-anchor;
	position-anchor: --menu-anchor;
	position-area: bottom center;
	position-try-fallbacks: --bottom-span-left;
	margin-top: 2px;
	min-width: 180px;
}

#nav-menu:popover-open {
	display: block;
	animation: fadeSlide 0.2s ease;
}

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

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

.menu-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.menu-item {
	background: transparent;
	border: none;
	color: white;
	padding: 12px 16px;
	border-radius: 12px;
	display: flex;
	align-items: center;
	gap: 12px;
	cursor: pointer;
	transition: 0.2s;
	font-size: 0.95rem;
	text-align: left;
	text-decoration: none !important;
}

.menu-item:hover {
	background: rgba(255, 255, 255, 0.1);
}

.menu-item i {
	font-size: 20px;
	color: var(--accent);
}

.menu-item .arrow-icon {
	margin-left: auto;
	font-size: 18px;
	color: var(--text-muted);
}

.version-item {
	cursor: default;
	pointer-events: none;
	opacity: 0.8;
}

hr {
	border: none;
	border-top: 1px solid rgba(255, 255, 255, 0.1);
	margin: 4px 0;
}

/* CONVERSOR TABS */
.converter-box section {
    width: 100%;
}

.tabs-header {
    display: flex;
    width: 100%;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding: 0; /* Limpiar padding previo */
}

.tab-btn {
    flex: 1; /* Anchos flexibles y equitativos */
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 12px 5px; /* Espacio vertical */
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    border-bottom: 3px solid transparent; /* Borde más grueso para resaltar */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(0, 242, 254, 0.05);
}

.tab-stack {
    display: grid;
    grid-template-rows: auto 1fr; /* Fila 1: Switch (si existe), Fila 2: El resto */
    grid-template-columns: 1fr;
    min-height: 250px;
    gap: 8px;
}

.tab-content {
    grid-area: 1 / 1; /* Ambas pestañas en la misma celda */
    display: flex;
    flex-direction: column;
    width: 100%;
    opacity: 0;
    pointer-events: none;
    visibility: hidden; /* Mantiene el tamaño para evitar que el dialog se encoja */
    transition: none; /* Instantáneo */
}

.tab-content.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.tab-content button:disabled {
	opacity: 0.4;
	pointer-events: none;
	cursor: not-allowed;
	filter: grayscale(1);
}

/* GRUPOS DE PASOS */
.group-input,
.group-output {
	display: flex;
	flex-direction: column;
	gap: 8px;
	animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(5px);
	}

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

/* ARQUITECTURA DE TRIPLE FILA v53 */
#box-mode-toggle { grid-row: 1; grid-column: 1; }
#box-kid-key, #box-text-area, #box-output { 
    grid-row: 2; 
    grid-column: 1; 
    display: flex; 
    flex-direction: column; 
}

/* ESTADO ELÁSTICO (v57): Ocupa todo el alto (Fila 1 y 2) */
.full-height {
    grid-row: 1 / 3 !important;
    display: flex !important;
    flex-direction: column;
}

/* Ocultación visual para el stack sin perder espacio */
.invisible {
    opacity: 0;
    pointer-events: none;
    display: none; /* Usamos none para que el grid colapse si no hay otro elemento en la fila */
}

.md3-input-full {
	width: 100%;
	background: var(--bg-color);
	border: 2px solid transparent;
	outline: none;
	color: white;
	padding: 10px;
	margin: 10px 0px; 
	border-radius: 12px;
	font-size: 1rem;
	font-family: monospace;
}

/* TEXTAREAS SIN ROWS (Controladas por el Grid) */
.md3-textarea-auto {
    flex: 1;
    width: 100%;
    field-sizing: content; /* Para navegadores modernos */
    background: var(--bg-color);
    border: 2px solid transparent;
    outline: none;
    color: white;
    padding: 12px;
    margin: 8px 0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: monospace;
    resize: none;
}
.md3-input-full:focus,
.md3-textarea-auto:focus { border-color: var(--accent); }

.md3-button-accent {
	background: var(--accent);
	color: var(--bg-color);
	border: none;
	padding: 12px;
	border-radius: 20px;
	font-size: 0.9rem;
	font-weight: 700;
	cursor: pointer;
	margin: 10px 0;
}

.action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 15px; /* Un poco más de margen para separar del stack */
    width: 100%;
}

.md3-btn-primary, .md3-btn-secondary {
    flex: 1; /* Todos crecen por igual */
    padding: 12px 5px;
    border-radius: 20px;
    font-size: 0.85rem; /* Fuente ligeramente menor para asegurar que quepan leyendas largas */
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-align: center;
    white-space: nowrap;
}

/* Copiar (Color Acento) */
.md3-btn-primary {
    background: var(--accent);
    color: var(--bg-color);
}

/* Borrar (Color Secundario / Gris con Borde) */
.md3-btn-secondary {
    background: var(--surface-variant);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.md3-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--text-color); /* Resaltado de borde solicitado */
}
.md3-btn-primary:hover { filter: brightness(1.1); }

.input-label {
    font-size: 0.8rem;
    color: var(--accent);
    display: block;
    min-height: 1.2rem; /* Reserva el espacio para que el textarea no salte */
margin-left: 12px;
}
.label-spacing { margin-top: 10px; }

.res-size { min-height: 180px; field-sizing: content; }

/* SCROLLBARS GLOBALES (Firefox & Modern Chrome) */
#channel-list,
main,
.md3-textarea,
dialog {
	scrollbar-color: #21293a #161d2b;
	scrollbar-width: thin;
}

/* SCROLLBARS ESPECÍFICOS PARA CHROME/SAFARI/EDGE */
::-webkit-scrollbar {
	width: 8px;
}

::-webkit-scrollbar-track {
	background: #161d2b;
}

::-webkit-scrollbar-thumb {
	background: #21293a;
	border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
	background: var(--accent);
}

/* STACK DE LOGOS (CSS GRID) */
.logo-stack {
	display: grid;
	place-items: center;
	width: 64px;
	height: 64px;
	margin: 0 auto 12px auto;
	background-color: #000;
	border-radius: 14px;
	overflow: hidden;
	position: relative;
}

.logo-stack>* {
	grid-area: 1 / 1;
}

.logo-stack .fallback-icon {
	font-size: 30px;
	color: var(--text-muted);
	opacity: 0.5;
	z-index: 1;
	transition: opacity 0.2s ease;
}

/* La imagen es invisible hasta que carga para evitar el icono roto */
.logo-stack .actual-logo {
	width: 100%;
	height: 100%;
	object-fit: contain;
	z-index: 2;
	opacity: 0;
	transition: opacity 0.3s ease;
}

/* Si la imagen carga, se vuelve visible */
.logo-stack .actual-logo.loaded {
	opacity: 1;
}

/* Ocultar el icono de fondo SOLO si la imagen cargó (evita verse tras logos transparentes) */
.logo-stack:has(.loaded) .fallback-icon {
	opacity: 0;
}

/* Icono que está "debajo" */
.fallback-icon {
	position: absolute;
	font-size: 32px;
	color: var(--surface-variant);
	/* Color discreto */
	z-index: 1;
}

.channel-item .logo-stack {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    margin-right: 15px; /* Margen externo para separar del texto */
    border-radius: 8px;
    background: #000;
    display: grid;
    place-items: center; /* Centrado absoluto interno */
    overflow: hidden;
}

.channel-item .logo-stack img,
.channel-item .logo-stack .actual-logo {
    margin: 0 !important; 
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
}

.channel-item .fallback-icon {
	font-size: 18px;
}

.logo-stack img, .logo-stack .actual-logo {
    transition: opacity 0.2s ease-in-out;
}

/* Resaltado del Modal Conversor */
.converter-box {
    min-width: 320px; /* Ancho mínimo de seguridad */
    width: 420px;
    max-width: 95%;
    border-radius: 28px !important;
    padding: 20px;
}

#ck-text-input {
    min-height: 100px;
    font-size: 0.9rem;
}

/* Selector Radio MD3 */
.format-selector {
    display: flex;
    background: rgba(255,255,255,0.03);
    border-radius: 16px;
    padding: 4px;
    margin-bottom: 20px;
    gap: 2px;
}

.radio-item {
    flex: 1;
    display: flex;
    flex-direction: column; /* Cambiamos a columna para ahorrar ancho en móvil */
    align-items: center;
    justify-content: center;
    gap: 6px; /* Espacio entre radio y texto */
    padding: 8px 2px;
    cursor: pointer;
    position: relative;
}

.radio-item input { display: none; }

/* El círculo exterior */
.radio-circle {
    width: 22px;
    height: 22px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    position: relative;
    transition: border-color 0.3s ease;
    flex-shrink: 0;
}

/* El punto interior */
.radio-circle::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Estados activos del Radio */
.radio-item input:checked + .radio-circle {
    border-color: var(--accent);
}

.radio-item input:checked + .radio-circle::after {
    transform: translate(-50%, -50%) scale(1);
}

.radio-item span {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.radio-item input:checked ~ span {
    color: var(--accent);
}

/* BOTÓN PEGAR MINI EN LABELS */
.btn-paste-mini {
    font-size: 18px !important;
    vertical-align: middle;
    margin-left: 8px;
    cursor: pointer;
    color: var(--accent);
    opacity: 0.7;
}
.btn-paste-mini:hover { opacity: 1; }

.md3-select {
    background: var(--surface-variant);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
}

.md3-select:focus {
    border-color: var(--accent);
}

/* SWITCH CENTRADO v45 */
.toggle-group-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    width: 100%;
}

.toggle-label {
    font-size: 0.9rem; /* Tamaño solicitado */
    color: var(--text-color);
    font-weight: 500;
}

#box-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    transition: none !important; /* Elimina cualquier retraso */
}

#box-mode-toggle.v-hidden {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none;
}

/* VARIANTES DEL GLOBITO (v56) */
.dynamic-tooltip.error-tooltip {
    background-color: #ff5252; /* Rojo Material Design */
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 15px rgba(255, 82, 82, 0.4);
}

/* Flecha roja para el error */
.dynamic-tooltip.error-tooltip::after {
    border-color: #ff5252 transparent transparent transparent;
}

/* Animación un poco más "vibrante" para el error */
.error-tooltip {
    animation: tooltip-shake 0.3s ease-in-out;
}

@keyframes tooltip-shake {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(0) translateX(-4px); }
    75% { transform: translateY(0) translateX(4px); }
}

/* BANNER DE INSTALACIÓN MD3 */
.menu-section-label {
    font-size: 0.7rem;
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 8px 16px 4px 16px;
    opacity: 0.8;
}

#installButton {
    margin: 8px auto;
    width: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    padding: 10px;
    font-size: 0.85rem;
}

.ios-prompt {
    padding: 12px;
    background-color: var(--surface);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    font-size: 0.8rem;
    margin: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ios-prompt p { line-height: 1.4; color: var(--text-color); }
.ios-prompt strong { color: var(--accent); }

@media (max-width: 768px) {
	#sidebar {
		position: fixed;
	}

	body:not(.sidebar-hidden) .backdrop {
		opacity: 1;
		pointer-events: auto;
	}

	.converter-box {
        width: 95% !important;
        max-width: 95% !important;
        border-radius: 0; /* Estilo Full Screen en móvil opcional */
	}
    .md3-btn-primary, .md3-btn-secondary {
        font-size: 0.75rem; /* Ajuste extremo para móviles muy pequeños */
    }
	
	.tabs-header {
        margin: 0 0 20px 0;
	}

	.gallery {
		grid-template-columns: repeat(2, 1fr);
		margin-bottom: 0;
		padding-bottom: 5px;
		padding: 0 10px 10px 10px;
		gap: 10px;
	}

	.stage {
		padding: 0 10px;
	}
}

@media (max-width: 600px) {
    .search-area {
        flex-direction: column;
        align-items: stretch !important;
    }
    #sec-all .group-filter {
        width: 100%;
    }
}

@media (min-width: 400px) {
    .radio-item { flex-direction: row; gap: 8px; }
    .radio-item span { font-size: 0.85rem; }
}
