/* ── VARIABLES ─────────────────────────────────────────────────────── */
:root {
  --cat-yellow:     #ffd700;
  --cat-amber:      #ffa000;
  --cat-black:      #111111;
  --cat-dark-grey:  #1b1f22;
  --cat-surface:    #20252b;
  --cat-red:        #d32f2f;
  --cat-green:      #2e7d32;
  --cat-blue:       #2196f3;
  --text-main:      #ffffff;
  --text-muted:     #a0aab4;
  --bg-body:        var(--cat-dark-grey);
  --glass-bg:       rgba(17, 17, 17, 0.95);
  --th-gradient:    linear-gradient(135deg, #1a1c20 0%, #2a2d33 100%);
  --module-header:  linear-gradient(135deg, #111111 0%, #1e2228 60%, #222830 100%);
  --row-hover:      rgba(255, 215, 0, 0.06);
  --border-subtle:  rgba(255, 215, 0, 0.12);
  --shadow-card:    0 4px 20px rgba(0,0,0,0.25);
  --shadow-hover:   0 8px 30px rgba(0,0,0,0.35);
  --radius:         6px;
  --transition:     0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── ANIMACIONES ───────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes tractorPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); filter: drop-shadow(0 0 10px var(--cat-yellow)); }
  100% { transform: scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulseGold {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,215,0,0); }
  50%      { box-shadow: 0 0 0 4px rgba(255,215,0,0.18); }
}

.anim-menu { animation: zoomIn 0.5s ease-out forwards; }
.anim-btn  { opacity: 0; animation: fadeInUp 0.5s ease-out forwards; }

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

body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

#bg {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background-image: url("images/bg.jpg");
  background-size: cover;
  z-index: 1; opacity: 0.3;
  pointer-events: none;
}
#bg-solid {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: var(--cat-dark-grey);
  z-index: 0;
  pointer-events: none;
}

/* ── TOAST DE NOTIFICACIONES ───────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  border-radius: 6px;
  color: white;
  font-weight: bold;
  font-size: 0.9em;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
  animation: fadeInUp 0.3s ease-out forwards;
  pointer-events: auto;
  max-width: 350px;
}
.toast.success { background: var(--cat-green); border-left: 5px solid #1b5e20; }
.toast.error   { background: var(--cat-red);   border-left: 5px solid #7f0000; }
.toast.warning { background: #e65100;           border-left: 5px solid #bf360c; }
.toast.info    { background: var(--cat-blue);   border-left: 5px solid #0d47a1; }

/* ── MODAL FOTOGRÁFICO ─────────────────────────────────────────────── */
#image-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background-color: rgba(0,0,0,0.85);
  justify-content: center; align-items: center;
  backdrop-filter: blur(5px);
}
.modal-content {
  background: white;
  padding: 15px;
  border-radius: 8px;
  max-width: 90%; max-height: 90%;
  display: flex; flex-direction: column;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.close-modal {
  position: absolute; top: -15px; right: -15px;
  background: var(--cat-red); color: white;
  border: none; border-radius: 50%;
  width: 40px; height: 40px;
  font-weight: bold; cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  font-size: 1.5em; transition: 0.3s;
  line-height: 40px; text-align: center;
}
.close-modal:hover { transform: scale(1.1); background: #b71c1c; }
.modal-body {
  flex: 1; overflow: auto;
  display: flex; justify-content: center; align-items: center;
}
.modal-body img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: 4px; }
.modal-body iframe { width: 80vw; height: 80vh; border: none; border-radius: 4px; }

/* ── LOGIN ─────────────────────────────────────────────────────────── */
#login-section {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 9999;
  display: flex; justify-content: center; align-items: center;
  background-color: var(--cat-black);
  background-image: repeating-linear-gradient(45deg, #0a0a0a, #0a0a0a 20px, #111 20px, #111 40px);
}
.login-card {
  background-color: var(--cat-yellow);
  padding: 50px; width: 400px;
  border-radius: 4px;
  box-shadow: 0 0 40px rgba(255,215,0,0.1);
  text-align: center;
  border: 5px solid var(--cat-black);
  color: var(--cat-black);
  animation: zoomIn 0.5s;
}
.login-input {
  width: 100%; padding: 15px; margin: 10px 0;
  border: 3px solid var(--cat-black);
  background: rgba(255,255,255,0.9);
  font-weight: bold; text-align: center;
  font-size: 1.1em;
}
.login-btn {
  width: 100%; padding: 15px;
  background: var(--cat-black); color: var(--cat-yellow);
  border: 3px solid var(--cat-black);
  font-weight: 900; cursor: pointer;
  text-transform: uppercase; margin-top: 20px;
  font-size: 1.2em; transition: 0.3s;
}
.login-btn:hover { background: #333; transform: translateY(-2px); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ── MENÚ PRINCIPAL ────────────────────────────────────────────────── */
#main-wrapper {
  position: relative; z-index: 10;
  display: none;
  width: 100%; height: 100%;
  justify-content: center; align-items: center;
  flex-direction: column;
}
#header-menu {
  display: flex; flex-direction: column; align-items: center;
  border: 1px solid rgba(255,215,0,0.2);
  padding: 50px; border-radius: 8px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  box-shadow: 0 0 50px rgba(0,0,0,0.8);
  max-width: 1000px; width: 95%;
  text-align: center;
}
.nav-links {
  list-style: none; padding: 0;
  display: flex; flex-wrap: wrap;
  justify-content: center; gap: 15px;
}
.nav-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 12px 20px;
  border: 1px solid rgba(255,255,255,0.1);
  color: #ddd; text-transform: uppercase;
  letter-spacing: 1px; font-size: 0.85em;
  border-radius: 4px;
  background: rgba(255,255,255,0.05);
  cursor: pointer; transition: 0.3s;
  font-weight: 600; animation-duration: 0.6s;
  gap: 8px;
}
.nav-btn:hover {
  background: var(--cat-yellow); color: var(--cat-black);
  border-color: var(--cat-yellow);
  transform: translateY(-5px);
  box-shadow: 0 0 20px rgba(255,215,0,0.5);
}
#btn-consultas .nav-btn,
#btn-catalogos .nav-btn,
#btn-reportes .nav-btn { border-color: var(--cat-yellow); color: var(--cat-yellow); }

