/* ==========================================================================
   UI kit compartido (misma paleta corporativa del navigation)
   Se carga globalmente desde index.html. Reutilizar estas clases en lugar de
   redefinir botones, tablas y tarjetas dentro de cada componente.
   ========================================================================== */

:root {
  --gx-primary: #4a7d33;
  --gx-primary-dark: #3f6a2b;
  --gx-primary-soft: rgba(74, 125, 51, 0.1);
  --gx-title: #012970;
  --gx-text: #1f2430;
  --gx-muted: #8a94a6;
  --gx-border: #e5e7eb;
  --gx-surface: #fff;
  --gx-hover: #f4f6fa;
  --gx-radius: 8px;
}

/* --------------------------------------------------------------------------
   Contenedor principal
   En teléfonos pequeños style.css deja #main con margin-top de 40px, menos que
   el alto del header fijo (70px), y el inicio de la página queda tapado.
   -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  #main {
    margin-top: 70px;
  }
}

/* --------------------------------------------------------------------------
   Botones
   -------------------------------------------------------------------------- */

.btn-gx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--gx-radius);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-gx:focus-visible {
  outline: 2px solid var(--gx-primary);
  outline-offset: 2px;
}

.btn-gx:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-gx-primary {
  background-color: var(--gx-primary);
  border-color: var(--gx-primary);
  color: #fff;
}

.btn-gx-primary:hover:not(:disabled) {
  background-color: var(--gx-primary-dark);
  border-color: var(--gx-primary-dark);
  color: #fff;
}

.btn-gx-outline {
  background-color: var(--gx-surface);
  border-color: var(--gx-border);
  color: #4b5563;
}

.btn-gx-outline:hover:not(:disabled) {
  background-color: #f8faf7;
  border-color: var(--gx-primary);
  color: var(--gx-primary);
}

.btn-gx-danger {
  background-color: var(--gx-surface);
  border-color: rgba(229, 72, 77, 0.45);
  color: #e5484d;
}

.btn-gx-danger:hover:not(:disabled) {
  background-color: rgba(229, 72, 77, 0.08);
  border-color: #e5484d;
  color: #e5484d;
}

.btn-gx-sm {
  padding: 4px 12px;
  font-size: 0.8rem;
}

.btn-gx-icon {
  padding-right: 10px;
  padding-left: 10px;
}

/* Barra de acciones de una página */
.gx-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

/* Buscador con ícono */
.gx-search {
  position: relative;
  flex: 1 1 220px;
  max-width: 340px;
}

.gx-search > i {
  position: absolute;
  top: 50%;
  left: 11px;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: #adb5bd;
  pointer-events: none;
}

.gx-search > input {
  padding-left: 32px;
  border: 1px solid var(--gx-border);
  border-radius: var(--gx-radius);
  font-size: 0.85rem;
}

.gx-search > input:focus {
  border-color: var(--gx-primary);
  box-shadow: 0 0 0 2px var(--gx-primary-soft);
  outline: none;
}

/* Panel / tarjeta de contenido */
.gx-panel {
  padding: 16px;
  border: 1px solid var(--gx-border);
  border-radius: var(--gx-radius);
  background: var(--gx-surface);
}

/* --------------------------------------------------------------------------
   Tarjetas de métricas
   -------------------------------------------------------------------------- */

.stat-mini-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  padding: 10px 16px;
  border: 1px solid var(--gx-border);
  border-radius: var(--gx-radius);
  background: var(--gx-surface);
}

.stat-mini > i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #f4f6fa;
  font-size: 1.05rem;
}

.stat-mini-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.stat-mini-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gx-text);
}

.stat-mini-label {
  font-size: 0.72rem;
  color: var(--gx-muted);
}

.stat-mini-green > i { color: var(--gx-primary); background: var(--gx-primary-soft); }
.stat-mini-blue > i { color: #4154f1; background: rgba(65, 84, 241, 0.1); }
.stat-mini-orange > i { color: #e08a00; background: rgba(255, 165, 0, 0.14); }

/* --------------------------------------------------------------------------
   Etiquetas de estado
   -------------------------------------------------------------------------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-warning {
  background-color: #fff3cd;
  border-color: #ffeeba;
  color: #856404;
}

.status-success {
  background-color: rgba(74, 125, 51, 0.12);
  border-color: rgba(74, 125, 51, 0.25);
  color: #2f5a1f;
}

/* --------------------------------------------------------------------------
   Tablas (en móvil se convierten en tarjetas con gx-table-cards + data-label)
   -------------------------------------------------------------------------- */

.gx-table-card {
  border: 1px solid var(--gx-border);
  border-radius: var(--gx-radius);
  background: var(--gx-surface);
}

.table.gx-table {
  margin: 0;
  color: var(--gx-text);
}

.table.gx-table > :not(caption) > * > * {
  padding: 12px 14px;
  border-bottom-color: #f0f2f6;
  vertical-align: middle;
  font-size: 0.88rem;
  box-shadow: none;
}

.table.gx-table > thead > tr > th {
  background: #fafbfc;
  border-bottom: 1px solid var(--gx-border);
  vertical-align: bottom;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gx-muted);
}

.table.gx-table > tbody > tr:last-child > td {
  border-bottom: 0;
}

.table.gx-table > tbody > tr:hover > td {
  background: #f8faf7;
}

.gx-filter {
  min-width: 80px;
  padding: 4px 8px;
  border: 1px solid var(--gx-border);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.gx-filter:focus {
  border-color: var(--gx-primary);
  box-shadow: 0 0 0 2px var(--gx-primary-soft);
  outline: none;
}

@media (max-width: 767px) {
  .gx-toolbar .btn-gx {
    flex: 1 1 calc(50% - 8px);
  }

  .gx-search {
    flex-basis: 100%;
    max-width: none;
  }

  .status-badge {
    font-size: 0.75rem;
  }

  .table-responsive.gx-table-card {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .gx-table-cards,
  .gx-table-cards > tbody {
    display: block;
  }

  /* El encabezado solo conserva los filtros, apilados en un panel */
  .gx-table-cards > thead {
    display: block;
    margin-bottom: 12px;
  }

  .gx-table-cards > thead > tr {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--gx-border);
    border-radius: var(--gx-radius);
    background: var(--gx-surface);
  }

  /* Sin filtros no hay nada que mostrar en el encabezado */
  .gx-table-cards.gx-no-thead > thead {
    display: none;
  }

  .table.gx-table-cards > thead > tr > th {
    display: none;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .table.gx-table-cards > thead > tr > th.gx-col-filter {
    display: block;
  }

  .gx-table-cards > tbody > tr {
    display: block;
    margin-bottom: 12px;
    padding: 4px 0;
    border: 1px solid var(--gx-border);
    border-radius: var(--gx-radius);
    background: var(--gx-surface);
    box-shadow: 0 1px 3px rgba(15, 30, 60, 0.05);
  }

  .table.gx-table-cards > tbody > tr > td,
  .table.gx-table-cards > tbody > tr > th {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    border: 0;
    text-align: right;
  }

  .gx-table-cards > tbody > tr > td[data-label]::before,
  .gx-table-cards > tbody > tr > th[data-label]::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
    color: var(--gx-muted);
  }

  .table.gx-table-cards > tbody > tr > td.gx-td-actions {
    justify-content: stretch;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid #f0f2f6;
  }

  .gx-td-actions .btn-gx {
    flex: 1;
  }

  .gx-td-actions > .dropdown {
    margin-left: auto;
  }
}
