/* =========================================================
   LibreIPTV Admin — Sistema de diseño
   Paleta oficial extraída de D:\...\LIBREIPTV\Web\styles.css
   ========================================================= */

/* ----- Tokens de diseño ---------------------------------- */
:root {
  /* Fondos */
  --bg-base:        #0A111A;
  --bg-sidebar:     #0E1722;
  --bg-surface:     #16212E;
  --bg-surface-alt: #1C2A3A;

  /* Acento */
  --accent:         #4A90D9;
  --accent-hover:   #5BA3EC;
  --accent-glow:    rgba(74, 144, 217, 0.25);
  --accent-subtle:  rgba(74, 144, 217, 0.12);

  /* Texto */
  --text-primary:   #FFFFFF;
  --text-secondary: #A8B8C8;
  --text-tertiary:  #6A7F94;

  /* Bordes */
  --border-subtle:  rgba(74, 144, 217, 0.18);
  --border-hover:   rgba(74, 144, 217, 0.55);

  /* Estados */
  --status-active:  #4CAF50;
  --star-color:     #FFC107;

  /* Radios */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  /* Sombras */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 28px var(--accent-glow);

  /* Transición */
  --transition: 0.22s ease;
}

/* ----- Reset base ---------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

/* ----- Body ---------------------------------------------- */
body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ----- Utilidades ---------------------------------------- */
.hidden {
  display: none !important;
}

/* Evita el flash de template sin compilar de Vue */
[v-cloak] {
  display: none;
}

/* ----- Auth loading (spinner inicial) -------------------- */
.auth-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ----- Login screen -------------------------------------- */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 2rem;
}

.brand-name {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ----- Formulario base ----------------------------------- */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

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

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.75rem 0.875rem;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--border-hover);
}

.form-group input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.form-group input::placeholder {
  color: var(--text-tertiary);
}

.login-error {
  color: #f44336;
  font-size: 0.8rem;
  margin-top: -0.25rem;
}

/* ----- Botones ------------------------------------------- */
.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.8rem 1.25rem;
  transition: background var(--transition);
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

/* ----- Topbar --------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: rgba(14, 23, 34, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-title em {
  color: var(--accent);
  font-style: normal;
}

.topbar-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-active);
  box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(76, 175, 80, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}

.admin-email {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  transition: border-color var(--transition), color var(--transition);
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* ----- Tabs de navegación ---------------------------------- */
.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.85rem 1rem;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.badge-count {
  background: #f44336;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 0.2rem 0.45rem;
}

/* ----- Contenido principal ---------------------------------- */
.main-content {
  margin: 0 auto;
  max-width: 1200px;
  padding: 2rem;
}

.placeholder-text {
  color: var(--text-tertiary);
  padding: 3rem 0;
  text-align: center;
}

/* ----- Toast -------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  max-width: 320px;
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  transform: translateY(150%);
  transition: transform var(--transition);
}

.toast.visible {
  transform: translateY(0);
}

.toast.ok {
  background: var(--status-active);
}

.toast.err {
  background: #f44336;
}

.toast.warn {
  background: var(--star-color);
  color: #000;
}

/* ----- Modal genérico ------------------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 1rem;
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  animation: modalIn 0.22s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.5rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem;
  transition: color var(--transition);
}

.btn-icon:hover {
  color: var(--text-primary);
}

/* ----- Sección: cabecera ---------------------------------------- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.section-badge {
  background: var(--accent-subtle);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.85rem;
}

/* ----- Reseñas ---------------------------------------------------- */
.reviews-panel {
  margin-bottom: 2rem;
}

.panel-title {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.review-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.9rem;
  transition: border-color var(--transition);
}

/* ----- Configuración remota --------------------------------------- */
.config-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 640px;
}

.config-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.config-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field-desc {
  color: var(--text-tertiary);
  font-size: 0.78rem;
}

/* Toggle tipo pill */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
}

.toggle-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  transition: background var(--transition), border-color var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}

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

.toggle-input:checked + .toggle-slider::before {
  background: var(--accent);
  transform: translateX(20px);
}

@media (max-width: 640px) {
  .config-row {
    grid-template-columns: 1fr;
  }
}

.review-card.pending {
  border-left-color: var(--star-color);
}

.review-card.approved {
  border-left-color: var(--status-active);
}

.review-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.review-name {
  font-weight: 600;
}

.review-stars {
  color: var(--star-color);
  letter-spacing: 0.05em;
}

.review-platform {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.review-date {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  margin-left: auto;
}

.review-comment {
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.review-actions {
  display: flex;
  gap: 0.6rem;
}

/* ----- Botones de acción (reseñas) ------------------------------- */
.btn-success,
.btn-danger {
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  transition: filter var(--transition);
}

.btn-success {
  background: var(--status-active);
  color: #fff;
}

.btn-danger {
  background: #f44336;
  color: #fff;
}

.btn-success:hover,
.btn-danger:hover {
  filter: brightness(1.1);
}

/* ----- Estado vacío ----------------------------------------------- */
.empty-state {
  color: var(--text-tertiary);
  padding: 2rem 0;
  text-align: center;
}

/* ----- Botones de ancho automático (fuera de formularios apilados) - */
.section-header .btn-primary,
.modal-footer .btn-primary {
  width: auto;
}

/* ----- Aviso de seguridad ------------------------------------------ */
.security-notice {
  background: rgba(255, 193, 7, 0.08);
  border: 1px solid rgba(255, 193, 7, 0.35);
  border-radius: var(--radius-md);
  color: var(--star-color);
  font-size: 0.85rem;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.5rem;
}

/* ----- Tabla de datos ----------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 1rem;
}

.data-table tbody tr:hover {
  background: var(--bg-surface-alt);
}

.data-table td.actions {
  display: flex;
  gap: 0.5rem;
}

/* ----- Badges de tipo de lista --------------------------------------- */
.badge {
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  text-transform: uppercase;
}

.badge.xtream {
  background: var(--accent-subtle);
  color: var(--accent);
}

.badge.m3u {
  background: rgba(76, 175, 80, 0.15);
  color: var(--status-active);
}

/* ----- Botones pequeños (acciones de tabla) -------------------------- */
.btn-sm {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  transition: border-color var(--transition), color var(--transition);
}

.btn-sm:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-sm.btn-danger {
  background: #f44336;
  border-color: #f44336;
  color: #fff;
}

.btn-sm.btn-danger:hover {
  filter: brightness(1.1);
}

/* ----- Formularios en dos columnas ------------------------------------ */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ----- Pie de modal ---------------------------------------------------- */
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ----- Dashboard: rejilla de KPIs --------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

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

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.stat-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
}

.stat-icon {
  font-size: 1.5rem;
}

.stat-value {
  color: var(--accent);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-label {
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

/* ----- Usuarios ---------------------------------------------------------- */
.search-input {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.875rem;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
  max-width: 320px;
}

.search-input:focus {
  border-color: var(--border-hover);
}

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

.user-cell {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.user-email {
  color: var(--text-primary);
  font-weight: 500;
}

.user-name {
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

/* Badges de estado de suscripción */
.badge.active {
  background: rgba(76, 175, 80, 0.15);
  color: var(--status-active);
}

.badge.pending {
  background: rgba(255, 193, 7, 0.15);
  color: var(--star-color);
}

.badge.cancelled {
  background: rgba(244, 67, 54, 0.15);
  color: #f44336;
}

/* Botón pequeño de éxito (desbloquear) */
.btn-sm.btn-success {
  background: var(--status-active);
  border-color: var(--status-active);
  color: #fff;
}

.btn-sm.btn-success:hover {
  filter: brightness(1.1);
}
