/* =========================================================
   AGROMAQ - Base global
   Archivo: assets/css/main.css

   Este archivo debe contener SOLO:
   - Variables globales
   - Reset base
   - Contenedor
   - Botones base
   - Animación reveal
   - SweetAlert
   - Soporte mínimo legacy / admin

   Los estilos visuales específicos están en:
   navbar.css, hero.css, empresa.css, servicios.css,
   categorias-secciones.css, catalogo.css, carrito.css,
   modal.css y footer.css
========================================================= */

:root {
  /* Paleta AGROMAQ nueva */
  --ag-dark-950: #111315;
  --ag-dark-900: #171a1d;
  --ag-dark-850: #1f2327;
  --ag-dark-800: #282d32;
  --ag-dark-700: #353b42;

  --ag-red-700: #a90f16;
  --ag-red-600: #c9161d;
  --ag-red-500: #e31b23;
  --ag-red-400: #ff3138;

  --ag-white: #ffffff;
  --ag-soft-white: rgba(255, 255, 255, 0.86);
  --ag-muted-white: rgba(255, 255, 255, 0.64);

  --ag-line: rgba(255, 255, 255, 0.12);
  --ag-line-red: rgba(227, 27, 35, 0.55);
  --ag-shadow: 0 18px 45px rgba(0, 0, 0, 0.28);

  --ag-radius-sm: 6px;
  --ag-radius-md: 10px;
  --ag-radius-lg: 14px;

  /* Variables legacy para no romper código anterior/admin */
  --primary: var(--ag-red-500);
  --primary-2: var(--ag-dark-950);
  --gold: var(--ag-red-400);
  --danger: var(--ag-red-600);
  --bg: #f7f7f5;
  --text: var(--ag-dark-950);
  --muted: rgba(17, 19, 21, 0.62);
  --line: rgba(17, 19, 21, 0.12);
  --shadow: 0 24px 70px rgba(17, 19, 21, 0.16);
  --shadow-soft: 0 12px 35px rgba(17, 19, 21, 0.09);
  --radius: 28px;
  --radius-sm: 16px;
  --max: 1200px;
}

/* =========================================================
   Reset base
========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background: #ffffff;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.agx-overlay-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  display: block;
}

img {
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

input,
select,
textarea {
  max-width: 100%;
}

textarea {
  resize: vertical;
}

::selection {
  color: #ffffff;
  background: var(--ag-red-600);
}

/* =========================================================
   Layout global
========================================================= */

.container {
  width: min(var(--max), calc(100% - 32px));
  margin-inline: auto;
}

.section {
  position: relative;
}

main {
  position: relative;
  z-index: 1;
}

/* =========================================================
   Botones base
========================================================= */

.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 18px;
  color: var(--ag-dark-950);
  background: #ffffff;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease,
    border-color 0.22s ease,
    color 0.22s ease;
}

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

.btn:focus-visible {
  outline: 3px solid rgba(227, 27, 35, 0.28);
  outline-offset: 3px;
}

.btn-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--ag-red-700), var(--ag-red-500));
  border-color: rgba(227, 27, 35, 0.48);
  box-shadow: 0 16px 30px rgba(227, 27, 35, 0.24);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--ag-red-600), var(--ag-red-500));
  box-shadow: 0 20px 38px rgba(227, 27, 35, 0.32);
}

.btn-ghost {
  color: var(--ag-dark-950);
  background: rgba(17, 19, 21, 0.045);
  border-color: rgba(17, 19, 21, 0.12);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ag-red-600);
  border-color: rgba(227, 27, 35, 0.35);
  background: rgba(227, 27, 35, 0.08);
}

.btn-line {
  color: var(--ag-dark-950);
  background: rgba(255, 255, 255, 0.86);
  border-color: rgba(17, 19, 21, 0.14);
}

.btn-line:hover:not(:disabled) {
  color: var(--ag-red-600);
  border-color: rgba(227, 27, 35, 0.34);
}

.btn-danger {
  color: var(--ag-red-700);
  background: rgba(227, 27, 35, 0.08);
  border-color: rgba(227, 27, 35, 0.18);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(227, 27, 35, 0.12);
  border-color: rgba(227, 27, 35, 0.34);
}

.btn-small {
  min-height: 40px;
  padding: 9px 13px;
  font-size: 13px;
}

