/*
Proyecto: Sistema de Inventario EOAT
Autor:
    Ing. José Antonio Guzmán Trujillo
    Becario de Procesos | Industrias Cazel
    tecnicosprocesos@cazel.mx
    2026
*/

/* =================================================
   1. RESET Y BASE
   ================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;
  line-height: 1.5;
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* =================================================
   2. VARIABLES
   ================================================= */

:root {
  /* Type scale */

  --fs-200: 0.75rem;
  --fs-300: 0.875rem;
  --fs-400: 1rem;
  --fs-500: 1.125rem;
  --fs-600: 1.25rem;
  --fs-700: 1.5rem;
  --fs-800: 2rem;
  --fs-900: 2.5rem;

  /* Spacing scale */

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radii */

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Shadows */

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);

  --shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 10px 15px rgba(0, 0, 0, 0.1);

  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1), 0 20px 40px rgba(0, 0, 0, 0.06);

  --shadow-xl: 0 25px 50px rgba(0, 0, 0, 0.15);

  /* Borders */

  --border-0: 0.5px solid var(--color-border);
  --border-1: 1px solid var(--color-border);
  --border-2: 2px solid var(--color-border);
  --border-3: 3px solid var(--color-border);

  /* Colors */

  --color-primary: #003b73;
  --color-primary-light: #0059b3;
  --color-primary-dark: #00264d;

  --color-accent: #0074d9;
  --color-accent-light: #3399ff;
  --color-accent-dark: #1976d2;

  --color-bg: #f5f5f5;
  --color-surface: #ffffff;
  --color-surface-muted: #f0f0f0;
  --color-surface-hover: #e8eaed;

  --color-text: #222222;
  --color-text-muted: #666666;
  --color-text-inverse: #ffffff;

  --color-border: #dddddd;
  --color-border-light: #e8eaed;

  --color-success: #2ecc71;
  --color-warning: #f39c12;
  --color-danger: #c0392b;
  --color-info: #49a2dd;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  --navbar-height: 275px;
}

/* =================================================
   3. LAYOUT GENERAL
   ================================================= */

.site-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);

  background: var(--color-surface);
  padding: var(--space-2);
  border-bottom: var(--border-1);

  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.site-title {
  font-size: var(--fs-600);
  margin: var(--space-1) 0;
  text-align: center;
  letter-spacing: 0.3px;
}

.main-content {
  padding: var(--space-4);
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  animation: fadeIn var(--transition-slow);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================
   🎨 COLORES POR NAVE
   ========================================= */

.nave-1 {
  background-color: rgba(192, 57, 43, 0.15); /* rojo suave */
  color: #c0392b;
  font-weight: bold;
}

.nave-2 {
  background-color: rgba(41, 128, 185, 0.15); /* azul suave */
  color: #2980b9;
  font-weight: bold;
}

.nave-3 {
  background-color: rgba(39, 174, 96, 0.15); /* verde suave */
  color: #27ae60;
  font-weight: bold;
}

.no-bg {
  background: none !important;
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

/* =================================================
   4. LOGO
   ================================================= */

#cazel-logo-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform var(--transition-base);
}

#cazel-logo-wrapper:hover {
  transform: scale(1.05);
}

.logo {
  max-height: 40px;
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* =================================================
   5. SCREENS
   ================================================= */

.screen {
  display: block;
  animation: slideIn var(--transition-base);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* =================================================
   6. CONTROLES DE BUSQUEDA
   ================================================= */

.controls-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

#eoat-search {
  padding: var(--space-3);
  font-size: var(--fs-400);
  border-radius: var(--radius);
  border: var(--border-1);
  background: var(--color-surface);
  transition: all var(--transition-base);
}

#eoat-search:hover {
  border-color: var(--color-accent-light);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

#eoat-search:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.15);
  outline: none;
}

#eoat-search::placeholder {
  color: var(--color-text-muted);
  opacity: 0.6;
}

/* =================================================
   7. BOTONES
   ================================================= */

.btn {
  border: none;
  padding: var(--space-3);
  border-radius: var(--radius);
  font-size: var(--fs-400);

  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);

  transition: background 0.15s ease;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.btn--secondary {
  background: var(--color-surface-muted);
  color: var(--color-text);
  border: var(--border-1);
  box-shadow: var(--shadow-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn--primary:hover {
  background: var(--color-primary-light);
}

.btn--secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-accent);
  box-shadow: var(--shadow);
}

