/* ============================
   Estilos del modulo por fecha
   ============================ */
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: 8px;
  margin: 20px 0 24px;
  animation: slideIn 0.3s ease;
}

.alert-error {
  background: var(--color-permission-no-bg);
  border-left: 4px solid var(--color-error);
  color: var(--color-error);
}

.alert-success {
  background: var(--color-permission-yes-bg);
  border-left: 4px solid var(--color-success);
  color: var(--color-success);
}

.alert-icon {
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.alert-message {
  flex: 1;
  font-weight: 500;
}

.alert-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
  opacity: 0.7;
}

.alert-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.1);
}

.filtros-card {
  margin-top: 20px;
  margin-bottom: 24px;
}

.filtros-card h2 {
  margin: 0 0 20px 0;
  color: var(--color-text-main);
  font-size: 1.3rem;
  font-weight: 600;
}

.filtros-form .form-row {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 200px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--color-text-main);
  font-size: 0.9rem;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--color-input-border);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  background-color: var(--color-input-bg);
  color: var(--color-text-main);
}

.form-group input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.form-group input.error {
  border-color: var(--color-error);
  background-color: var(--color-permission-no-bg);
}

.error-message {
  color: var(--color-error);
  font-size: 0.8rem;
  margin-top: 4px;
  font-weight: 500;
}

.form-actions {
  display: flex;
  gap: 12px;
}

.btn-buscar {
  min-width: 140px;
  justify-content: center;
}

.btn-buscar:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.3);
}

.btn-buscar:disabled {
  transform: none;
  box-shadow: none;
}

/* Loading Spinner */
.loading-spinner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Resultados Section */
.resultados-section {
  margin-bottom: 24px;
}

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

.resultados-header h2 {
  margin: 0;
  color: var(--color-text-main);
  font-size: 1.3rem;
  font-weight: 600;
}

.resultados-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.resultados-filtro-numero {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.resultados-filtro-numero label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.resultados-filtro-numero input {
  min-width: 200px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-input-border);
  font-size: 0.9rem;
  color: var(--color-text-main);
  background: var(--color-input-bg);
}

.resultados-filtro-numero input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.estado-masivo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.estado-masivo label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.estado-masivo select {
  min-width: 160px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--color-input-border);
  background: var(--color-input-bg);
  font-size: 0.85rem;
  color: var(--color-text-main);
}

.estado-masivo button {
  min-width: 180px;
}

/* Table */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.autorizaciones-table {
  font-size: 0.9rem;
}

.autorizaciones-table th {
  white-space: nowrap;
}

.autorizaciones-table td {
  vertical-align: top;
}

.autorizaciones-table tr:hover td {
  background: var(--color-table-hover);
}

.autorizaciones-table tr.even-row td {
  background: var(--color-table-row-alt);
}

.numero-autorizacion {
  font-weight: 600;
  color: var(--color-primary);
  font-family: "Courier New", monospace;
}

.fecha {
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.interno {
  font-weight: 600;
  font-family: "Courier New", monospace;
}

.cup-codigo {
  font-weight: 600;
  font-family: "Courier New", monospace;
  text-align: center;
}

.cup-cobertura {
  text-align: center;
}

.cobertura-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.cobertura-ok {
  background: var(--color-permission-yes-bg);
  color: var(--color-success);
}

.cobertura-no {
  background: var(--color-permission-no-bg);
  color: var(--color-error);
}

.cup-nivel {
  font-weight: 600;
  text-align: center;
}

.nombre-paciente,
.ips,
.autorizante,
.establecimiento,
.estado {
  max-width: 180px;
  line-height: 1.3;
}

.ips-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ips-convenio {
  align-self: flex-start;
  font-size: 0.7rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.estado select {
  width: 100%;
  min-width: 140px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--color-input-border);
  background: var(--color-input-bg);
  font-size: 0.95rem;
  color: var(--color-text-main);
}

.estado-label {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.mini-status {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.municipio,
.departamento {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.acciones {
  white-space: nowrap;
  text-align: center;
}

.no-result {
  text-align: center;
  padding: 24px 16px;
  color: var(--color-text-muted);
  font-weight: 600;
}

.btn-descargar:hover:not(:disabled) {
  transform: translateY(-1px);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  margin: 0 0 8px 0;
  color: var(--color-text-main);
  font-size: 1.3rem;
  font-weight: 600;
}

.empty-state p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

/* Linea de estado inferior para procesos de carga */
.status-line {
  margin-top: 12px;
  font-size: 0.85rem;
  color: #1976d2;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Spinner pequenito en linea */
.spinner-inline {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(25, 118, 210, 0.3);
  border-top-color: #1976d2;
  animation: spin 0.8s linear infinite;
}

/* Animations */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 768px) {
  .filtros-form .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-group {
    min-width: auto;
  }

  .resultados-header {
    flex-direction: column;
    align-items: stretch;
  }

  .resultados-filtro-numero {
    width: 100%;
    margin-left: 0;
  }

  .resultados-filtro-numero input {
    width: 100%;
  }

  .resultados-actions {
    justify-content: center;
  }

  .estado-masivo {
    width: 100%;
    justify-content: space-between;
  }

  .autorizaciones-table th,
  .autorizaciones-table td {
    padding: 8px 12px;
  }

  .nombre-paciente,
  .ips,
  .autorizante,
  .establecimiento,
  .estado {
    max-width: 120px;
  }
}

@media (max-width: 480px) {
  .resultados-actions {
    flex-direction: column;
  }

  .btn-exportar,
  .btn-descargar-todos,
  .estado-masivo,
  .estado-masivo button {
    justify-content: center;
  }

  .estado-masivo {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .estado-masivo select,
  .estado-masivo button {
    width: 100%;
  }

  .empty-state {
    padding: 40px 16px;
  }
}
