/* ══════════════════════════════════════════════════════════════════════
   SUPER PLAY IPTV MATCHER PRO — STYLESHEET
   Modern Glassmorphism Dark Theme & Mobile-First Responsive Design
   ══════════════════════════════════════════════════════════════════════ */

:root {
  --bg-main: #090d16;
  --bg-surface: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-glass: rgba(15, 23, 42, 0.85);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(16, 185, 129, 0.35);

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-indigo: #6366f1;
  --accent-rose: #f43f5e;
  --accent-amber: #f59e0b;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(99, 102, 241, 0.05) 0px, transparent 60%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 75px; /* Espacio para navegación móvil */
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }
}

/* ── SCROLLBAR PERSONALIZADO ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-emerald);
}

/* ── HEADER ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-glass);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px var(--accent-emerald-glow);
  font-size: 16px;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--accent-cyan);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── CONTENEDOR PRINCIPAL ── */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
}

/* ── VISTAS / TABS ── */
.tab-view {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

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

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

/* ── NAVEGACIÓN MÓVIL INFERIOR ── */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-around;
  padding: 8px 6px;
}

@media (min-width: 768px) {
  .mobile-nav {
    display: none;
  }
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.nav-item.active {
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
}

/* ── NAVEGACIÓN ESCRITORIO ── */
.desktop-nav {
  display: none;
  gap: 6px;
}

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
  }
}

.desktop-nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.desktop-nav-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.desktop-nav-btn.active {
  color: #fff;
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
}

/* ── TARJETAS Y CONTENEDORES GLASS ── */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.glass-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── ESTADÍSTICAS EN GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-box {
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.stat-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-emerald);
  font-family: monospace;
}

.stat-lbl {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 2px;
}

/* ── BOTONES ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-emerald-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #34d399, #10b981);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #1e293b;
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-secondary:hover {
  background: #334155;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-cyan), #0284c7);
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-cyan-glow);
}
.btn-accent:hover {
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ── INPUTS Y FORMULARIOS ── */
.input-group {
  margin-bottom: 12px;
}

.input-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.input-field {
  width: 100%;
  background: rgba(11, 15, 25, 0.8);
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: #fff;
  font-size: 12px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.input-field:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.input-field::placeholder {
  color: #475569;
}

/* ── BUSCADOR Y FILTROS ── */
.search-filter-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

@media (min-width: 640px) {
  .search-filter-bar {
    flex-direction: row;
    align-items: center;
  }
}

.pill-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.pill-list::-webkit-scrollbar {
  display: none;
}

.pill {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pill:hover {
  background: #334155;
  color: #fff;
}

.pill.active {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: #000;
  font-weight: 700;
}

/* ── MODO CUADRÍCULA DE LOGOS (VISUAL GRID) ── */
.channel-grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

@media (min-width: 768px) {
  .channel-grid-layout {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 12px;
  }
}

.grid-channel-card {
  background: rgba(9, 14, 26, 0.95);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-lg);
  padding: 8px 6px;
  height: 106px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.grid-channel-card:hover {
  background: rgba(15, 23, 42, 1);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.grid-channel-card.linked {
  border-color: rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

.grid-channel-card.linked:hover {
  border-color: rgba(16, 185, 129, 0.9);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
}

.grid-channel-card.unlinked:hover {
  border-color: rgba(245, 158, 11, 0.7);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
}

.grid-card-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 8px;
  font-weight: 800;
  padding: 0 2px;
}

.badge-grid-status {
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.badge-grid-status.iptv {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-grid-status.link {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.grid-card-streams-cnt {
  font-family: monospace;
  font-size: 9px;
  color: #34d399;
  font-weight: 700;
}

.grid-card-logo-container {
  height: 48px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  margin: auto 0;
}

.grid-card-logo-img {
  max-height: 38px;
  max-width: 90%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  transition: transform 0.2s ease;
}

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

.grid-card-fallback-name {
  font-size: 10px;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.grid-card-country-tag {
  font-family: monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.grid-card-country-tag.linked {
  color: #34d399;
}

.grid-card-country-tag.unlinked {
  color: #fbbf24;
}

/* ── LISTA DE CANALES GUÍA ── */
.channel-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.channel-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: all var(--transition-fast);
}

.channel-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.channel-card.linked {
  border-left: 3px solid var(--accent-emerald);
}

.channel-card.unlinked {
  border-left: 3px solid var(--accent-rose);
}

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

.channel-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-flag {
  font-size: 14px;
}

.channel-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.channel-cat-badge {
  font-size: 10px;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.badge-status {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-linked {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-unlinked {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

/* ── STREAMS ASIGNADOS DENTRO DEL CANAL ── */
.assigned-streams-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.stream-item {
  background: rgba(11, 15, 25, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.stream-name {
  font-weight: 600;
  color: #e2e8f0;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-cat {
  font-size: 9px;
  color: #64748b;
}

/* ── MODALES ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: #0f172a;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  animation: modalPop 0.2s ease forwards;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── TOAST NOTIFICATIONS ── */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastSlide 0.25s ease forwards;
}

.toast.success { border-left: 3px solid var(--accent-emerald); }
.toast.error { border-left: 3px solid var(--accent-rose); }
.toast.info { border-left: 3px solid var(--accent-cyan); }

@keyframes toastSlide {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── UTILITIES ── */
.text-emerald { color: var(--accent-emerald); }
.text-cyan { color: var(--accent-cyan); }
.text-muted { color: var(--text-muted); }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }

/* ── CARTELERA & PARTIDOS STYLES ── */
.event-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
  transition: var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.event-card.selected {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.05);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.1);
}
.event-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.event-league-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.event-time-badge {
  font-size: 11px;
  font-weight: 800;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.event-teams-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.event-team {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}
.event-team.away {
  justify-content: flex-end;
  text-align: right;
  flex-direction: row-reverse;
}
.team-shield {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.team-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.event-vs {
  font-size: 11px;
  font-weight: 900;
  color: #64748b;
  padding: 0 8px;
  text-transform: uppercase;
}
.event-channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}
.event-channel-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  position: relative;
  text-align: left;
}
.event-channel-btn.checked {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
}
.event-channel-logo {
  width: 28px;
  height: 20px;
  object-fit: contain;
  background: #fff;
  border-radius: 4px;
  padding: 2px;
}
.event-channel-name {
  font-size: 10px;
  font-weight: 700;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.event-channel-country {
  font-size: 8px;
  font-weight: 800;
  color: #94a3b8;
}

/* ── POSTER PREVIEW MODAL ── */
.canvas-preview-container {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
  overflow: auto;
  max-height: 65vh;
}
.canvas-preview-container canvas,
.canvas-preview-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.8);
}
.whatsapp-preview-box {
  background: #0b141a;
  border: 1px solid #1f2c34;
  border-radius: 10px;
  padding: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: #e9edef;
  white-space: pre-wrap;
  max-height: 50vh;
  overflow-y: auto;
}
