/* HomeReady Repairs — senior-friendly, offline-first UI */

:root {
  --accent: #1B5E4A;
  --accent-hover: #144536;
  --accent-soft: #E6F2EE;
  --accent-mid: #2A8A6A;
  --danger: #9B1C1C;
  --danger-hover: #7A1515;
  --danger-soft: #FDECEC;
  --warning: #8A5A00;
  --warning-soft: #FFF6E0;
  --text: #1A1A1A;
  --text-muted: #4A4A4A;
  --border: #C8CFC9;
  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --space: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --touch: 48px;
  --max-width: 720px;
  --focus: 3px solid #0B3D2E;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
  outline: var(--focus);
  outline-offset: 2px;
}

/* Header */
.app-header {
  background: var(--accent);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px var(--space);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-tagline {
  margin: 2px 0 0;
  font-size: 0.9rem;
  opacity: 0.92;
  line-height: 1.2;
}

.btn-icon {
  min-width: var(--touch);
  min-height: var(--touch);
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: transparent;
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 1.35rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.btn-icon:hover,
.btn-icon:focus-visible {
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

.btn-icon:focus-visible {
  box-shadow: 0 0 0 3px #fff;
}

/* Nav */
.nav-panel {
  background: var(--accent-hover);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.nav-list {
  list-style: none;
  margin: 0 auto;
  padding: 8px var(--space) 12px;
  max-width: var(--max-width);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  width: 100%;
  min-height: var(--touch);
  text-align: left;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: none;
}

.nav-link[aria-current="page"] {
  background: rgba(255, 255, 255, 0.22);
}

/* Main */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-lg) var(--space) var(--space-xl);
}

.view-title {
  margin: 0 0 8px;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.view-intro {
  margin: 0 0 var(--space-lg);
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: var(--space-lg);
}

@media (min-width: 520px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card-alert {
  border-color: #E0A8A8;
  background: var(--danger-soft);
}

.stat-value {
  display: block;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-card-alert .stat-value {
  color: var(--danger);
}

.stat-label {
  display: block;
  margin-top: 6px;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Panels & cards */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
  margin-bottom: var(--space);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.panel-header .panel-title {
  margin: 0;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.repair-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel .repair-card {
  box-shadow: none;
  background: var(--bg);
}

.repair-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.repair-card-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.repair-card-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.repair-card-desc {
  margin: 0;
  color: var(--text);
}

.repair-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-planned {
  background: #E8EEF5;
  color: #1A3A5C;
}

.badge-in-progress {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-completed {
  background: #E8F0E4;
  color: #2D5A1E;
}

.badge-call-pro {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-easy {
  background: #E8F0E4;
  color: #2D5A1E;
}

.badge-moderate {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-hard {
  background: #F5E8E0;
  color: #7A3A12;
}

.badge-pro-only {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-category {
  background: #EEF0F2;
  color: #333;
}

.badge-sample {
  background: #EDE7F6;
  color: #4A2C7A;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-secondary:hover {
  background: var(--accent-soft);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-text {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  min-height: 44px;
  padding: 8px 12px;
  font-weight: 600;
}

.btn-text:hover {
  background: var(--accent-soft);
}

.btn-text-inline {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  min-height: auto;
}

.btn-text-inline:focus-visible {
  outline: var(--focus);
  outline-offset: 2px;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: var(--touch);
  padding: 10px 14px;
  font-size: 1rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.quick-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: var(--space);
}

/* Forms */
.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
  margin: 0 0 var(--space);
  background: var(--surface);
}

.fieldset legend {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 8px;
  color: var(--text);
}

.field {
  margin-bottom: 16px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.field-grow {
  flex: 1 1 160px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.required {
  color: var(--danger);
}

.field input[type="text"],
.field input[type="search"],
.field input[type="date"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 12px 14px;
  font: inherit;
  font-size: 1.05rem;
  color: var(--text);
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(27, 94, 74, 0.25);
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--danger);
}

.field-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.95rem;
}

.field-hint {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.toolbar {
  margin-bottom: var(--space);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space);
  box-shadow: var(--shadow);
}

.toolbar .field {
  margin-bottom: 12px;
}

.toolbar .field:last-child {
  margin-bottom: 0;
}

/* Steps editor */
.steps-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.step-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.step-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.step-number {
  font-weight: 700;
  color: var(--accent);
}

.step-row-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.step-row textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  font: inherit;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.step-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(27, 94, 74, 0.25);
}

/* Photo */
.photo-preview {
  margin-top: 12px;
}

.photo-preview img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  max-height: 240px;
  object-fit: contain;
  background: var(--bg);
  margin-bottom: 12px;
}

/* Detail view */
.back-btn {
  margin-bottom: 12px;
  padding-left: 0;
}

.detail-hero {
  margin-bottom: var(--space);
}

.detail-title {
  margin: 0 0 10px;
  font-size: 1.55rem;
  line-height: 1.25;
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.detail-section {
  margin-bottom: var(--space);
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  color: var(--accent);
}

.detail-section p,
.detail-section li {
  color: var(--text);
}

.detail-list {
  margin: 0;
  padding-left: 1.35rem;
}

.detail-list li {
  margin-bottom: 6px;
}

.steps-walkthrough {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.step-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step-check {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

.step-body {
  flex: 1;
  min-width: 0;
}

.step-item-label {
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.step-item-text {
  margin: 0;
}

.step-item.done {
  background: var(--accent-soft);
  border-color: #A8C9BC;
}

.step-item.done .step-item-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.call-pro-banner {
  background: var(--danger-soft);
  border: 2px solid #E0A8A8;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--space);
}

.call-pro-banner h3 {
  margin: 0 0 8px;
  color: var(--danger);
  font-size: 1.15rem;
}

.call-pro-banner p {
  margin: 0;
  color: var(--text);
}

.safety-banner {
  background: var(--warning-soft);
  border: 2px solid #E0C878;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--space);
}

.safety-banner h3 {
  margin: 0 0 8px;
  color: var(--warning);
  font-size: 1.15rem;
}

.safety-banner p {
  margin: 0;
}

.progress-bar-wrap {
  margin: 12px 0 4px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.progress-bar {
  height: 12px;
  background: #DDE5E1;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
  min-width: 0;
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: var(--space);
}

/* Insights */
.insight-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.insight-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
}

.insight-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.insight-list li:first-child {
  padding-top: 0;
}

.insight-label {
  color: var(--text);
  font-weight: 500;
}

.insight-value {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.reminder-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.reminder-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reminder-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.reminder-item.overdue {
  border-color: #E0A8A8;
  background: var(--danger-soft);
}

.reminder-text {
  margin: 0;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

.reminder-date {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Settings */
.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.status-msg {
  margin: 12px 0 0;
  font-weight: 600;
  color: var(--accent);
  min-height: 1.5em;
}

.status-msg.is-error {
  color: var(--danger);
}

.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space);
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 1.05rem;
}

/* Footer */
.app-footer {
  background: #E8ECEA;
  border-top: 1px solid var(--border);
  padding: 18px var(--space);
  text-align: center;
}

.app-footer p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: var(--max-width);
  margin-inline: auto;
}

/* Dialog */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space);
}

.dialog {
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--space-lg);
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.dialog-title {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

.dialog-message {
  margin: 0 0 var(--space);
  color: var(--text-muted);
  font-size: 1.05rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.dialog-actions .btn {
  flex: 1 1 auto;
  min-width: 120px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 14px 22px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1.05rem;
  z-index: 300;
  max-width: calc(100% - 32px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  text-align: center;
}

/* Utility */
[hidden] {
  display: none !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
