/**
 * @file
 * Mattress Finder Styles
 * Based on Dunlopillo brand design system
 */

/* ===== CSS Variables (Brand Colors) ===== */
:root {
  --mf-primary: #5e9cd1;
  /* 主色 - 青藍 */
  --mf-primary-hover: #4e8cc1;
  /* Hover 狀態 */
  --mf-accent: #32c5d2;
  /* 輔助色 - 青綠 */
  --mf-text-heading: #3f444a;
  /* 標題 */
  --mf-text-body: #677581;
  /* 內文 */
  --mf-text-muted: #7f8c97;
  /* 次要文字 */
  --mf-bg-main: #ffffff;
  /* 主背景 */
  --mf-bg-light: #f7f7f7;
  /* 淺灰背景 */
  --mf-border: #eeeeee;
  /* 邊框 */
  --mf-input-border: #d0d7de;
  /* 輸入框邊框 */
  --mf-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --mf-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
  --mf-transition: all 0.3s ease;
}

/* ===== Base Styles ===== */
.mattress-finder-wrapper {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 17px;
  color: var(--mf-text-body);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ===== Trigger Button ===== */
.mf-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--mf-primary);
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 4px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--mf-transition);
  box-shadow: var(--mf-shadow);
}

.mf-trigger:hover {
  background: var(--mf-primary-hover);
  box-shadow: var(--mf-shadow-hover);
  transform: translateY(-2px);
}

.mf-trigger:focus {
  outline: 3px solid var(--mf-accent);
  outline-offset: 2px;
}

.mf-trigger-icon {
  font-size: 24px;
}

/* ===== Modal Styles ===== */
.mf-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: mf-fade-in 0.3s ease;
}

@keyframes mf-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.mf-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.mf-modal-container {
  position: relative;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  background: var(--mf-bg-main);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  animation: mf-slide-up 0.3s ease;
}

@keyframes mf-slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ===== Modal Header ===== */
.mf-modal-header {
  padding: 32px;
  border-bottom: 1px solid var(--mf-border);
  position: relative;
}

.mf-modal-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--mf-text-heading);
  margin: 0 0 8px 0;
}

.mf-modal-subtitle {
  font-size: 18px;
  color: var(--mf-text-muted);
  margin: 0;
}

.mf-modal-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: transparent;
  border: none;
  font-size: 32px;
  color: var(--mf-text-muted);
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: var(--mf-transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mf-modal-close:hover {
  background: var(--mf-bg-light);
  color: var(--mf-text-heading);
}

.mf-modal-close:focus {
  outline: 3px solid var(--mf-primary);
}

/* ===== Progress Indicator ===== */
.mf-progress {
  padding: 24px 32px 0;
}

.mf-progress-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.mf-progress-step {
  flex: 1;
  text-align: center;
  opacity: 0.4;
  transition: var(--mf-transition);
}

.mf-progress-step.active,
.mf-progress-step.completed {
  opacity: 1;
}

.mf-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--mf-border);
  color: var(--mf-text-muted);
  font-weight: 600;
  transition: var(--mf-transition);
  margin-bottom: 8px;
}

.mf-progress-step.active .mf-step-number {
  background: var(--mf-primary);
  color: white;
  animation: mf-pulse 2s infinite;
}

.mf-progress-step.completed .mf-step-number {
  background: var(--mf-accent);
  color: white;
}

.mf-progress-step.completed .mf-step-number::after {
  content: '✓';
}

@keyframes mf-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(94, 156, 209, 0.4);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(94, 156, 209, 0);
  }
}

.mf-step-label {
  display: block;
  font-size: 14px;
  color: var(--mf-text-body);
}

.mf-progress-bar {
  height: 4px;
  background: var(--mf-border);
  border-radius: 2px;
  overflow: hidden;
}

.mf-progress-fill {
  height: 100%;
  background: var(--mf-primary);
  transition: width 0.3s ease;
}

/* ===== Modal Body ===== */
.mf-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* ===== Steps Container ===== */
.mf-steps-container {
  min-height: 400px;
}

.mf-step {
  animation: mf-fade-slide 0.3s ease;
}

@keyframes mf-fade-slide {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.mf-step-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--mf-text-heading);
  margin: 0 0 8px 0;
}

.mf-step-subtitle {
  font-size: 16px;
  color: var(--mf-text-muted);
  margin: 0 0 32px 0;
}

