/* --- SISTEMA DE DISEÑO & VARIABLES --- */
:root {
  --bg-color: #0b0a16;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.2);
  
  --primary: #9d4edd;
  --primary-glow: rgba(157, 78, 221, 0.4);
  --secondary: #00f5d4;
  --secondary-glow: rgba(0, 245, 212, 0.4);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #111827;
  
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --glass-blur: blur(16px);
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-fast: all 0.15s ease;
}

/* --- RESET & ESTILOS GLOBALES --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* --- ORBES DE GRADIENTE DE FONDO --- */
.background-orbs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.25;
  animation: float 20s infinite alternate ease-in-out;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  top: -10%;
  left: -10%;
}

.orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
  bottom: -15%;
  right: -10%;
  animation-duration: 25s;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #3a0ca3 0%, transparent 70%);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.15;
  animation-duration: 18s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(50px, 30px) scale(1.1);
  }
}

/* --- CABECERA (HEADER) --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 10, 22, 0.7);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--primary-glow);
}

.logo-icon i {
  color: var(--text-dark);
  font-size: 1.1rem;
  margin-left: 2px;
}

.app-title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #e9ecef);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-title span {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 400;
}

.controls-area {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-grow: 1;
  justify-content: flex-end;
  max-width: 800px;
}

/* --- BUSCADOR --- */
.search-box {
  position: relative;
  flex-grow: 1;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  display: flex;
  align-items: center;
  transition: var(--transition-smooth);
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
  background: rgba(255, 255, 255, 0.05);
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.8rem 2.8rem;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.clear-btn {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition-fast);
}

.clear-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* --- DESPLEGABLE / SELECT --- */
.select-container {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  display: flex;
  align-items: center;
  transition: var(--transition-smooth);
  width: 260px;
}

.select-container:focus-within {
  border-color: var(--secondary);
  box-shadow: 0 0 15px var(--secondary-glow);
  background: rgba(255, 255, 255, 0.05);
}

.select-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.select-container select {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.8rem;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  cursor: pointer;
  appearance: none;
}

/* Flecha personalizada */
.select-container::after {
  content: '\f107';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  position: absolute;
  right: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Estilo para las opciones */
.select-container select option {
  background-color: #141226;
  color: var(--text-main);
}

/* --- CONTENIDO PRINCIPAL --- */
.main-content {
  flex-grow: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

/* --- BARRA DE ESTADO --- */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.status-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.badge {
  background: linear-gradient(135deg, rgba(157, 78, 221, 0.2), rgba(0, 245, 212, 0.2));
  border: 1px solid rgba(157, 78, 221, 0.3);
  padding: 0.25rem 0.75rem;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--secondary);
}

.action-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-hint i {
  color: var(--primary);
}

/* --- GRID DE CANALES --- */
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

/* --- TARJETA DE CANAL (DISEÑO PREMIUM) --- */
.channel-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  transition: var(--transition-smooth);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.channel-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  padding: 1.5px;
  background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.15) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Efectos al hacer hover */
.channel-card:hover {
  transform: translateY(-6px);
  background: var(--bg-card-hover);
  border-color: var(--primary);
  box-shadow: 0 12px 30px var(--primary-glow);
}

/* Contenedor de la Imagen */
.card-image-wrapper {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 60%;
  position: relative;
  margin-bottom: 0.75rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.channel-logo {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
  transition: var(--transition-smooth);
}

.channel-card:hover .channel-logo {
  transform: scale(1.08);
}

/* Placeholder */
.logo-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  text-transform: uppercase;
}

/* Info del canal en tarjeta */
.channel-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 2;
}

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

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

/* Botón copiar en tarjeta */
.copy-hover-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(11, 10, 22, 0.85);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8);
  transition: var(--transition-smooth);
  color: var(--secondary);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.channel-card:hover .copy-hover-badge {
  opacity: 1;
  transform: scale(1);
}

.channel-card:active {
  transform: translateY(-2px) scale(0.98);
}

/* --- SPINNER DE CARGA --- */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1.25rem;
  width: 100%;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(157, 78, 221, 0.1);
  border-top-color: var(--primary);
  border-right-color: var(--secondary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

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

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

/* --- SIN RESULTADOS --- */
.no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6rem 2rem;
  gap: 0.75rem;
}

.no-results i {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.no-results h3 {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 600;
}

.no-results p {
  color: var(--text-muted);
  max-width: 320px;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.sentinel {
  height: 50px;
  width: 100%;
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  background: rgba(11, 10, 22, 0.85);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(0, 245, 212, 0.3);
  padding: 1rem 1.5rem;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 245, 212, 0.15);
  pointer-events: auto;
  min-width: 300px;
  max-width: 450px;
  transform: translateX(120%);
  animation: slideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slideIn {
  to {
    transform: translateX(0);
  }
}

.toast.removing {
  animation: slideOut 0.3s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
}

@keyframes slideOut {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

.toast-icon {
  color: var(--secondary);
  font-size: 1.25rem;
}

.toast-content {
  flex-grow: 1;
}

.toast-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}

.toast-message {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

/* --- MODAL AUXILIAR --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 7, 16, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: rgba(19, 17, 38, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 500px;
  padding: 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: zoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes zoomIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

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

.modal-header h3 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
}

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.close-modal-btn:hover {
  color: var(--text-main);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-channel-name {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--primary);
}

.link-input-group {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.link-input-group input {
  flex-grow: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 0.8rem 1rem;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.modal-copy-btn {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  color: var(--text-dark);
  font-weight: 700;
  padding: 0 1.25rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-copy-btn:hover {
  opacity: 0.9;
  box-shadow: 0 0 10px rgba(0, 245, 212, 0.4);
}

/* --- FOOTER --- */
.app-footer {
  border-top: 1px solid var(--border-color);
  padding: 1.5rem;
  text-align: center;
  background: rgba(11, 10, 22, 0.4);
  margin-top: auto;
}

.footer-content p {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* --- RESPONSIVIDAD --- */
@media (max-width: 768px) {
  .app-header {
    padding: 1rem;
  }
  
  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .controls-area {
    flex-direction: column;
    align-items: stretch;
    max-width: none;
  }
  
  .search-box, .select-container {
    max-width: none;
    width: 100%;
  }
  
  .main-content {
    padding: 1rem;
  }
  
  .channels-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
  }
  
  .channel-card {
    border-radius: 14px;
    padding: 0.75rem;
  }
  
  .channel-name {
    font-size: 0.85rem;
  }
  
  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
  
  .toast {
    min-width: 0;
    width: 100%;
  }
}
