/* MACNOVA — Estilos globales App Reportes */
@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@400;600;700;800;900&display=swap');

:root {
  --rojo: #E63A14;
  --rojo-hover: #C42E0A;
  --gris-oscuro: #2E2E2E;
  --gris-claro: #F5F5F5;
  --blanco: #FFFFFF;
  --borde: #E0E0E0;
  --sombra: 0 2px 8px rgba(0,0,0,0.10);
  --radio: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Barlow', sans-serif;
  color: var(--gris-oscuro);
  background: var(--gris-claro);
  min-height: 100vh;
}

/* ── Header ── */
.header {
  background: var(--rojo);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.header-logo svg { height: 28px; width: auto; }

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-user span {
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.btn-logout {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-family: 'Barlow', sans-serif;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.35); }

/* ── Page container ── */
.page { max-width: 700px; margin: 0 auto; padding: 20px 16px 40px; }

/* ── Cards ── */
.card {
  background: var(--blanco);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gris-oscuro);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--rojo);
  border-radius: 2px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--rojo);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Barlow', sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  width: 100%;
}
.btn:hover { background: var(--rojo-hover); }
.btn:active { transform: scale(0.98); }

.btn-outline {
  background: transparent;
  color: var(--rojo);
  border: 2px solid var(--rojo);
}
.btn-outline:hover { background: var(--rojo); color: #fff; }

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  width: auto;
}

.btn-gray {
  background: var(--gris-claro);
  color: var(--gris-oscuro);
  border: 1px solid var(--borde);
}
.btn-gray:hover { background: #e8e8e8; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gris-oscuro);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--borde);
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 14px;
  font-family: 'Barlow', sans-serif;
  color: var(--gris-oscuro);
  background: #fff;
  transition: border-color 0.2s;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--rojo);
}