/* ===== Option Cards ===== */
.mf-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.mf-option-card {
  position: relative;
  background: var(--mf-bg-main);
  border: 2px solid var(--mf-border);
  border-radius: 4px;
  padding: 24px;
  cursor: pointer;
  transition: var(--mf-transition);
  box-shadow: var(--mf-shadow);
  text-align: center;
}

.mf-option-card:hover {
  border-color: var(--mf-primary);
  box-shadow: var(--mf-shadow-hover);
  transform: scale(1.02);
}

.mf-option-card:focus {
  outline: 3px solid var(--mf-primary);
  outline-offset: 2px;
}

.mf-option-card.selected {
  border-color: var(--mf-primary);
  background: rgba(94, 156, 209, 0.05);
}

.mf-option-card.selected::after {
  content: '✓';
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--mf-primary);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  animation: mf-checkmark-pop 0.3s ease;
}

@keyframes mf-checkmark-pop {
  0% {
    transform: scale(0);
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

.mf-option-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.mf-option-label {
  font-size: 18px;
  font-weight: 600;
  color: var(--mf-text-heading);
  margin: 0 0 8px 0;
}

.mf-option-description {
  font-size: 14px;
  color: var(--mf-text-muted);
  margin: 0;
}

/* ===== Body Input (Dual Mode) ===== */
.mf-input-mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border: 1px solid var(--mf-border);
  border-radius: 4px;
  padding: 4px;
  background: var(--mf-bg-light);
}

.mf-mode-btn {
  flex: 1;
  padding: 12px 24px;
  background: transparent;
  border: none;
  border-radius: 2px;
  font-size: 16px;
  font-weight: 600;
  color: var(--mf-text-body);
  cursor: pointer;
  transition: var(--mf-transition);
}

.mf-mode-btn.active {
  background: var(--mf-bg-main);
  color: var(--mf-primary);
  box-shadow: var(--mf-shadow);
}

.mf-mode-btn:hover:not(.active) {
  color: var(--mf-text-heading);
}

.mf-mode-btn:focus {
  outline: 3px solid var(--mf-primary);
  outline-offset: -3px;
}

.mf-input-panel {
  display: none;
}

.mf-input-panel.active {
  display: block;
  animation: mf-fade-slide 0.3s ease;
}

/* BMI Form */
.mf-bmi-form {
  max-width: 600px;
  margin: 0 auto;
}

.mf-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.mf-form-group {
  display: flex;
  flex-direction: column;
}

.mf-form-group label {
  font-weight: 600;
  color: var(--mf-text-heading);
  margin-bottom: 8px;
}

.mf-input {
  padding: 12px 16px;
  border: 2px solid var(--mf-input-border);
  border-radius: 4px;
  font-size: 16px;
  font-family: 'Roboto Condensed', sans-serif;
  transition: var(--mf-transition);
}

.mf-input:focus {
  outline: none;
  border-color: var(--mf-primary);
  box-shadow: 0 0 0 3px rgba(94, 156, 209, 0.1);
}

.mf-input.error {
  border-color: #e7505a;
}

.mf-error-msg {
  color: #e7505a;
  font-size: 14px;
  margin-top: 4px;
  display: block;
}

/* BMI Inputs */
.mf-bmi-inputs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.mf-input-inline {
  flex: 1;
  position: relative;
}

.mf-input-inline label {
  display: block;
  font-size: 14px;
  color: var(--mf-text-heading);
  margin-bottom: 4px;
  font-weight: 600;
}

.mf-input-sm {
  width: 100%;
  padding: 8px 12px;
  padding-right: 36px;
  border: 2px solid var(--mf-input-border);
  border-radius: 4px;
  font-size: 16px;
  transition: var(--mf-transition);
}

.mf-input-sm:focus {
  outline: none;
  border-color: var(--mf-primary);
}

.mf-input-sm.error {
  border-color: #e7505a;
}

.mf-unit {
  position: absolute;
  right: 12px;
  top: 34px;
  color: var(--mf-text-muted);
  font-size: 14px;
  pointer-events: none;
}

.mf-bmi-result {
  background: var(--mf-bg-light);
  border-radius: 4px;
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
}

.mf-bmi-value {
  font-size: 18px;
  margin-bottom: 8px;
}

.mf-bmi-number {
  font-size: 32px;
  color: var(--mf-primary);
}

.mf-category-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
}

