/* ============================================================
   Quality Roofing – Generador de Reportes
   Mobile-first | Alto contraste | Botones grandes
   ============================================================ */

:root {
  /* Paleta oficial Quality Roofing (extraída del logo SVG) */
  --c-primary: #ef0000;          /* rojo de marca – CTAs principales */
  --c-primary-dark: #c30000;
  --c-primary-light: #ff3939;
  --c-dark: #393432;             /* gris oscuro – "Roofing" del logo */
  --c-dark-soft: #5a5350;
  --c-gray: #a8a8a9;             /* gris medio – "Quality" del logo */
  --c-accent: #ef0000;
  --c-accent-dark: #c30000;
  --c-success: #2e7d32;
  --c-success-dark: #1b5e20;
  --c-warning: #f29100;
  --c-bg: #f5f5f5;
  --c-card: #ffffff;
  --c-text: #1f1d1c;
  --c-text-soft: #6d6764;
  --c-border: #e1e1e2;
  --c-border-focus: #ef0000;
  --c-danger: #c30000;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 14px rgba(0,0,0,.10);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.18);

  --tap: 48px;
  --font-base: 17px;
  --font-sm: 14px;
  --font-lg: 19px;

  --header-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; font-size: 16px; }

body {
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--font-base);
  line-height: 1.45;
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  padding-bottom: 32px;
  -webkit-tap-highlight-color: transparent;
  font-weight: 500;
}
h1, h2, h3, .brand strong { font-weight: 700; letter-spacing: -.01em; }

/* ===================== HEADER ===================== */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: #ffffff;
  color: var(--c-dark);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--c-border);
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  min-height: var(--header-h);
}
.app-header__back {
  background: var(--c-bg);
  color: var(--c-dark);
  border: 1px solid var(--c-border);
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex: none;
  transition: background .15s ease, border-color .15s ease;
}
.app-header__back:hover { background: #ececec; border-color: var(--c-gray); }

.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand__logo {
  height: 36px;
  width: auto;
  max-width: 165px;
  flex: none;
  display: block;
}
.brand__text {
  display: flex; flex-direction: column; line-height: 1.15;
  min-width: 0; overflow: hidden;
  border-left: 2px solid var(--c-border);
  padding-left: 12px;
}
.brand__text small {
  font-size: 12px;
  color: var(--c-text-soft);
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* Indicador "Guardado ✓" */
.save-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--c-bg);
  color: var(--c-dark);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
  flex: none;
  border: 1px solid var(--c-border);
}
.save-indicator__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c-success);
}
.save-indicator.is-saving .save-indicator__dot {
  background: var(--c-warning);
  animation: pulse 1s ease infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.3); opacity: .5; }
}