/* ── MÓDULOS ───────────────────────────────────────────────────────── */
.module-container {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  background: #f0f2f5; color: #2c3038;
  z-index: 20;
  display: none; flex-direction: column;
  overflow-y: auto;
  animation: slideInDown 0.3s ease-out;
}
.module-header {
  background: var(--module-header); color: var(--cat-yellow);
  padding: 14px 28px;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 3px solid var(--cat-yellow);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  gap: 10px;
}
.module-header h3 {
  margin: 0;
  font-size: 1em; letter-spacing: 1.5px;
  text-shadow: 0 0 15px rgba(255,215,0,0.25);
}
.module-header h3 i { color: var(--cat-amber); margin-right: 6px; }
.close-module {
  background: transparent;
  border: 1.5px solid rgba(255,215,0,0.5);
  color: var(--cat-yellow);
  padding: 6px 18px; font-weight: bold;
  cursor: pointer; border-radius: var(--radius);
  transition: var(--transition); font-size: 0.85em; letter-spacing: 0.5px;
}
.close-module:hover {
  background: var(--cat-yellow); color: var(--cat-black);
  border-color: var(--cat-yellow);
  box-shadow: 0 0 12px rgba(255,215,0,0.3);
}
.app-content { max-width: 1500px; margin: 22px auto; padding: 20px; width: 95%; }
.user-badge {
  background: rgba(255,255,255,0.9); padding: 8px 18px;
  border-radius: 50px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  font-size: 0.85em; color: #333; font-weight: 600;
  border: 1px solid rgba(255,215,0,0.2);
}