.mf-category-badge.mf-bmi-light {
  background: #c8d046;
  color: white;
}

.mf-category-badge.mf-bmi-normal {
  background: #5dc09c;
  color: white;
}

.mf-category-badge.mf-bmi-heavy {
  background: #e7505a;
  color: white;
}

.mf-privacy-note {
  text-align: center;
  color: var(--mf-text-muted);
  font-size: 14px;
}

/* ===== Step 4 (Multi-select) ===== */
.mf-step-4 .mf-option-card[aria-checked="true"] {
  border-color: var(--mf-accent);
  background: rgba(50, 197, 210, 0.05);
}

.mf-step-4 .mf-option-card[aria-checked="true"]::after {
  background: var(--mf-accent);
}

/* ===== Loading Screen ===== */
.mf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  animation: mf-fade-in 0.3s ease;
}

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

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

.mf-loading-message {
  margin-top: 24px;
  font-size: 18px;
  color: var(--mf-text-body);
}

/* ===== Result Page ===== */
.mf-result-page {
  animation: mf-fade-in 0.5s ease;
}

.mf-recommendation-header {
  text-align: center;
  padding: 32px 0;
  border-bottom: 1px solid var(--mf-border);
  margin-bottom: 32px;
}

.mf-expert-badge {
  display: inline-block;
  background: var(--mf-accent);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.mf-result-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--mf-text-heading);
  margin: 0 0 16px 0;
}

.mf-hardness-badge {
  display: inline-block;
  background: var(--mf-bg-light);
  padding: 12px 24px;
  border-radius: 4px;
  font-size: 16px;
  margin-bottom: 16px;
}

.mf-hardness-badge strong {
  font-size: 24px;
  color: var(--mf-primary);
}

.mf-hardness-badge.small {
  padding: 6px 12px;
  font-size: 14px;
}

.mf-hardness-badge.small strong {
  font-size: 18px;
}

.mf-series-name {
  font-size: 24px;
  font-weight: 600;
  color: var(--mf-primary);
  margin: 0 0 8px 0;
}

.mf-series-desc {
  font-size: 16px;
  color: var(--mf-text-muted);
  margin: 0;
}

/* Summary Section */
.mf-summary-section {
  margin-bottom: 32px;
}

.mf-summary-section h4 {
  font-size: 20px;
  font-weight: 600;
  color: var(--mf-text-heading);
  margin: 0 0 16px 0;
}

.mf-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.mf-summary-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--mf-bg-light);
  border-radius: 4px;
}

.mf-summary-card .mf-icon {
  font-size: 32px;
}

.mf-summary-card .mf-label {
  font-size: 16px;
  color: var(--mf-text-heading);
}

.mf-summary-card small {
  display: block;
  font-size: 14px;
  color: var(--mf-text-muted);
  margin-top: 4px;
}

/* Tips Section */
.mf-tips-section {
  margin-bottom: 32px;
  padding: 24px;
  background: rgba(50, 197, 210, 0.05);
  border-left: 4px solid var(--mf-accent);
  border-radius: 4px;
}

.mf-tips-section h4 {
  font-size: 20px;
  font-weight: 600;
  color: var(--mf-text-heading);
  margin: 0 0 16px 0;
}

.mf-tips-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mf-tips-list li {
  padding: 8px 0;
  padding-left: 24px;
  position: relative;
}

.mf-tips-list li::before {
  content: '💡';
  position: absolute;
  left: 0;
}

/* Products Section */
.mf-products-section {
  margin-bottom: 32px;
}

.mf-products-section h4 {
  font-size: 20px;
  font-weight: 600;
  color: var(--mf-text-heading);
  margin: 0 0 16px 0;
}

.mf-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.mf-product-item {
  border: 1px solid var(--mf-border);
  border-radius: 4px;
  overflow: hidden;
  transition: var(--mf-transition);
}

.mf-product-item:hover {
  box-shadow: var(--mf-shadow-hover);
  transform: translateY(-2px);
}

/* Adjacent Series */
.mf-adjacent-section {
  margin-bottom: 32px;
}

.mf-adjacent-section h4 {
  font-size: 20px;
  font-weight: 600;
  color: var(--mf-text-heading);
  margin: 0 0 16px 0;
}

.mf-adjacent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.mf-adjacent-card {
  padding: 20px;
  border: 2px solid var(--mf-border);
  border-radius: 4px;
  transition: var(--mf-transition);
}

