/* ==============================================================================
   AiFitProspectLite Modern Design System & Stylesheet (style.css)
   ============================================================================== */

:root {
  --primary: #0284C7;
  --primary-hover: #0369A1;
  --primary-light: rgba(2, 132, 199, 0.1);
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #E11D48;
  
  --bg-page: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-subcard: #F1F5F9;
  
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  
  --border-color: #E2E8F0;
  --border-focus: #38BDF8;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.1);
  --shadow-xl: 0 20px 40px rgba(15, 23, 42, 0.15);
  
  --font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* App Shell Layout */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #0284C7, #06B6D4);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 1.1rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.5px;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.coach-badge-btn {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.coach-badge-btn:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.coach-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
}

/* Main Content Area */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* Section Cards */
.section-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  margin-bottom: 24px;
  transition: var(--transition);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  gap: 16px;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* 2-Column Grid for Input & Photo */
.lead-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .lead-grid {
    grid-template-columns: 1fr;
  }
}

.sub-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.card-header-sm {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.card-title-sm {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-light {
  background: #F1F5F9;
  color: #475569;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #D97706;
}

.badge-danger {
  background: rgba(225, 29, 72, 0.12);
  color: var(--danger);
}

/* Forms */
.form-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 5px;
}

.form-input, .form-select {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  color: var(--text-main);
  transition: var(--transition);
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

/* TANITA 8 Metrics Grid */
.tanita-block {
  margin-top: 14px;
}

.tanita-heading {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.tanita-8-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 600px) {
  .tanita-8-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.metric-input-item {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-direction: column;
}

.m-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
}

.m-input {
  width: 100%;
  padding: 5px 8px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  background: #FFFFFF;
  text-align: right;
}

/* Photo Card & Guidance */
.camera-guide-banner {
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.guide-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--primary);
  font-size: 0.82rem;
}

.guide-icon {
  font-size: 0.75rem;
}

.guide-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}

/* Photo Preview Box (9:16 optimized) */
.photo-preview-wrap {
  width: 100%;
  height: 280px;
  background: #0F172A;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #CBD5E1;
}

.photo-preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.photo-empty-state {
  text-align: center;
  color: #94A3B8;
  padding: 20px;
}

.empty-icon {
  font-size: 2.4rem;
  color: #38BDF8;
}

.empty-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #F8FAFC;
  margin-top: 8px;
}

.empty-subtitle {
  font-size: 0.78rem;
  color: #94A3B8;
  margin-top: 4px;
}

/* Aspect Notice */
.aspect-notice {
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}

.btn-outline {
  background: #FFFFFF;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: #F8FAFC;
  border-color: #CBD5E1;
}

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

.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: var(--warning);
  color: #0F172A;
  font-weight: 700;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 12px 22px;
  font-size: 0.95rem;
  font-weight: 700;
}

.btn-block {
  width: 100%;
}

.photo-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.photo-actions-row .btn {
  flex: 1;
}

/* ==============================================================================
   STEP 2: Result & Dual Comparison Showcase
   ============================================================================== */
.result-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.tab-pill-group {
  display: flex;
  background: #E2E8F0;
  padding: 4px;
  border-radius: var(--radius-full);
  gap: 4px;
}

.tab-pill {
  border: none;
  background: transparent;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.tab-pill.active {
  background: #FFFFFF;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Comparison Display Stage */
.compare-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .compare-stage {
    gap: 6px;
  }
}

.stage-box {
  background: #0B0F17;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid #334155;
  display: flex;
  flex-direction: column;
}

.stage-header-bar {
  background: #1E293B;
  color: #F8FAFC;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 7px 10px;
  border-bottom: 1px solid #334155;
  letter-spacing: 0.5px;
  user-select: none;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .stage-header-bar {
    font-size: 0.8rem;
    padding: 6px 4px;
  }
}

.stage-tag {
  display: none;
}

.stage-img-wrap {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 540px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Loading & Alert Overlays */
.stage-loading-overlay, .stage-alert-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  color: #FFFFFF;
  z-index: 10;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #38BDF8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

.loading-text {
  font-weight: 600;
  font-size: 0.85rem;
}

.alert-icon {
  font-size: 2.2rem;
  color: var(--warning);
  margin-bottom: 6px;
}

.alert-title {
  font-size: 1rem;
  font-weight: 800;
  color: #FFFFFF;
}

.alert-desc {
  font-size: 0.78rem;
  color: #CBD5E1;
  margin-top: 4px;
  line-height: 1.4;
}

.alert-subdesc {
  font-size: 0.72rem;
  color: #94A3B8;
  margin-top: 6px;
  margin-bottom: 14px;
}

/* 1+3 Metrics Board */
.metrics-board {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

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

.board-title {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-main);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 600px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  background: #F8FAFC;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.card-span-2 {
  grid-column: span 2;
}

@media (max-width: 600px) {
  .card-span-2 {
    grid-column: span 1;
  }
}

.mc-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.mc-value {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 4px 0 2px;
  letter-spacing: -0.5px;
}

.mc-sub {
  font-size: 0.75rem;
  color: #64748B;
}

.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-warning { color: #D97706; }
.text-success { color: #059669; }
.text-muted { color: #334155; }

.schedule-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 6px 0;
  flex-wrap: wrap;
  gap: 8px;
}

.sch-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sch-val {
  font-size: 0.95rem;
  font-weight: 700;
  margin-left: 4px;
}

.sch-coach {
  color: var(--primary);
  font-weight: 700;
}

/* Contour Banner */
.contour-banner {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 0.82rem;
  color: #1E3A8A;
}

.contour-title {
  color: #1E40AF;
}

/* Disclaimer */
.disclaimer-box {
  margin-top: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  background: #F1F5F9;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  line-height: 1.45;
}

/* Result Actions Row */
.result-actions-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-poster-dialog {
  max-width: 480px;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

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

.modal-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.modal-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-poster-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0F172A;
  padding: 12px;
}

.poster-preview-wrap {
  max-height: 65vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.poster-preview-wrap img {
  max-height: 65vh;
  width: auto;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #F8FAFC;
}

/* Coach Settings Modal Enhancements */
.modal-tabs-nav {
  display: flex;
  background: #F1F5F9;
  border-bottom: 1px solid var(--border-color);
  padding: 4px 8px;
  gap: 6px;
}

.modal-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.modal-tab-btn.active {
  background: #FFFFFF;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.cfg-panel {
  display: flex;
  flex-direction: column;
}

.form-help {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.ai-security-callout {
  background: rgba(2, 132, 199, 0.08);
  border: 1px solid rgba(2, 132, 199, 0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.78rem;
  color: #1E3A8A;
  line-height: 1.45;
}

.callout-badge {
  display: inline-block;
  background: #0284C7;
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.provider-radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 480px) {
  .provider-radio-group {
    grid-template-columns: 1fr;
  }
}

.provider-radio-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: #F8FAFC;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.provider-radio-card:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.provider-radio-card input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--primary);
}

.provider-radio-card.active {
  border-color: var(--primary);
  background: rgba(2, 132, 199, 0.06);
}

.pr-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.pr-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.link-external {
  font-size: 0.75rem;
  color: var(--primary);
  margin-left: 8px;
  text-decoration: underline;
  font-weight: 500;
}

.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
}

.test-conn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.test-result-text {
  font-size: 0.78rem;
  font-weight: 600;
  flex: 1;
}

.test-result-text.success {
  color: #059669;
}

.test-result-text.error {
  color: #E11D48;
}

.test-result-text.loading {
  color: #0284C7;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background: #FFFFFF;
}

