/* ===================== Variables ===================== */
:root {
  --gap: 12px;
  --radius: 12px;
  --shadow: 0 6px 20px rgba(0,0,0,.08);
  --bg: #f6f7fb;
  --text: #222;
  --muted: #444;
  --line: #eee;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #94a3b8;
  --secondary-hover: #7e8fa3;
  --success: #10b981;

  --info-bg: #eaf2ff;
  --info-fg: #1e3a8a;
  --error-bg: #ffeaea;
  --error-fg: #7f1d1d;
}

/* ===================== Base ===================== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans";
  background: var(--bg);
  color: var(--text);
}
.container { max-width: 1000px; margin: 32px auto; padding: 0 16px; }

/* ===================== Header ===================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: var(--gap);
}
.header h1 { margin: 0; }

/* ===================== Cards ===================== */
.card {
  background: #fff;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* ===================== Formularios ===================== */
.form-row { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 0.95rem; color: var(--muted); }

input, select {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  width: 100%;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.2);
  outline: none;
}

/* ===================== Botones ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-hover); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .9; }

/* Igualamos ancho */
.btn-equal { flex: 1; min-width: 140px; }

/* Deshabilitados */
.btn.disabled,
.btn[aria-disabled="true"] {
  opacity: .5;
  pointer-events: none;
  cursor: default;
}

/* ===================== Grid filtros ===================== */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  gap: var(--gap);
  align-items: end;
}

/* Estado */
.grid-col-estado { grid-column: 1 / 2; }

/* Acciones (Limpiar izquierda, Buscar derecha) */
.grid-col-actions {
  grid-column: 2 / 5;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ===================== Tabla ===================== */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { font-weight: 700; }
tbody tr:hover { background: #f9fafb; }

/* ===================== Alertas ===================== */
.alert { padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.alert.info { background: var(--info-bg); color: var(--info-fg); }
.alert.error { background: var(--error-bg); color: var(--error-fg); }

/* ===================== LOGIN ===================== */
.auth-layout { display: grid; min-height: 100%; place-items: center; }
.auth-wrapper { width: 100%; padding: 24px; }
.auth-card { width: 100%; max-width: 720px; margin: 0 auto; padding: 24px; }
.auth-title { margin: 0 0 12px 0; font-size: 2rem; line-height: 1.2; }
.auth-form { display: grid; gap: 14px; }
.auth-form .form-actions { margin-top: 6px; }

/* Autofill Chrome */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
  box-shadow: 0 0 0px 1000px #fff inset !important;
}

/* ===================== Paginación ===================== */
.pager {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pager-left { color: #475569; font-size: .95rem; }

.pager-form { margin: 0; }

.pager-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pager-pages {
  display: inline-flex;
  gap: 6px;
}

.page-link {
  display: inline-flex;
  min-width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-radius: 8px;
  background: #eef2ff;
  color: #1e3a8a;
  text-decoration: none;
  font-weight: 600;
}
.page-link:hover { filter: brightness(.98); }
.page-link.active { background: var(--primary); color: #fff; }

/* Tamaño de página */
.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}
.pager-size select {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #ddd;
}

/* ===================== Responsive ===================== */
@media (max-width: 1100px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(200px, 1fr)); }
  .grid-col-estado { grid-column: 1 / 2; }
  .grid-col-actions { grid-column: 2 / 4; }
}

@media (max-width: 800px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .grid-col-estado { grid-column: 1 / 2; }
  .grid-col-actions {
    grid-column: 2 / 3;
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  .pager { flex-direction: column; align-items: stretch; }
  .pager-nav { justify-content: space-between; }
}

@media (max-width: 560px) {
  .filter-grid { grid-template-columns: 1fr; }
  .grid-col-estado { grid-column: 1 / -1; }
  .grid-col-actions {
    grid-column: 1 / -1;
    justify-content: space-between;
  }
  .btn-equal { min-width: 0; }
}
