/* ════════════════════════════════════════════════
   InventoryPro — custom.css
   Extends Bootstrap 5 + base styles from index.html
   ════════════════════════════════════════════════ */

/* ─── Signature Pad ─────────────────────────── */
.signature-wrapper {
  position: relative;
  background: #fafbfc;
  border: 2px dashed var(--border, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
  user-select: none;
}

.signature-wrapper:hover,
.signature-wrapper.active {
  border-color: var(--primary, #2563eb);
  background: #f8faff;
}

.signature-wrapper canvas {
  display: block;
  width: 100%;
  height: 160px;
  cursor: crosshair;
  touch-action: none;
}

.signature-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b0bac4;
  font-size: 0.85rem;
  pointer-events: none;
  transition: opacity 0.2s;
}

.signature-hint.hidden { opacity: 0; }

.signature-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border, #e2e8f0);
  background: #f8f9fa;
}

/* ─── Image Upload Preview ──────────────────── */
.upload-zone {
  border: 2px dashed var(--border, #e2e8f0);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #fafbfc;
  position: relative;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary, #2563eb);
  background: #f0f6ff;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-zone-icon {
  font-size: 2rem;
  color: #94a3b8;
  margin-bottom: 8px;
}

.upload-zone-text {
  font-size: 0.9rem;
  color: var(--text-muted, #64748b);
  line-height: 1.5;
}

.upload-zone-text strong { color: var(--primary, #2563eb); }

.upload-zone-limit {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.preview-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--border, #e2e8f0);
  background: #f1f5f9;
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-thumb .remove-thumb {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  background: rgba(239,68,68,0.9);
  border-radius: 50%;
  border: none;
  color: white;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.preview-thumb:hover .remove-thumb { opacity: 1; }

/* ─── Stock Indicators ──────────────────────── */
.stock-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.stock-pill.ok      { background: #dcfce7; color: #166534; }
.stock-pill.low     { background: #fef9c3; color: #854d0e; }
.stock-pill.critical{ background: #fee2e2; color: #991b1b; }

.stock-pill.low::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #eab308;
  display: inline-block;
}

.stock-pill.critical::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #ef4444;
  display: inline-block;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(1.3); }
}

/* ─── Movement Type Badge ───────────────────── */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.type-badge.entrada { background: #dcfce7; color: #166534; }
.type-badge.salida  { background: #fee2e2; color: #991b1b; }

/* ─── Area Tag ──────────────────────────────── */
.area-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e0f2fe;
  color: #075985;
  white-space: nowrap;
}

/* ─── Signed Chip ───────────────────────────── */
.signer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #334155;
}

.signer-chip .chip-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.signer-chip .chip-remove {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
  transition: color 0.15s;
}

.signer-chip .chip-remove:hover { color: #ef4444; }

/* ─── Confirmation Step ─────────────────────── */
.confirm-summary {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px;
}

.confirm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}

.confirm-row:last-child { border-bottom: none; }
.confirm-row .c-label { color: #64748b; font-weight: 500; }
.confirm-row .c-value { font-weight: 700; color: #0f172a; }

.confirm-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fefce8;
  border: 1.5px solid #fde68a;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: #92400e;
  margin-top: 14px;
}

/* ─── Audit Log Row ─────────────────────────── */
.audit-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
}

.audit-row:last-child { border-bottom: none; }

.audit-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.audit-icon.create  { background: #dcfce7; color: #16a34a; }
.audit-icon.update  { background: #dbeafe; color: #2563eb; }
.audit-icon.delete  { background: #fee2e2; color: #dc2626; }
.audit-icon.login   { background: #f3e8ff; color: #9333ea; }
.audit-icon.failure { background: #fef9c3; color: #d97706; }

.audit-meta { flex: 1; min-width: 0; }
.audit-action { font-weight: 700; color: #0f172a; }
.audit-detail { color: #64748b; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audit-time { font-size: 0.78rem; color: #94a3b8; white-space: nowrap; }

/* ─── Dashboard Metric Card ─────────────────── */
.metric-card {
  background: #fff;
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 14px;
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.metric-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.09);
  transform: translateY(-2px);
}

.metric-card .mc-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 14px;
}

.metric-card .mc-val {
  font-size: 2rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1;
  margin-bottom: 4px;
}

.metric-card .mc-label {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 500;
}

.metric-card .mc-trend {
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 6px;
}

.metric-card .mc-trend.up   { color: #16a34a; }
.metric-card .mc-trend.down { color: #dc2626; }

/* ─── Page transition ───────────────────────── */
.page-fade {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Table enhancements ────────────────────── */
.table-hover tbody tr {
  transition: background 0.12s;
}

.td-code {
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 4px;
  color: #334155;
  white-space: nowrap;
}

/* ─── Empty state ───────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
}

.empty-state-icon { font-size: 3rem; margin-bottom: 14px; opacity: 0.5; }
.empty-state h4   { font-size: 1.05rem; font-weight: 700; color: #64748b; margin-bottom: 6px; }
.empty-state p    { font-size: 0.88rem; }

/* ─── Responsive tweaks ─────────────────────── */
@media (max-width: 576px) {
  .metric-card .mc-val { font-size: 1.6rem; }
  .image-preview-grid  { grid-template-columns: repeat(3, 1fr); }
  .confirm-row         { flex-direction: column; gap: 2px; }
}
.item-option {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
}
.item-option:last-child { border-bottom: none; }
.item-option:hover { background: #f0f7ff; }
.item-option-name {
  font-weight: 600;
  font-size: .9rem;
  color: #0f172a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.item-option-meta {
  font-size: .78rem;
  color: #64748b;
  margin-top: 3px;
}
.stock-ok    { color: #10b981; font-weight: 700; }
.stock-low   { color: #f59e0b; font-weight: 700; }
.stock-empty { color: #ef4444; font-weight: 700; }
.item-search-empty {
  padding: 16px;
  text-align: center;
  color: #64748b;
  font-size: .88rem;
}

/* ─── Movement Detail Modal ─────────────────── */
.detail-section {
  margin-bottom: 24px;
}
.detail-section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.detail-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.detail-label {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.detail-value {
  font-size: .92rem;
  color: var(--text);
  font-weight: 500;
}
.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.img-thumb {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 4/3;
  cursor: zoom-in;
  border: 2px solid var(--border);
  transition: border-color .2s, transform .2s;
}
.img-thumb:hover {
  border-color: var(--primary);
  transform: scale(1.02);
}
.img-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.img-thumb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  color: #fff;
  font-size: 1.6rem;
  opacity: 0;
}
.img-thumb:hover .img-thumb-overlay {
  background: rgba(0,0,0,.35);
  opacity: 1;
}
.sig-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1.5px solid var(--border);
}
.sig-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sig-img {
  max-width: 100%;
  max-height: 80px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: zoom-in;
}
.sig-name { font-weight: 600; font-size: .9rem; }
.sig-role { font-size: .78rem; color: var(--text-muted); }
.sig-date { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.stock-change {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: .9rem;
}
.stock-change.entrada {
  background: #d1fae5;
  color: #065f46;
}
.stock-change.salida {
  background: #fee2e2;
  color: #991b1b;
}