/* ============================================================
   ECO MÁQUINAS — Modales y paneles deslizantes
   ============================================================ */

/* ── Overlay ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn .18s ease;
}
.modal-overlay.closing { animation: fadeOut .15s ease forwards; }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* ── Modal box ───────────────────────────────────────────── */
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: slideUp .2s ease;
}
.modal.modal-lg  { max-width: 780px; }
.modal.modal-xl  { max-width: 960px; }
.modal.modal-sm  { max-width: 420px; }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  flex-shrink: 0;
}
.modal-header h2 { font-size: 1.125rem; color: var(--primary); flex: 1; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gray-100); border: none;
  font-size: 1.1rem; cursor: pointer; color: var(--gray-500);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--danger); color: var(--white); }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex; justify-content: flex-end; gap: .75rem;
  flex-shrink: 0;
}

/* ── Panel deslizante derecha (detalle) ──────────────────── */
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 520px; max-width: 100%;
  background: var(--white);
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  z-index: 1000;
  display: flex; flex-direction: column;
  animation: slideRight .25s ease;
  overflow: hidden;
}
@keyframes slideRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

.side-panel-header {
  padding: 1.125rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: var(--white);
  display: flex; align-items: center; gap: 1rem;
  flex-shrink: 0;
}
.side-panel-header h2 { font-size: 1.1rem; flex: 1; }
.side-panel-close {
  background: rgba(255,255,255,.2); border: none;
  width: 32px; height: 32px; border-radius: 50%;
  color: var(--white); font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.side-panel-close:hover { background: rgba(255,255,255,.35); }
.side-panel-body { flex: 1; overflow-y: auto; padding: 1.5rem; }
.side-panel-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .75rem; flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}
.tab-btn {
  padding: .6rem 1.1rem;
  background: none; border: none;
  font-size: .9rem; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Formulario de permisos ──────────────────────────────── */
.perm-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.perm-table th {
  background: var(--primary); color: var(--white);
  padding: .5rem .75rem; text-align: center; font-weight: 600;
}
.perm-table th:first-child { text-align: left; }
.perm-table td { padding: .5rem .75rem; border-bottom: 1px solid var(--gray-100); }
.perm-table tr:hover td { background: var(--purple-50); }
.perm-table input[type=checkbox] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
  display: block; margin: 0 auto;
}

/* ── Sección de info ─────────────────────────────────────── */
.info-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: .875rem 1.5rem;
  margin-bottom: 1.25rem;
}
.info-item label { font-size: .8rem; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: .15rem; }
.info-item span  { font-size: .9375rem; color: var(--text-main); }
.info-item.full  { grid-column: 1/-1; }

/* ── Historial de lecturas ───────────────────────────────── */
.reading-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem 0; border-bottom: 1px solid var(--gray-100); font-size: .875rem;
}
.reading-row:last-child { border-bottom: none; }
.reading-type { width: 20px; text-align: center; }
.reading-val  { font-weight: 700; color: var(--primary); min-width: 80px; }
.reading-date { color: var(--text-muted); font-size: .8rem; }
.reading-by   { color: var(--text-muted); font-size: .8rem; margin-left: auto; }

/* ── Live search box ─────────────────────────────────────── */
.live-search-wrapper { position: relative; }
.live-search-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--white);
  border: 1.5px solid var(--primary);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 240px; overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow);
}
.live-search-item {
  padding: .625rem 1rem; cursor: pointer;
  font-size: .9rem; border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition);
}
.live-search-item:last-child { border-bottom: none; }
.live-search-item:hover { background: var(--purple-50); }
.live-search-item .lsi-main  { font-weight: 600; color: var(--primary); }
.live-search-item .lsi-sub   { font-size: .8rem; color: var(--text-muted); }

/* ── Selector dual (disponibles / seleccionadas) ─────────── */
.dual-select { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.dual-col h4  { font-size: .875rem; font-weight: 700; color: var(--gray-700); margin-bottom: .5rem; }
.dual-list {
  border: 1.5px solid var(--border); border-radius: var(--radius);
  min-height: 180px; max-height: 240px; overflow-y: auto;
}
.dual-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; cursor: pointer; font-size: .875rem;
  border-bottom: 1px solid var(--gray-100); transition: background var(--transition);
}
.dual-item:last-child { border-bottom: none; }
.dual-item:hover  { background: var(--blue-50); }
.dual-item.sel    { background: var(--purple-50); }
.dual-item .d-name { flex: 1; font-weight: 600; color: var(--primary); }
.dual-item .d-sub  { font-size: .75rem; color: var(--text-muted); }
.dual-item .d-btn  { background: none; border: none; font-size: 1rem; cursor: pointer; flex-shrink: 0; }

/* ── Upload de foto ──────────────────────────────────────── */
.photo-upload {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 1.25rem; text-align: center; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.photo-upload:hover { border-color: var(--primary); background: var(--purple-50); }
.photo-upload input[type=file] { display: none; }
.photo-preview {
  width: 100%; max-height: 180px; object-fit: cover;
  border-radius: var(--radius); margin-top: .5rem;
}

/* ── Confirm dialog ──────────────────────────────────────── */
.confirm-modal { max-width: 400px; }
.confirm-icon  { font-size: 3rem; text-align: center; margin-bottom: 1rem; }
.confirm-msg   { text-align: center; font-size: 1rem; color: var(--gray-700); margin-bottom: 1.5rem; }

@media (max-width: 640px) {
  .modal { max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; align-self: flex-end; max-height: 95vh; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .side-panel { width: 100%; }
  .info-grid  { grid-template-columns: 1fr; }
  .dual-select { grid-template-columns: 1fr; }
}