textarea { resize: vertical; min-height: 90px; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%232E2E2E' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ── Estado badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-bueno     { background: #d4edda; color: #155724; }
.badge-regular   { background: #fff3cd; color: #856404; }
.badge-malo      { background: #f8d7da; color: #721c24; }
.badge-fuera     { background: #d1d3e2; color: #4e5070; }
.badge-disponible { background: #d4edda; color: #155724; }
.badge-rentado   { background: #cce5ff; color: #004085; }
.badge-proyecto  { background: #e2d9f3; color: #4a235a; }
.badge-mantenimiento { background: #fff3cd; color: #856404; }

/* ── Machine card (dashboard) ── */
.machine-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--borde);
  cursor: pointer;
  transition: background 0.15s;
}
.machine-item:last-child { border-bottom: none; }
.machine-item:hover { background: #fafafa; margin: 0 -20px; padding: 14px 20px; border-radius: 6px; }

.machine-info { flex: 1; }
.machine-no { font-size: 12px; font-weight: 700; color: var(--rojo); text-transform: uppercase; }
.machine-name { font-size: 15px; font-weight: 600; margin: 2px 0; }
.machine-sub { font-size: 12px; color: #888; }

.machine-arrow { color: #ccc; font-size: 18px; margin-left: 10px; }

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-btn {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--borde);
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Barlow', sans-serif;
  cursor: pointer;
  color: var(--gris-oscuro);
  transition: all 0.2s;
}
.filter-btn.active, .filter-btn:hover {
  background: var(--rojo);
  color: #fff;
  border-color: var(--rojo);
}

/* ── Reporte item (bitácora) ── */
.report-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--borde);
}
.report-item:last-child { border-bottom: none; }
.report-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.report-fecha { font-size: 12px; color: #888; }
.report-mecanico { font-size: 12px; font-weight: 600; color: var(--gris-oscuro); }
.report-obs { font-size: 13px; color: #555; margin: 6px 0; }
.report-fotos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.report-foto {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--borde);
  cursor: pointer;
}

/* ── Reparaciones (dentro del formulario) ── */
.repair-row {
  background: var(--gris-claro);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
}
.repair-row .btn-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: #aaa;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.repair-row .btn-remove:hover { color: var(--rojo); }

/* ── Photo upload ── */
.photo-upload-area {
  border: 2px dashed var(--borde);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.photo-upload-area:hover { border-color: var(--rojo); }
.photo-upload-area p { font-size: 13px; color: #888; margin-top: 6px; }
.photo-previews { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photo-preview-item { position: relative; }
.photo-preview-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--borde);
}
.photo-preview-item .remove-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--rojo);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Login screen ── */
.login-wrap {
  min-height: 100vh;
  background: var(--rojo);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo svg { height: 36px; width: auto; }
.login-title { font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 24px; }
.login-error {
  background: #fde8e4;
  color: var(--rojo);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}

/* ── Page title ── */
.page-title {
  font-size: 20px;
  font-weight: 800;
  margin: 16px 0 4px;
  color: var(--gris-oscuro);
}
.page-subtitle {
  font-size: 13px;
  color: #888;
  margin-bottom: 20px;
}

/* ── Alert / toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gris-oscuro);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: #1a7f4b; }
.toast.error { background: var(--rojo-hover); }

/* ── Stats row (admin) ── */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: #fff;
  border-radius: var(--radio);
  padding: 16px;
  text-align: center;
  box-shadow: var(--sombra);
}
.stat-number { font-size: 28px; font-weight: 800; color: var(--rojo); }
.stat-label { font-size: 11px; font-weight: 600; color: #888; text-transform: uppercase; margin-top: 2px; }

/* ── Table (admin) ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--gris-oscuro);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
tbody tr:nth-child(even) { background: var(--gris-claro); }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--borde); vertical-align: middle; }

/* ── Search input ── */
.search-wrap { position: relative; margin-bottom: 16px; }
.search-wrap input { padding-left: 36px; }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  font-size: 16px;
  pointer-events: none;
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #aaa;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Loading ── */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #f0f0f0;
  border-top-color: var(--rojo);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FAB (floating action button) ── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 20px;
  background: var(--rojo);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(230,58,20,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  z-index: 50;
}
.fab:hover { background: var(--rojo-hover); transform: scale(1.05); }

/* ── Back link ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--rojo);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 12px;
}
.back-link:hover { text-decoration: underline; }

/* ── Insignia "editado" ── */
.editado-tag {
  display: inline-block;
  background: #fff3cd;
  color: #856404;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
  vertical-align: middle;
}

/* ── Folio en bitácora ── */
.report-folio { font-size: 11px; font-weight: 700; color: var(--rojo); letter-spacing: .3px; }

/* ── Responsive tweaks ── */
@media (max-width: 480px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat-number { font-size: 22px; }
}

/* ===== Módulo Piezas / Compras ===== */
.badge-flujo-pendiente { background:#FFF3CD; color:#8A6D00; }
.badge-flujo-proceso   { background:#D6E4FF; color:#1A4FB4; }
.badge-flujo-listo     { background:#D4EDDA; color:#155724; }
.badge-flujo-cancel    { background:#EEE;    color:#777; }

/* Tablero "me toca" */
.metoca-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:10px; margin-bottom:18px; }
.metoca-card { background:var(--blanco); border:1px solid var(--borde); border-left:4px solid var(--rojo);
  border-radius:var(--radio); padding:14px 16px; box-shadow:var(--sombra); min-width:0; overflow:hidden; }
/* Montos grandes: se encogen y, en último caso, se parten — nunca se salen de la tarjeta */
.metoca-card .n { font-size:clamp(19px, 1.6vw + 12px, 27px); font-weight:900; color:var(--rojo); line-height:1.1; overflow-wrap:anywhere; }
.metoca-card .l { font-size:12px; color:#555; margin-top:4px; font-weight:600; }

/* Renglones de piezas (formulario dinámico) */
.item-row { display:grid; grid-template-columns:2fr 1fr 70px 90px 110px 34px; gap:8px; align-items:end; margin-bottom:8px; }
.item-row .form-group { margin:0; }
@media (max-width:640px){ .item-row { grid-template-columns:1fr 1fr; } }

/* Tabla comparativa de cotizaciones */
.cotiza-card { border:1px solid var(--borde); border-radius:var(--radio); padding:14px; margin-bottom:10px; position:relative; }
.cotiza-card.sel { border-color:var(--rojo); box-shadow:0 0 0 2px rgba(230,58,20,.15); }
.cotiza-card .prov { font-weight:700; font-size:14px; }
.cotiza-card .meta { font-size:12px; color:#777; margin-top:2px; }
.cotiza-card .tot { font-size:18px; font-weight:800; color:var(--gris-oscuro); }

/* Bloque de la Orden de Compra */
.oc-box { border:2px solid var(--gris-oscuro); border-radius:var(--radio); padding:18px; }
.oc-folio { font-family:monospace; font-weight:800; font-size:16px; color:var(--rojo); letter-spacing:.5px; }
.aviso-revision { background:#FFF3CD; border:1px solid #FFE08A; color:#8A6D00; padding:10px 12px;
  border-radius:8px; font-size:12.5px; margin-top:12px; }

/* Stepper compacto del flujo */
.flujo-steps { display:flex; flex-wrap:wrap; gap:6px; margin:10px 0 4px; }
.flujo-steps .s { font-size:11px; padding:3px 8px; border-radius:20px; background:#eee; color:#999; font-weight:600; }
.flujo-steps .s.done { background:#D4EDDA; color:#155724; }
.flujo-steps .s.now  { background:var(--rojo); color:#fff; }

.back-link2 { display:inline-block; margin-bottom:12px; color:var(--rojo); font-weight:600; font-size:13px; text-decoration:none; }
