:root {
  --primary-color: #1f2937;
  --secondary-color: #0c7046;
  --accent-color: #f43f5e;
  --light-gray: #f9fafb;
  --dark-gray: #111827;
  --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease-in-out;
  --border-radius: 12px;
}

/* Reset base y tipografía */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ===== Fondo optimizado ===== */
body {
  min-height: 100vh;
  color: white;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  position: relative;
  background-color: #0f1220;
}

body:not(.detalle-activo) {
  background-image: image-set(
    url("../imagenes/bg-1280.webp") 1x,
    url("../imagenes/bg-1920.webp") 1.5x,
    url("../imagenes/bg-2560.webp") 2x
  );
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: scroll;
}

@media (min-width: 1024px){
  body { background-attachment: fixed; }
}



/* Contenedor principal */
.container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Animación */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.rotating-content {
  text-align: center;
  margin-bottom: 3rem;
  animation: fadeIn 1s ease-out;
}

.logo {
  max-width: 320px;
  width: 100%;
  height: auto;
  margin: 1.5rem 0;
  filter: drop-shadow(var(--box-shadow));
  transition: var(--transition);
}

/* Formulario */
.form-container {
  background: white;
  padding: 2.5rem;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
  width: 100%;
  max-width: 500px;
  transform: translateY(0);
  transition: var(--transition);
  color: var(--dark-gray);
}

.form-container:hover {
  transform: translateY(-5px);
}

.input-group { margin-bottom: 1.5rem; }

.input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--primary-color);
}

.input-group input {
  width: 100%;
  padding: 0.8rem 1.2rem;
  border: 2px solid #dfe6e9;
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: var(--transition);
}

.input-group input:focus {
  outline: none;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

/* ===== BOTONES ===== */
.button-group {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.btn-principal,
.btn-secundario {
  flex: 1;
  padding: 1rem;
  border-radius: var(--border-radius);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Botón principal (BUSCAR) */
.btn-principal {
  background-color: var(--secondary-color);
  color: white;
  border: none;
}
.btn-principal:hover {
  background-color: #0a5e3a;
  transform: translateY(-2px);
}

/* Botón secundario (HISTORIAL) */
.btn-secundario {
  background-color: white;
  color: var(--secondary-color);
  border: 2px solid var(--secondary-color);
}
.btn-secundario:hover {
  background-color: var(--secondary-color);
  color: white;
  transform: translateY(-2px);
}

/* ===== Mensaje de error ===== */
.error-message {
  color: var(--accent-color);
  text-align: center;
  margin: 1rem 0;
  font-weight: 500;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-10px); }
  75%      { transform: translateX(10px); }
}

/* ===== Overlay de carga ===== */
.loading-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(255, 255, 255, 0.95);
  display: none;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  z-index: 1000;
  backdrop-filter: blur(3px);
}

.hourglass {
  animation: spin 1.5s infinite linear;
  font-size: 5rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

@keyframes spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.buscando {
  color: var(--dark-gray);
  font-weight: bold;
  font-size: 1.2rem;
}

/* ===== Tablas ===== */
#tablaPedidos {
  background: white;
  color: var(--dark-gray);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--box-shadow);
}

#tablaPedidos thead { background-color: var(--secondary-color); color: white; }

#tablaPedidos th, #tablaPedidos td {
  padding: 0.75rem 1rem;
  text-align: left;
}

#tablaPedidos tbody tr:hover { background-color: #f1f5f9; }

#tablaPedidos_wrapper {
  margin-top: 20px;
  width: 90%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.boton-ver {
  cursor: pointer;
  color: var(--secondary-color);
  text-decoration: underline;
}



/* ===== Botón Volver ===== */
#btnVolver {
  margin-top: 20px;
  padding: 0.8rem 1.2rem;
  background-color: var(--secondary-color);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

#btnVolver:hover {
  background-color: #0a5e3a;
  transform: translateY(-2px);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .container { padding: 1rem; }
  .form-container { padding: 1.5rem; }
  .logo { max-width: 250px; }
  #tablaPedidos_wrapper, #detallePedido {
    width: 100%;
    padding: 0 1rem;
  }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .button-group { flex-direction: column; }
  .btn-principal, .btn-secundario, #btnVolver {
    padding: 0.9rem; font-size: 0.95rem;
  }
  #tablaPedidos th, #tablaPedidos td,
  #tablaArticulos th, #tablaArticulos td {
    padding: 0.5rem; font-size: 0.85rem;
  }
}