.info-btn {
  background: linear-gradient(
    135deg,
    var(--color-info) 0%,
    var(--color-accent) 100%
  );
  color: var(--color-text-inverse);
  border: none;
  padding: var(--space-1) var(--space-1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

/* =================================================
   8. RESULTADOS
   ================================================= */

#results-counter {
  display: block;
  margin-bottom: var(--space-3);
  font-weight: bold;
}

#results-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
}

#results-table-container {
  max-height: calc(100dvh - var(--navbar-height) - 180px);
  overflow-y: auto;
  overflow-x: auto;
  border: var(--border-1);
  border-radius: var(--radius);
}

#results-table th,
#results-table td {
  border: var(--border-1);
  padding: var(--space-2);
  text-align: center;
}

#results-table th {
  background: var(--color-surface-muted);
  text-transform: uppercase;
}

#results-table tr:hover {
  background: var(--color-surface-muted);
}

#results-table tbody tr:nth-child(even) {
  background: var(--color-surface-muted);
}

#results-table td:first-child {
  font-weight: 600;
}

/* =================================================
   9. FORMULARIO BUZON
   ================================================= */

#inbox-form-container {
  background: var(--color-surface);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

#inbox-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

#inbox-form input,
#inbox-form textarea,
#inbox-form select {
  padding: var(--space-3);
  border-radius: var(--radius);
  border: var(--border-1);
  font-size: var(--fs-400);
  background: var(--color-surface);
}

#inbox-form input:hover,
#inbox-form textarea:hover,
#inbox-form select:hover {
  border-color: var(--color-accent-light);
}

#inbox-form input:focus,
#inbox-form textarea:focus,
#inbox-form select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
  outline: none;
}

/* =================================================
   10. MAPA
   ================================================= */

#map-container {
  text-align: center;
  background: var(--color-surface);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

#map-image {
  width: 100%;
  margin-bottom: var(--space-2);
  margin-top: var(--space-2);
}

/* =================================================
   11. POPUP
   ================================================= */

.popup {
  position: fixed;
  inset: 0;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  animation: fadeInBg var(--transition-base);
}

@keyframes fadeInBg {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Caja del contenido */

#popup-content {
  background: var(--color-surface);
  padding: var(--space-5);
  border-radius: var(--radius);

  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;

  text-align: center;
  box-shadow: var(--shadow-lg);

  animation: popupIn var(--transition-slow);
  border: 1px solid var(--color-border-light);
}

@keyframes popupIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

#popup-content h3 {
  color: var(--color-primary-dark);
  font-size: var(--fs-700);
  margin-top: 0;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 3px solid var(--color-accent);
  font-weight: 600;
}

/* Botón abajo */

#close-popup-btn {
  margin-top: var(--space-4);
  align-self: center;

  min-width: 140px;
}

/* Imagen */

.eoat-image {
  margin: var(--space-3) auto;
  max-height: 200px;
}

/* Ocultar */

.popup.hidden {
  display: none;
}

/* =================================================
   12. NAVBAR
   ================================================= */

.site-footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  background: var(--color-surface);
  border-top: var(--border-1);
  box-shadow: var(--shadow-sm);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}

.navbar {
  display: flex;
  width: 100%;
}

.navbar .btn {
  flex: 1;
  border-radius: 0;
  font-size: var(--fs-400);
}

.navbar .btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Estado activo en navbar */
.navbar .btn.active {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  box-shadow: inset 0 -3px 0 var(--color-primary-dark);
  font-weight: bold;
}

.navbar .btn.active:hover {
  background: var(--color-accent-light);
}

/* =================================================
   13. AYUDA
   ================================================= */

#help-screen {
  background: var(--color-surface);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

details {
  margin-bottom: var(--space-3);
  transition: all var(--transition-base);
  background: var(--color-surface-muted);
  border-radius: var(--radius);
  padding: var(--space-2);
  border: 1px solid var(--color-border-light);
}

details:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--color-accent-light);
}

details[open] {
  background: var(--color-surface);
  box-shadow: var(--shadow);
  border-color: var(--color-accent);
}

summary {
  font-weight: bold;
  cursor: pointer;
}

#help-screen p,
#help-screen li {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