/* ===================== MAIN / VIEWS ===================== */
.app-main { padding-bottom: 24px; }
.view { display: none; animation: fadeIn .2s ease; }
.view[hidden] { display: none !important; }
.view:not([hidden]) { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

.view__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.view__header h1 {
  font-size: 24px;
  margin: 0 0 4px;
  color: var(--c-dark);
  word-break: break-word;
}
.view__sub {
  margin: 0;
  color: var(--c-text-soft);
  font-size: 14px;
}

/* ===================== FORM ===================== */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field__group-label { font-weight: 700; color: var(--c-dark); font-size: 15px; }
.field__hint { margin: 0 0 8px; color: var(--c-text-soft); font-size: 13px; }
.field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="search"],
input:not([type]),
select,
textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--font-base);
  font-weight: 500;
  color: var(--c-text);
  background: #fff;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: var(--tap);
  line-height: 1.3;
  transition: border-color .15s ease, box-shadow .15s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  outline: none;
  box-shadow: none;
  box-sizing: border-box;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.4; }
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%235d6d7e' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}
/* Ocultar el indicador nativo de datalist (Chrome/Edge) */
input[list]::-webkit-calendar-picker-indicator {
  display: none !important;
  opacity: 0;
}
input[list] {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%235d6d7e' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--c-border-focus);
  box-shadow: 0 0 0 3px rgba(239, 0, 0, .15);
}
/* Anular el highlight nativo de validación que cambia el borde */
input:invalid, input:valid, textarea:invalid, textarea:valid { box-shadow: none; }
/* Autofill: mantener fondo blanco */
input:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px #fff inset; }

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: 1fr; }
@media (min-width: 540px) {
  .grid--2 { grid-template-columns: 1fr 1fr; }
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: var(--font-base);
  font-weight: 700;
  letter-spacing: .2px;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 20px;
  min-height: var(--tap);
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, box-shadow .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn--primary {
  background: var(--c-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: var(--c-primary-dark); }
.btn--success {
  background: var(--c-success);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.btn--success:hover { background: var(--c-success-dark); }
.btn--ghost {
  background: transparent;
  color: var(--c-dark);
  border: 1.5px solid var(--c-border);
}
.btn--ghost:hover { background: var(--c-bg); border-color: var(--c-gray); }
.btn--small { font-size: 14px; padding: 8px 14px; min-height: 38px; }
.btn--xl { font-size: 18px; padding: 18px 24px; width: 100%; }
.btn--danger { background: transparent; color: var(--c-danger); border: 1.5px solid var(--c-danger); }
.btn--danger:hover { background: rgba(192, 57, 43, .08); }

/* ===================== SEARCH ===================== */
.search { margin-bottom: 14px; }
.search input { background: #fff; }

/* ===================== PROJECTS LIST ===================== */
.projects { display: flex; flex-direction: column; gap: 10px; }
.project-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  border-left: 4px solid var(--c-primary);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .08s ease, box-shadow .15s ease;
}
.project-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.project-card__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
  margin: 0;
  word-break: break-word;
}
.project-card__sub {
  font-size: 13px;
  color: var(--c-text-soft);
  margin: 0;
}
.project-card__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--c-text-soft);
  margin-top: 4px;
}
.project-card__badge {
  background: rgba(239, 0, 0, .08);
  color: var(--c-primary);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

/* ===================== EMPTY STATES ===================== */
.empty-state {
  text-align: center;
  padding: 36px 16px;
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--c-border);
}
.empty-state__icon { font-size: 56px; margin-bottom: 8px; }
.empty-state h2 { font-size: 19px; margin: 0 0 6px; color: var(--c-dark); }
.empty-state p { margin: 0 0 18px; color: var(--c-text-soft); }
.empty-inline {
  margin: 12px 0 0;
  color: var(--c-text-soft);
  font-size: 14px;
  text-align: center;
  padding: 12px;
}

/* ===================== ACCORDION ===================== */
.accordion {
  background: #fff;
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.accordion__head {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  min-height: var(--tap);
  user-select: none;
  position: relative;
}
.accordion__head::-webkit-details-marker { display: none; }
.accordion__num, .accordion__icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--c-dark);
  color: #fff;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex: none;
}
.accordion__icon { background: var(--c-bg); color: var(--c-dark); font-size: 18px; border: 1px solid var(--c-border); }
.accordion__title {
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  color: var(--c-text);
  min-width: 0;
}
.accordion__check {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--c-border);
  color: var(--c-text-soft);
  flex: none;
}
.accordion__check.is-ok {
  background: var(--c-success);
  color: #fff;
}
.accordion__check.is-warn {
  background: var(--c-warning);
  color: #fff;
}
.accordion__chev {
  font-size: 18px;
  color: var(--c-text-soft);
  transition: transform .2s ease;
  flex: none;
}
.accordion[open] .accordion__chev { transform: rotate(180deg); }
.accordion__body {
  padding: 4px 16px 18px;
  border-top: 1px solid var(--c-border);
  background: #fafbfc;
}