/* =========================================================
   Animaciones generales
========================================================= */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.65s ease,
    transform 0.65s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes softFloat {
  50% {
    transform: translateY(-8px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   Estados genéricos de carga
========================================================= */

.loading-card {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 180px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}

.spin {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid rgba(227, 27, 35, 0.18);
  border-top-color: var(--ag-red-500);
  animation: spin 0.8s linear infinite;
}

.empty {
  grid-column: 1 / -1;
  padding: 30px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
  border: 1px dashed rgba(17, 19, 21, 0.18);
  border-radius: 18px;
}

/* =========================================================
   Paginación genérica / soporte admin
========================================================= */

.pagination,
.admin-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.pagination button,
.admin-pagination button {
  min-width: 38px;
  min-height: 38px;
  padding: 0 13px;
  color: var(--ag-dark-950);
  background: #ffffff;
  border: 1px solid rgba(17, 19, 21, 0.12);
  border-radius: 999px;
  font-weight: 900;
  transition:
    transform 0.22s ease,
    color 0.22s ease,
    background 0.22s ease,
    border-color 0.22s ease;
}

.pagination button:hover:not(:disabled),
.admin-pagination button:hover:not(:disabled) {
  color: var(--ag-red-600);
  border-color: rgba(227, 27, 35, 0.35);
  transform: translateY(-1px);
}

.pagination button.active,
.admin-pagination button.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--ag-red-700), var(--ag-red-500));
  border-color: rgba(227, 27, 35, 0.45);
}

.pagination button:disabled,
.admin-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination .page-info,
.admin-pagination .page-info {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

/* =========================================================
   SweetAlert
========================================================= */

.swal2-container {
  z-index: 30000 !important;
}

.swal2-popup {
  border-radius: 22px !important;
  color: var(--ag-dark-950) !important;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif !important;
}

.swal2-title {
  color: var(--ag-dark-950) !important;
  font-weight: 950 !important;
  letter-spacing: -0.03em !important;
}

.swal2-html-container {
  color: rgba(17, 19, 21, 0.72) !important;
  font-weight: 650 !important;
}

.swal2-confirm {
  border-radius: 999px !important;
  background: linear-gradient(135deg, var(--ag-red-700), var(--ag-red-500)) !important;
  font-weight: 900 !important;
}

.swal2-cancel {
  border-radius: 999px !important;
  font-weight: 900 !important;
}

/* =========================================================
   Soporte mínimo legacy / admin
   No afecta los nuevos modales porque ellos usan .agx-modal
========================================================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 9200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal.open {
  display: flex;
}

.modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(17, 19, 21, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-box {
  position: relative;
  z-index: 2;
  width: min(760px, 100%);
  max-height: 88dvh;
  overflow: auto;
  padding: 24px;
  color: var(--ag-dark-950);
  background: #ffffff;
  border: 1px solid rgba(227, 27, 35, 0.18);
  border-radius: 18px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32);
  animation: fadeUp 0.24s ease both;
}

.modal-box-small {
  width: min(480px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal h2,
.modal-box h2 {
  margin: 0;
  color: var(--ag-dark-950);
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--ag-dark-950);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ag-dark-950);
  background: #ffffff;
  border: 1px solid rgba(17, 19, 21, 0.14);
  border-radius: 10px;
  outline: 0;
  font-size: 14px;
  font-weight: 750;
  transition:
    border-color 0.22s ease,
    box-shadow 0.22s ease;
}

.field textarea {
  min-height: 96px;
  padding-top: 12px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(227, 27, 35, 0.52);
  box-shadow: 0 0 0 4px rgba(227, 27, 35, 0.1);
}

.notice {
  padding: 13px 14px;
  color: rgba(17, 19, 21, 0.72);
  background: rgba(227, 27, 35, 0.07);
  border: 1px solid rgba(227, 27, 35, 0.16);
  border-left: 4px solid var(--ag-red-500);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 750;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab {
  min-height: 44px;
  padding: 0 12px;
  color: var(--ag-dark-950);
  background: #ffffff;
  border: 1px solid rgba(17, 19, 21, 0.12);
  border-radius: 9px;
  font-size: 13px;
  font-weight: 950;
}

.auth-tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--ag-red-700), var(--ag-red-500));
  border-color: rgba(227, 27, 35, 0.5);
}

.auth-help {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.auth-contact {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.auth-contact span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.auth-contact a {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 9px 13px;
  color: #ffffff;
  background: #25d366;
  border-radius: 999px;
  font-weight: 950;
}

/* =========================================================
   Helpers
========================================================= */

.sr-only,
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
}

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

.hidden {
  display: none !important;
}

/* =========================================================
   Responsive global
========================================================= */

@media (max-width: 980px) {
  .container {
    width: min(var(--max), calc(100% - 28px));
  }

  .pagination,
  .admin-pagination {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 4px;
  }
}

@media (max-width: 620px) {
  .container {
    width: min(var(--max), calc(100% - 22px));
  }

  .btn {
    min-height: 42px;
    padding: 10px 14px;
    font-size: 13px;
  }

  .btn-small {
    min-height: 38px;
    padding: 8px 11px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 12px;
  }

  .modal-box {
    max-height: 92dvh;
    padding: 18px;
    border-radius: 16px;
  }

  .auth-tabs {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}