#help-screen > p:last-of-type {
  background: var(--color-surface);
  padding: var(--space-4);
  border-radius: var(--radius);
  margin-top: var(--space-3);
  line-height: 1.8;
  box-shadow: var(--shadow-sm);
}

#help-screen a {
  color: var(--color-accent-dark);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition-base);
}

#help-screen a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

/* =================================================
   14. MEDIA QUERIES (TABLET / DESKTOP)
   ================================================= */

/* =========================================
   📱 SMALLER (≤480px)
   ========================================= */

@media (max-width: 480px) {
  .main-content {
    padding: var(--space-2);
    max-width: 480px;
    margin: auto;
    margin-bottom: 50px;
  }

  h1 {
    font-size: var(--fs-400);
  }

  h2 {
    font-size: var(--fs-400);
  }

  /* Controles en columna */
  .controls-container {
    gap: 5px;
  }

  #results-table-container {
    overflow-x: auto;
    max-height: calc(100dvh - var(--navbar-height) - 160px);
  }

  #results-table th,
  #results-table td {
    padding: 4px;
    font-size: 0.8rem;
  }

  /* Popup */
  #popup-content {
    width: 95%;
    padding: var(--space-3);
  }

  /* Texto ayuda */
  #help-screen p,
  #help-screen li {
    text-align: justify;
    font-size: 0.85rem;
  }

  .navbar {
    max-width: 480px;
    margin: auto;
    font-size: var(--fs-300);
  }

  .nav-icon {
    display: none;
  }
}

/* =========================================
   📱 SMALL (≤640px)
   ========================================= */

@media (max-width: 640px) {
  .main-content {
    padding: var(--space-3);
    max-width: 640px;
    margin: auto;
    margin-bottom: 40px;
  }

  h1 {
    font-size: var(--fs-600);
  }

  h2 {
    font-size: var(--fs-500);
  }

  /* Controles en columna */
  .controls-container {
    flex-direction: column;
    gap: 10px;
  }

  #eoat-search {
    width: 100%;
  }

  #results-table-container {
    overflow-x: auto;
    max-height: calc(100dvh - var(--navbar-height) - 160px);
  }

  #results-table th,
  #results-table td {
    padding: 6px;
    font-size: 0.9rem;
  }

  /* Popup */
  #popup-content {
    width: 95%;
    padding: var(--space-4);
  }

  /* Texto ayuda */
  #help-screen p,
  #help-screen li {
    text-align: justify;
    font-size: 0.95rem;
  }

  .navbar {
    max-width: 640px;
    margin: auto;
  }
}

/* =========================================
   📱 TABLET (≥768px)
   ========================================= */

@media (min-width: 768px) {
  .main-content {
    max-width: 770px;
    margin: auto;
    margin-bottom: 30px;
  }

  .controls-container {
    flex-direction: row;
    align-items: center;
  }

  #eoat-search {
    flex: 1;
  }

  .navbar {
    max-width: 770px;
    margin: auto;
  }
}

/* =========================================
   💻 DESKTOP (≥1024px)
   ========================================= */

@media (min-width: 1024px) {
  .main-content {
    max-width: 1000px;
  }

  #results-table th,
  #results-table td {
    font-size: 1rem;
    padding: 8px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-primary-light: #42a5f5;
    --color-primary-dark: #5b9cff;

    --color-accent: #2196f3;
    --color-accent-light: #64b5f6;
    --color-accent-dark: #2583ee;

    --color-bg: #121212;
    --color-surface: #1e1e1e;
    --color-surface-muted: #2a2a2a;
    --color-surface-hover: #2d333d;

    --color-text: #f5f5f5;
    --color-text-muted: #aaaaaa;

    --color-border: #333333;
    --color-border-light: #2d333d;

    --color-success: #34a853;
    --color-warning: #fbbc04;
    --color-danger: #ea4335;
    --color-info: #4285f4;
  }

  .nave-1 {
    background-color: rgba(231, 76, 60, 0.25);
  }
  .nave-2 {
    background-color: rgba(52, 152, 219, 0.25);
  }
  .nave-3 {
    background-color: rgba(46, 204, 113, 0.25);
  }

  #cazel-logo-wrapper {
    filter: invert(1) grayscale(100%) brightness(150%);
  }
}

/* ESTO VA AL FINAL */

.hidden {
  display: none;
}