/* ===================== TOC ===================== */
.toc {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 0 -16px 14px;
  padding: 0 16px 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.toc::-webkit-scrollbar { display: none; }
.toc__item {
  flex: none;
  text-decoration: none;
  color: var(--c-dark);
  background: #fff;
  border: 1.5px solid var(--c-border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.toc__item:hover { background: rgba(239, 0, 0, .06); border-color: var(--c-primary); color: var(--c-primary); }

/* ===================== REPORTS LIST ===================== */
.reports-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.reports-actions .btn { flex: 1 1 auto; min-width: 130px; }
.reports { display: flex; flex-direction: column; gap: 8px; }
.report-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-left: 4px solid var(--c-primary);
  transition: box-shadow .15s ease;
}
.report-card:hover { box-shadow: var(--shadow-sm); }
.report-card--avance { border-left-color: var(--c-warning); }
.report-card__icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--c-bg);
  color: var(--c-dark);
  border: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex: none;
}
.report-card--avance .report-card__icon {
  background: rgba(243,156,18,.12);
  color: var(--c-warning);
}
.report-card__body { flex: 1; min-width: 0; }
.report-card__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.report-card__meta {
  font-size: 12px;
  color: var(--c-text-soft);
}
.report-card__arrow { color: var(--c-text-soft); font-size: 20px; }

/* ===================== CHIPS ===================== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid var(--c-border);
  color: var(--c-text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--c-primary); }
.chip.is-on {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}
.chip.is-on::before { content: "✓"; font-weight: 800; }
.chips__add {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.chips__add input { flex: 1; }

/* ===================== UPLOAD ===================== */
.upload__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px 16px;
  border: 2.5px dashed var(--c-primary-light);
  border-radius: var(--radius);
  background: rgba(10,61,98,.04);
  color: var(--c-primary);
  cursor: pointer;
  font-weight: 700;
  min-height: 120px;
  transition: background .15s ease, border-color .15s ease;
}
.upload__btn:hover { background: rgba(10,61,98,.08); }
.upload__btn svg { width: 36px; height: 36px; }
.upload__btn span { font-size: 16px; }
.upload__btn small { font-weight: 500; color: var(--c-text-soft); font-size: 13px; }
.upload__status { margin: 10px 0 0; color: var(--c-text-soft); font-size: 14px; text-align: center; }

/* ===================== PHOTOS ===================== */
.photos {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}
@media (min-width: 540px) {
  .photos { grid-template-columns: 1fr 1fr; }
}
.photo-card {
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--c-border);
}
.photo-card__img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e9ecef;
  display: block;
}
.photo-card__body {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.photo-card__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--c-dark);
  margin: 0;
  word-break: break-word;
  text-transform: uppercase;
  line-height: 1.25;
}
.photo-card__actions { display: flex; gap: 6px; }
.photo-card__actions .btn { flex: 1; font-size: 12px; padding: 6px 8px; min-height: 32px; }

/* ===================== REPORT FOOTER ===================== */
.report-footer {
  margin-top: 24px;
  padding: 18px 0;
  border-top: 1px solid var(--c-border);
}

/* ===================== OVERLAY ===================== */
.overlay {
  position: fixed; inset: 0;
  background: rgba(10,17,28,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.overlay__box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  text-align: center;
  min-width: 220px;
  box-shadow: var(--shadow-lg);
}
.spinner {
  width: 36px; height: 36px;
  border: 4px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== MODAL ===================== */
.modal {
  position: fixed; inset: 0;
  background: rgba(10,17,28,.55);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 90;
  padding: 0;
}
@media (min-width: 540px) {
  .modal { align-items: center; padding: 16px; }
}
.modal__box {
  background: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@media (min-width: 540px) {
  .modal__box { border-radius: var(--radius-lg); }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.modal__box h2 { margin: 0 0 6px; color: var(--c-dark); font-size: 19px; }
.modal__hint { margin: 0 0 12px; color: var(--c-text-soft); font-size: 14px; }
.modal__box input { margin-bottom: 16px; }
.modal__nav { display: flex; gap: 10px; }
.modal__nav .btn { flex: 1; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--c-text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  animation: toastIn .2s ease;
  max-width: 90%;
  text-align: center;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ===================== UTILS ===================== */
[hidden] { display: none !important; }
.campos-avance { display: contents; }
