/* ==========================================================================
   AAR OS — Componentes Material Design 3
   ========================================================================== */

/* Cards M3 */
.md-card {
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  padding: var(--espacio-4);
  display: flex;
  flex-direction: column;
  gap: var(--espacio-3);
}

.md-card--elevada {
  background-color: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.md-card__cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--espacio-2);
  flex-wrap: wrap;
}

.md-card__titulo {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.metrica-valor {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

/* Botones M3 */
.md-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border-radius: var(--md-sys-shape-corner-full);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter var(--md-sys-motion-duration) var(--md-sys-motion-standard),
    background-color var(--md-sys-motion-duration) var(--md-sys-motion-standard);
}

.md-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.md-btn--filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.md-btn--filled:hover:not(:disabled) {
  filter: brightness(1.08);
}

.md-btn--tonal {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.md-btn--outlined {
  background-color: transparent;
  border-color: var(--md-sys-color-outline);
  color: var(--md-sys-color-primary);
}

.md-btn--text {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  padding: 0 12px;
}

.md-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--md-sys-shape-corner-full);
  border: none;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.md-icon-btn:hover {
  background-color: var(--md-sys-color-surface-container-highest);
}

/* Campos de texto Outlined M3 */
.md-campo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.md-campo__etiqueta {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
}

.md-input,
.md-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--md-sys-shape-corner-small);
  border: 1px solid var(--md-sys-color-outline);
  background-color: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  font-family: inherit;
  font-size: 0.95rem;
}

.md-input:focus,
.md-select:focus {
  outline: 2px solid var(--md-sys-color-primary);
  border-color: var(--md-sys-color-primary);
}

/* Chips y Badges */
.chips-fila {
  display: flex;
  flex-wrap: wrap;
  gap: var(--espacio-2);
}

.md-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--md-sys-shape-corner-small);
  border: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.md-chip.activo {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  border-color: transparent;
}

.md-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--md-sys-shape-corner-full);
  font-size: 0.78rem;
  font-weight: 600;
}

.md-badge--ok {
  background-color: var(--md-sys-color-success-container);
  color: var(--md-sys-color-on-success-container);
}

.md-badge--warning {
  background-color: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
}

.md-badge--error {
  background-color: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}

.md-badge--neutro {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
}

/* Banner de alerta */
.md-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--espacio-3);
  padding: var(--espacio-3) var(--espacio-4);
  border-radius: var(--md-sys-shape-corner-medium);
  background-color: var(--md-sys-color-warning-container);
  color: var(--md-sys-color-on-warning-container);
  flex-wrap: wrap;
}

/* Tablas responsivas */
.tabla-envoltura {
  width: 100%;
  overflow-x: auto;
}

.md-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.md-tabla th,
.md-tabla td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.md-tabla th {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--md-sys-color-on-surface-variant);
}

.md-tabla tr:hover td {
  background-color: var(--md-sys-color-surface-container);
}

/* Barras de gráfica nativas */
.barra-progreso {
  height: 10px;
  border-radius: var(--md-sys-shape-corner-full);
  background-color: var(--md-sys-color-surface-container-highest);
  overflow: hidden;
}

.barra-progreso__relleno {
  height: 100%;
  border-radius: var(--md-sys-shape-corner-full);
}

/* Dialog M3 */
dialog.md-dialog {
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-extra-large);
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
  padding: var(--espacio-6);
  width: min(92vw, 520px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

dialog.md-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

/* Snackbar M3 */
.md-snackbar {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background-color: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  padding: 12px 20px;
  border-radius: var(--md-sys-shape-corner-small);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 50;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

@media (min-width: 840px) {
  .md-snackbar {
    bottom: 24px;
  }
}