/* ── FILTROS Y TABLAS ──────────────────────────────────────────────── */
.filter-box {
  background: white; padding: 18px 22px; border-radius: var(--radius);
  border-left: 4px solid var(--cat-yellow);
  box-shadow: var(--shadow-card);
  margin-bottom: 22px;
  transition: box-shadow var(--transition);
}
.filter-box:focus-within { box-shadow: var(--shadow-hover); }
.filter-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; flex: 1; min-width: 130px; }
.filter-group label {
  font-weight: 700; font-size: 0.75em; text-transform: uppercase;
  margin-bottom: 5px; color: #5a6270; letter-spacing: 0.5px;
}
.filter-input {
  padding: 8px 10px; border: 1.5px solid #dde1e8;
  border-radius: var(--radius); font-family: inherit;
  width: 100%; transition: border-color var(--transition), box-shadow var(--transition);
  background: #fafbfc; color: #2c3038;
}
.filter-input:focus {
  border-color: var(--cat-yellow); outline: none;
  box-shadow: 0 0 0 3px rgba(255,215,0,0.18);
  background: #fffef5;
}
.filter-input:hover:not(:focus) { border-color: #bac0cc; }

.upload-zone {
  border: 3px dashed #c8a800;
  padding: 38px; text-align: center;
  background: #fffde7; cursor: pointer;
  transition: var(--transition); border-radius: var(--radius);
  margin-bottom: 20px; color: #6b5700;
}
.upload-zone:hover { background: var(--cat-yellow); transform: scale(1.015); box-shadow: var(--shadow-hover); }

/* ── TABLAS ────────────────────────────────────────────────────────── */
table {
  width: 100%; border-collapse: collapse; margin-top: 14px;
  background: white; border-radius: var(--radius);
  overflow: hidden; font-size: 0.84em;
  box-shadow: var(--shadow-card);
}
th {
  background: var(--th-gradient);
  color: var(--cat-yellow); padding: 10px 12px;
  text-transform: uppercase; font-size: 0.82em;
  white-space: nowrap; letter-spacing: 0.5px;
  border-bottom: 2px solid rgba(255,215,0,0.25);
}
td {
  border-bottom: 1px solid #e9ecf0; padding: 8px 10px;
  transition: background var(--transition);
}
tbody tr {
  animation: rowFadeIn 0.2s ease-out both;
}
tbody tr:nth-child(even) td { background: #f8f9fb; }
tbody tr:hover td { background: var(--row-hover) !important; }

.editable-cell {
  border: 1.5px solid #dde1e8; background: #fff;
  text-align: center; padding: 5px; width: 100%;
  border-radius: var(--radius); font-weight: bold;
  transition: var(--transition);
}
.editable-cell:focus {
  border-color: var(--cat-yellow); outline: none;
  background: #fffbe6; box-shadow: 0 0 0 3px rgba(255,215,0,0.15);
}
.comment-input {
  border: 1.5px solid #dde1e8; background: #fff;
  width: 100%; padding: 5px 8px; border-radius: var(--radius);
  transition: var(--transition);
}
.comment-input:focus {
  border-color: var(--cat-blue); outline: none;
  box-shadow: 0 0 0 3px rgba(33,150,243,0.15);
}

/* ── BOTONES ───────────────────────────────────────────────────────── */
.btn-action {
  padding: 9px 18px; border: none; cursor: pointer;
  font-weight: 700; border-radius: var(--radius); margin-left: 8px;
  color: white; transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.88em; letter-spacing: 0.3px;
}
.btn-action:hover  { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.btn-action:active { transform: scale(0.97) translateY(0); box-shadow: none; }
.btn-action:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-excel   { background: linear-gradient(135deg, #1d6f42, #2e9d5f); }
.btn-discard { background: linear-gradient(135deg, #c62828, #e53935); }
.btn-confirm { background: linear-gradient(135deg, #111, #2a2a2a); color: var(--cat-yellow); }
.btn-blue    { background: linear-gradient(135deg, #1976d2, #42a5f5); }

.pagination-controls {
  display: flex; justify-content: center; align-items: center;
  gap: 14px; margin-top: 18px; padding: 10px;
  background: white; border-radius: var(--radius);
  border: 1px solid #e9ecf0; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.btn-page {
  padding: 7px 16px;
  background: linear-gradient(135deg, #111, #2a2a2a);
  color: var(--cat-yellow); border: none;
  border-radius: var(--radius); cursor: pointer; font-weight: bold;
  transition: var(--transition); font-size: 0.85em;
}
.btn-page:hover:not(:disabled) { background: #333; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.btn-page:disabled { opacity: 0.45; cursor: not-allowed; background: #c8cdd6; color: #7a8090; transform: none; }

/* ── CATÁLOGOS ─────────────────────────────────────────────────────── */
.catalog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
@media (max-width: 768px) { .catalog-grid { grid-template-columns: 1fr; } }

.catalog-panel {
  background: white; padding: 20px; border-radius: 8px;
  border-top: 4px solid var(--cat-yellow);
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.catalog-list {
  list-style: none; padding: 0;
  max-height: 400px; overflow-y: auto;
  border: 1px solid #eee; border-radius: 4px;
}
.catalog-list li {
  padding: 10px; border-bottom: 1px solid #eee;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.9em;
}
.catalog-list li:last-child { border-bottom: none; }
.btn-delete-cat { color: var(--cat-red); background: none; border: none; cursor: pointer; padding: 5px 10px; }
.cat-import-box {
  background: #e8f5e9; padding: 15px; border-radius: 4px;
  border: 1px dashed #4caf50; margin-bottom: 15px; text-align: center;
}

/* ── INCIDENCIAS ───────────────────────────────────────────────────── */
.incidencia-form {
  background: white; border: 2px solid var(--cat-red);
  padding: 25px; border-radius: 8px;
  max-width: 1000px; margin: 0 auto;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.inc-header {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 2px solid #eee; padding-bottom: 10px; margin-bottom: 20px;
}
.inc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 20px; }
.inc-section {
  background: #f9f9f9; padding: 15px;
  border-radius: 4px; border: 1px solid #ddd;
}
.inc-section h4 { margin-top: 0; border-bottom: 1px solid #ccc; padding-bottom: 5px; font-size: 0.9em; text-transform: uppercase; }
.inc-section.mecanica  h4 { color: var(--cat-red);  border-color: var(--cat-red); }
.inc-section.operativa h4 { color: #2196f3;         border-color: #2196f3; }
.inc-section.seguridad h4 { color: #e65100;         border-color: #e65100; }
.inc-section.otras     h4 { color: #607d8b;         border-color: #607d8b; }

.time-input-group {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; border-bottom: 1px dashed #eee; padding-bottom: 5px;
}
.time-input-group label { font-size: 0.85em; color: #333; flex: 1; }
.time-input-group input {
  width: 70px; padding: 5px; text-align: center;
  border: 1px solid #ccc; border-radius: 4px;
  font-weight: bold; color: var(--cat-red);
}
.time-input-group input.has-value { background: #ffebee; border-color: var(--cat-red); }

.total-box {
  background: var(--cat-red); color: white;
  padding: 15px; border-radius: 8px;
  text-align: center; margin-bottom: 20px;
  display: flex; justify-content: space-between; align-items: center;
}
.total-box h2 { margin: 0; font-size: 1.3em; }
.total-box span { font-size: 2em; font-weight: 900; }
.total-box.over-limit { background: #7f0000; border: 3px solid #ff5252; }

.col-salto  { background: #ffcdd2 !important; color: #b71c1c !important; }
.col-demora { background: #ffebee !important; color: var(--cat-red) !important; }
.dead-salto  { color: #b71c1c; font-weight: bold; }
.dead-demora { color: var(--cat-red); font-weight: bold; }

/* ── SPINNER DE CARGA ──────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

/* ── MODAL DE EDICIÓN ──────────────────────────────────────────────── */
#edit-modal {
  display: none; position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8); z-index: 10001;
  justify-content: center; align-items: center;
  backdrop-filter: blur(5px);
}

/* ── MODAL DE DEMORAS (gráfica interactiva) ────────────────────────── */
#modal-demoras {
  display: none; position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.8); z-index: 9999;
  justify-content: center; align-items: center;
}
.modal-demoras-inner {
  background: #fff; width: 80%; max-height: 80vh;
  border-radius: 8px; padding: 20px;
  overflow-y: auto; position: relative;
}
.modal-demoras-close {
  position: absolute; top: 10px; right: 15px;
  background: red; color: white;
  border: none; padding: 5px 10px;
  border-radius: 4px; cursor: pointer; font-weight: bold;
}