.mf-adjacent-card:hover {
  border-color: var(--mf-primary);
  box-shadow: var(--mf-shadow);
}

.mf-adjacent-card h5 {
  font-size: 18px;
  font-weight: 600;
  color: var(--mf-text-heading);
  margin: 8px 0;
}

.mf-adjacent-card p {
  font-size: 14px;
  color: var(--mf-text-muted);
  margin: 0 0 16px 0;
}

.mf-link {
  color: var(--mf-primary);
  text-decoration: none;
  font-weight: 600;
  transition: var(--mf-transition);
}

.mf-link:hover {
  color: var(--mf-primary-hover);
  text-decoration: underline;
}

/* Result Actions */
.mf-result-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding-top: 32px;
  border-top: 1px solid var(--mf-border);
}

/* ===== Modal Footer ===== */
.mf-modal-footer {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 24px 32px;
  border-top: 1px solid var(--mf-border);
}

/* ===== Buttons ===== */
.mf-btn {
  padding: 14px 32px;
  border-radius: 4px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--mf-transition);
  border: none;
  font-family: 'Roboto Condensed', sans-serif;
}

.mf-btn:focus {
  outline: 3px solid var(--mf-accent);
  outline-offset: 2px;
}

.mf-btn-primary {
  background: var(--mf-primary);
  color: white;
  box-shadow: var(--mf-shadow);
}

.mf-btn-primary:hover:not(:disabled) {
  background: var(--mf-primary-hover);
  box-shadow: var(--mf-shadow-hover);
}

.mf-btn-primary:disabled {
  background: var(--mf-input-border);
  opacity: 0.6;
  cursor: not-allowed;
}

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

.mf-btn-secondary:hover {
  background: var(--mf-primary);
  color: white;
}

.mf-btn-prev,
.mf-btn-next {
  flex: 1;
  max-width: 200px;
}

.mf-btn-prev {
  margin-right: auto;
}

.mf-btn-next {
  margin-left: auto;
}

/* ===== Responsive Design ===== */
@media (max-width: 767px) {
  .mf-modal-container {
    width: 95%;
    max-height: 95vh;
  }

  .mf-modal-header,
  .mf-modal-body,
  .mf-modal-footer {
    padding: 20px;
  }

  .mf-modal-title {
    font-size: 24px;
  }

  .mf-modal-subtitle {
    font-size: 16px;
  }

  .mf-progress-steps {
    flex-wrap: wrap;
    gap: 8px;
  }

  .mf-step-number {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .mf-step-label {
    font-size: 12px;
  }

  .mf-options-grid {
    grid-template-columns: 1fr;
  }

  .mf-option-card {
    padding: 20px;
    min-height: 44px;
    /* Touch target size */
  }

  .mf-input {
    font-size: 16px;
    /* Prevent iOS zoom */
  }

  .mf-summary-cards {
    grid-template-columns: 1fr;
  }

  .mf-products-grid {
    grid-template-columns: 1fr;
  }

  .mf-adjacent-grid {
    grid-template-columns: 1fr;
  }

  .mf-result-actions {
    flex-direction: column;
  }

  .mf-modal-footer {
    flex-direction: column;
  }

  .mf-btn-prev,
  .mf-btn-next {
    max-width: none;
    width: 100%;
  }
}

@media (min-width: 768px) and (max-width: 991px) {
  .mf-options-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .mf-products-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ===== Touch Optimization ===== */
@media (hover: none) and (pointer: coarse) {
  .mf-option-card {
    min-height: 44px;
    touch-action: manipulation;
  }

  .mf-btn {
    min-height: 44px;
  }
}

/* ===== Print Styles ===== */
@media print {

  .mf-modal-backdrop,
  .mf-modal-close,
  .mf-modal-footer,
  .mf-trigger {
    display: none !important;
  }

  .mf-modal-container {
    box-shadow: none;
    max-width: 100%;
  }
}


/* SVG Icon Styles */
.mf-option-card .mf-option-icon {
  margin-bottom: 15px;
  line-height: 1;
}

.mf-icon-svg {
  width: 48px;
  height: 48px;
  color: var(--mf-primary);
  transition: color var(--mf-transition-speed) ease;
}

.mf-option-card:hover .mf-icon-svg {
  color: var(--mf-primary-hover);
}

.mf-option-card.selected .mf-icon-svg {
  color: var(--mf-primary);
}