/* assets/css/components.css
   Shared, reusable UI components: cards, buttons, status pills, inputs,
   segmented controls. Used by both the inspector-facing pages and admin.
*/

/* ---- Cards ---- */
.card {
  background: var(--hf-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 16px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--hf-navy);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--hf-navy-dark); }

.btn-gold {
  background: var(--hf-gold);
  color: var(--hf-navy-dark);
}
.btn-gold:hover:not(:disabled) { background: var(--hf-gold-dark); }

.btn-secondary {
  background: var(--hf-white);
  color: var(--hf-navy);
  border-color: var(--hf-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--hf-bg); }

.btn-danger {
  background: var(--status-not-compliant);
  color: white;
}

.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: 0.88rem; }

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Status pills (always paired with visible text) ---- */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-compliant { background: var(--status-compliant-bg); color: var(--status-compliant); }
.status-compliant .dot { background: var(--status-compliant); }

.status-not-compliant { background: var(--status-not-compliant-bg); color: var(--status-not-compliant); }
.status-not-compliant .dot { background: var(--status-not-compliant); }

.status-not-applicable { background: var(--status-not-applicable-bg); color: var(--status-not-applicable); }
.status-not-applicable .dot { background: var(--status-not-applicable); }

.status-draft { background: var(--status-draft-bg); color: var(--status-draft); }
.status-draft .dot { background: var(--status-draft); }

.status-submitted { background: var(--status-submitted-bg); color: var(--status-submitted); }
.status-submitted .dot { background: var(--status-submitted); }

.status-stand-by { background: var(--status-standby-bg); color: var(--status-standby); }
.status-stand-by .dot { background: var(--status-standby); }

.status-ready-for-review { background: var(--status-review-bg); color: var(--status-review); }
.status-ready-for-review .dot { background: var(--status-review); }

.status-finalized { background: var(--status-finalized-bg); color: var(--status-finalized); }
.status-finalized .dot { background: var(--status-finalized); }

.status-reopened { background: var(--status-reopened-bg); color: var(--status-reopened); }
.status-reopened .dot { background: var(--status-reopened); }

.status-overdue { background: var(--status-overdue-bg); color: var(--status-overdue); }
.status-overdue .dot { background: var(--status-overdue); }

/* ---- Form controls ---- */
.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-weight: 600;
  color: var(--hf-navy);
  margin-bottom: 6px;
  font-size: 0.92rem;
}
.field .field-hint {
  font-size: 0.82rem;
  color: var(--hf-text-muted);
  margin-top: 4px;
}
.field .field-error {
  font-size: 0.85rem;
  color: var(--status-not-compliant);
  margin-top: 6px;
  font-weight: 600;
}
.field[data-required] label::after {
  content: " *";
  color: var(--status-not-compliant);
}

input[type="text"],
input[type="date"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--hf-border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  color: var(--hf-charcoal);
  background: var(--hf-white);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--hf-blue);
}
input.invalid, select.invalid, textarea.invalid {
  border-color: var(--status-not-compliant);
}

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

/* ---- Segmented / radio-card controls for Compliant / Not Compliant / N/A ---- */
.result-options {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
@media (max-width: 480px) {
  .result-options {
    grid-template-columns: 1fr;
  }
}
.result-option {
  position: relative;
}
.result-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.result-option .option-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  border: 2px solid var(--hf-border);
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  padding: 10px;
  background: var(--hf-white);
  color: var(--hf-charcoal);
}
.result-option input[type="radio"]:checked + .option-card {
  border-color: currentColor;
}
.result-option.opt-compliant input:checked + .option-card {
  background: var(--status-compliant-bg);
  color: var(--status-compliant);
  border-color: var(--status-compliant);
}
.result-option.opt-not-compliant input:checked + .option-card {
  background: var(--status-not-compliant-bg);
  color: var(--status-not-compliant);
  border-color: var(--status-not-compliant);
}
.result-option.opt-not-applicable input:checked + .option-card {
  background: var(--status-not-applicable-bg);
  color: var(--status-not-applicable);
  border-color: var(--status-not-applicable);
}
.result-option input[type="radio"]:focus-visible + .option-card {
  outline: 3px solid var(--hf-gold);
  outline-offset: 2px;
}

/* ---- Checkbox ---- */
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.checkbox-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ---- Photo previews ---- */
.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.photo-thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--hf-border);
}
.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb .remove-photo {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(20, 20, 20, 0.72);
  color: white;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-thumb .upload-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: var(--hf-gold);
}
.photo-thumb:has(.photo-thumb-error) {
  width: auto;
  height: auto;
  min-width: 220px;
  border-color: var(--status-not-compliant);
  background: var(--status-not-compliant-bg);
}
.photo-thumb-error {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  width: 100%;
}
.photo-thumb-error .field-error {
  font-size: 0.85rem;
  line-height: 1.3;
}

/* ---- Alerts / banners ---- */
.banner {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-bottom: 16px;
  font-weight: 600;
}
.banner-info { background: var(--status-submitted-bg); color: var(--status-submitted); }
.banner-warn { background: var(--status-standby-bg); color: var(--status-standby); }
.banner-error { background: var(--status-not-compliant-bg); color: var(--status-not-compliant); }
.banner-success { background: var(--status-compliant-bg); color: var(--status-compliant); }

/* ---- Empty / loading / error states ---- */
.state-block {
  text-align: center;
  padding: 40px 20px;
  color: var(--hf-text-muted);
}
.state-block h3 { color: var(--hf-charcoal); }

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--hf-border);
  border-top-color: var(--hf-navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Table -> card responsive pattern ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--hf-white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.data-table th, .data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hf-border);
  font-size: 0.9rem;
}
.data-table th {
  background: var(--hf-bg);
  color: var(--hf-navy);
  font-weight: 700;
}

@media (max-width: 700px) {
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    background: var(--hf-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 12px;
    padding: 8px 4px;
  }
  .data-table td {
    border-bottom: none;
    padding: 6px 14px;
  }
  .data-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--hf-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
}
