/* ============================================
   WalkThru - Voice-First Home Inspection App
   Mobile-first, big-button, contractor-friendly
   ============================================ */

/* --- Custom Properties --- */
:root {
  --primary: #1E3A5F;
  --primary-light: #2E5A8F;
  --accent: #F5A623;
  --success: #27AE60;
  --danger: #E74C3C;
  --warning: #F39C12;
  --bg: #F8F9FA;
  --bg-card: #FFFFFF;
  --text: #2C3E50;
  --text-light: #7F8C8D;
  --border: #E0E0E0;

  --header-height: 56px;
  --bottom-nav-height: 72px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
  --transition: 0.2s ease;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- Loading Overlay --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: 16px;
  font-size: 1rem;
  color: var(--text-light);
}

/* --- Header --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
  max-width: 600px;
  margin: 0 auto;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-action-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.header-action-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

/* --- Main Content --- */
.app-root {
  padding-top: var(--header-height);
  padding-bottom: var(--bottom-nav-height);
  min-height: 100vh;
}

/* --- Screens --- */
.screen {
  display: block;
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
  animation: fadeIn 0.25s ease;
}

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

/* --- Bottom Navigation --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--bottom-nav-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  min-height: 48px;
  color: var(--text-light);
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn:active {
  transform: scale(0.95);
}

.nav-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.nav-icon-new {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 1.75rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  margin-top: -18px;
}

.nav-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.card:active {
  box-shadow: var(--shadow-lg);
}

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

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.card-subtitle {
  font-size: 0.875rem;
  color: var(--text-light);
  margin-top: 2px;
}

.card-body {
  font-size: 0.95rem;
  color: var(--text);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary:active {
  background: var(--primary-light);
}

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

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

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:active {
  background: var(--primary);
  color: #fff;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  min-height: 60px;
  font-size: 1.125rem;
  padding: 16px 32px;
  border-radius: var(--radius);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

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

.form-input {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

.form-input::placeholder {
  color: var(--text-light);
}

textarea.form-input {
  min-height: 120px;
  resize: vertical;
}

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

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 20px;
}

.badge-recording {
  background: rgba(231, 76, 60, 0.12);
  color: var(--danger);
}

.badge-recording::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  animation: pulse 1.2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

.badge-processing {
  background: rgba(245, 166, 35, 0.12);
  color: var(--warning);
}

.badge-complete {
  background: rgba(39, 174, 96, 0.12);
  color: var(--success);
}

.badge-error {
  background: rgba(231, 76, 60, 0.12);
  color: var(--danger);
}

/* --- Recording Screen --- */
.record-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
}

.record-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--danger);
  border: 6px solid rgba(231, 76, 60, 0.25);
  color: #fff;
  font-size: 2.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 20px rgba(231, 76, 60, 0.35);
  margin: 24px 0;
}

.record-btn:active {
  transform: scale(0.93);
}

.record-btn.recording {
  animation: recordPulse 1.5s ease infinite;
}

@keyframes recordPulse {
  0%   { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.5); }
  70%  { box-shadow: 0 0 0 20px rgba(231, 76, 60, 0); }
  100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.record-timer {
  font-size: 2.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  margin-bottom: 8px;
}

.record-hint {
  font-size: 1rem;
  color: var(--text-light);
  margin-top: 12px;
}

.record-room-label {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
}

/* --- Photo Grid --- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.photo-grid-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--border);
}

.photo-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-grid-item .photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-add-btn {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-light);
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color var(--transition);
}

.photo-add-btn:active {
  border-color: var(--primary);
  color: var(--primary);
}

.photo-add-btn .add-icon {
  font-size: 1.5rem;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 8px);
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 600px;
  margin: 0 auto;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn 0.3s ease;
}

.toast.toast-out {
  animation: toastOut 0.25s ease forwards;
}

.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warning { background: var(--warning); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-12px); }
}

/* --- Modal / Dialog --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.5);
  animation: fadeInBackdrop 0.2s ease;
}

.modal-backdrop[hidden] {
  display: none;
}

@keyframes fadeInBackdrop {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-container {
  position: fixed;
  inset: 0;
  z-index: 501;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.modal-container[hidden] {
  display: none;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow-lg);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.modal-close:active {
  background: var(--bg);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.modal-footer .btn {
  flex: 1;
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 0.95rem;
  color: var(--text-light);
  margin-bottom: 24px;
  max-width: 280px;
}

/* --- Section Headers --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  margin-top: 24px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Inspection List Item --- */
.inspection-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow var(--transition);
}

.inspection-item:active {
  box-shadow: var(--shadow-lg);
}

.inspection-item-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 58, 95, 0.08);
  border-radius: var(--radius-sm);
  font-size: 1.5rem;
  flex-shrink: 0;
}

.inspection-item-content {
  flex: 1;
  min-width: 0;
}

.inspection-item-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inspection-item-meta {
  font-size: 0.825rem;
  color: var(--text-light);
  margin-top: 2px;
}

.inspection-item-arrow {
  color: var(--text-light);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* --- Utility Classes --- */
.text-center  { text-align: center; }
.text-light   { color: var(--text-light); }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* --- Responsive --- */
@media (min-width: 480px) {
  .photo-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 768px) {
  :root {
    --header-height: 64px;
    --bottom-nav-height: 80px;
  }

  .screen {
    padding: 24px;
  }

  .record-btn {
    width: 140px;
    height: 140px;
    font-size: 3rem;
  }

  .record-timer {
    font-size: 3rem;
  }

  .photo-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
  }

  .modal {
    border-radius: var(--radius);
    align-self: center;
  }

  .modal-container {
    align-items: center;
  }
}

/* --- Skeleton Loading --- */
.skeleton {
  background: linear-gradient(90deg, #E0E0E0 25%, #F0F0F0 50%, #E0E0E0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 80px;
  margin-bottom: 8px;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
  width: 60%;
}

.skeleton-text-short {
  height: 14px;
  margin-bottom: 6px;
  width: 40%;
}

.skeleton-block {
  height: 120px;
  margin-bottom: 12px;
}

/* --- Trial/Subscription Banners --- */
.trial-banner {
  background: #FFF8E1;
  border: 1px solid #FFD54F;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: #5D4037;
}

.trial-banner a {
  color: #E65100;
  font-weight: 600;
  text-decoration: none;
}

.success-banner {
  background: #E8F5E9;
  border: 1px solid #81C784;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: #2E7D32;
}

.upgrade-banner {
  background: #FFF3E0;
  border: 1px solid #FFB74D;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: #E65100;
}

/* --- Settings Styles --- */
.settings-section {
  margin-bottom: 16px;
}

.settings-section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.logo-preview {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid var(--border);
}

.logo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: var(--bg);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-light);
  text-align: center;
}

.billing-plan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.billing-plan-name {
  font-weight: 600;
  font-size: 1rem;
}

.billing-plan-detail {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* --- Network Error State --- */
.error-state {
  text-align: center;
  padding: 48px 24px;
}

.error-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.error-state-text {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 20px;
}
