/**
 * mod_indicadores_fiscales - Estilos modernos para Joomla 4/5
 * @copyright (C) 2026 Todos los derechos reservados.
 */

:root {
  --mif-font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mif-primary: #0f766e;
  --mif-primary-light: #f0fdfa;
  --mif-primary-border: #99f6e4;
  --mif-text-dark: #0f172a;
  --mif-text-muted: #64748b;
  --mif-bg-card: #ffffff;
  --mif-border: #e2e8f0;
  --mif-badge-bg: #f1f5f9;
  --mif-badge-text: #475569;
  --mif-accent-green: #10b981;
  --mif-accent-blue: #0284c7;
  --mif-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.04), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
}

/* Contenedor Principal */
.mif-container {
  font-family: var(--mif-font);
  background: var(--mif-bg-card);
  border: 1px solid var(--mif-border);
  border-radius: 16px;
  box-shadow: var(--mif-shadow);
  overflow: hidden;
  margin: 1.5rem 0;
  transition: all 0.3s ease;
}

.mif-container * {
  box-sizing: border-box;
}

/* Encabezado */
.mif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mif-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mif-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #38bdf8;
}

.mif-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.mif-subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
  margin: 0.15rem 0 0 0;
}

.mif-badge-year {
  background: linear-gradient(135deg, #0d9488 0%, #059669 100%);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Tabla de Indicadores */
.mif-table-wrapper {
  overflow-x: auto;
}

.mif-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.mif-table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--mif-border);
}

.mif-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.mif-table tbody tr:last-child {
  border-bottom: none;
}

.mif-table tbody tr:hover {
  background-color: #f8fafc;
}

.mif-table td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
}

/* Celda de Nombre del Indicador */
.mif-indicator-cell {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.mif-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--mif-primary-light);
  color: var(--mif-primary);
  flex-shrink: 0;
}

.mif-item-texts {
  display: flex;
  flex-direction: column;
}

.mif-item-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--mif-text-dark);
}

.mif-item-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

.mif-tag {
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--mif-badge-bg);
  color: var(--mif-badge-text);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}

.mif-tag-frequency {
  background: #e0f2fe;
  color: #0369a1;
}

.mif-tag-official {
  background: #dcfce7;
  color: #15803d;
}

/* Celda de Valor */
.mif-value-cell {
  text-align: right;
  white-space: nowrap;
}

.mif-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--mif-text-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.mif-unit {
  display: block;
  font-size: 0.72rem;
  color: var(--mif-text-muted);
  font-weight: 500;
  margin-top: 0.1rem;
}

/* Desglose UMA opcional */
.mif-uma-breakdown {
  font-size: 0.73rem;
  color: #64748b;
  margin-top: 0.35rem;
  line-height: 1.35;
}

.mif-uma-breakdown span {
  display: inline-block;
  margin-right: 0.6rem;
  background: #f8fafc;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

/* Fila Dinámica: Tipo de Cambio */
.mif-row-dynamic {
  background: linear-gradient(90deg, #faf5ff 0%, #ffffff 100%);
}

.mif-dynamic-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: #7c3aed;
  background: #f3e8ff;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  margin-left: 0.4rem;
}

.mif-pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: mif-pulse 2s infinite;
}

@keyframes mif-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.mif-refresh-btn {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  font-size: 0.72rem;
  color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.5rem;
  transition: all 0.2s ease;
}

.mif-refresh-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.mif-refresh-btn.spinning svg {
  animation: mif-spin 0.8s linear infinite;
}

@keyframes mif-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Pie del módulo */
.mif-footer {
  padding: 0.85rem 1.25rem;
  background: #f8fafc;
  border-top: 1px solid var(--mif-border);
  font-size: 0.76rem;
  color: var(--mif-text-muted);
}

.mif-footer-note {
  margin: 0;
  line-height: 1.45;
}

.mif-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #e2e8f0;
}

.mif-source-link {
  color: #0284c7;
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.mif-source-link:hover {
  text-decoration: underline;
  color: #0369a1;
}

/* Temas Adicionales */
/* 1. Tema Minimalist */
.mif-theme-minimalist {
  border-radius: 8px;
  box-shadow: none;
  border: 1px solid #cbd5e1;
}

.mif-theme-minimalist .mif-header {
  background: #ffffff;
  color: #0f172a;
  border-bottom: 2px solid #0f172a;
}

.mif-theme-minimalist .mif-title {
  color: #0f172a;
}

.mif-theme-minimalist .mif-header-icon {
  background: #f1f5f9;
  color: #0f172a;
}

.mif-theme-minimalist .mif-badge-year {
  background: #0f172a;
  color: #ffffff;
  box-shadow: none;
}

/* 2. Tema Dark */
.mif-theme-dark {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

.mif-theme-dark .mif-header {
  background: #1e293b;
  border-bottom: 1px solid #334155;
}

.mif-theme-dark .mif-table thead th {
  background: #1e293b;
  color: #94a3b8;
  border-bottom-color: #334155;
}

.mif-theme-dark .mif-table tbody tr {
  border-bottom-color: #1e293b;
}

.mif-theme-dark .mif-table tbody tr:hover {
  background-color: #1e293b;
}

.mif-theme-dark .mif-item-title,
.mif-theme-dark .mif-value {
  color: #f8fafc;
}

.mif-theme-dark .mif-item-icon {
  background: #334155;
  color: #38bdf8;
}

.mif-theme-dark .mif-footer {
  background: #1e293b;
  border-top-color: #334155;
  color: #94a3b8;
}

.mif-theme-dark .mif-tag {
  background: #334155;
  color: #cbd5e1;
}

/* Adaptabilidad Móvil */
@media (max-width: 640px) {
  .mif-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .mif-badge-year {
    align-self: flex-start;
  }

  .mif-table thead {
    display: none;
  }

  .mif-table,
  .mif-table tbody,
  .mif-table tr,
  .mif-table td {
    display: block;
    width: 100%;
  }

  .mif-table tbody tr {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--mif-border);
  }

  .mif-table td {
    padding: 0.35rem 0;
  }

  .mif-value-cell {
    text-align: left;
    margin-top: 0.4rem;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
  }

  .mif-unit {
    display: inline;
  }
}
