/* =========================
   해양 페이지 전용 스타일
   - 골드 수익 최적화 탭
========================= */

/* ===== 골드 최적화 컨테이너 ===== */
.gold-optimizer-container {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

/* ===== 계산기 블록 ===== */
.star-level {
  background-color: white;
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.star-level h3 {
  font-size: clamp(0.9rem, 3vw, 1rem);
  margin-bottom: 14px;
  color: #333;
  font-weight: 600;
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 8px;
}

/* ===== 성급 선택 토글 ===== */
.star-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background-color: var(--color-bg-secondary, #f8f9fa);
  border-radius: var(--border-radius-md);
  flex-wrap: wrap;
}

.star-toggle input[type="radio"] {
  display: none;
}

.star-toggle label {
  padding: 8px 20px;
  border-radius: var(--border-radius-full);
  border: 1px solid var(--color-border-light);
  cursor: pointer;
  font-size: clamp(12px, 3vw, 14px);
  background: white;
  transition: background-color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.star-toggle input[type="radio"]:checked + label {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.star-toggle label:hover {
  background: var(--color-bg-hover);
}

/* ===== 스위치 컨테이너 ===== */
.switch-container {
  margin-left: auto;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.switch-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--border-radius-md);
}

.switch-label {
  font-size: clamp(10px, 2.5vw, 12px);
  color: var(--color-text-secondary);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

/* 스위처 */
.switcher {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
  flex-shrink: 0;
}

.switcher input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switcher label {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 24px;
  transition: background-color 0.3s;
}

.switcher label::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switcher input:checked + label {
  background-color: var(--color-primary);
}

.switcher input:checked + label::before {
  transform: translateX(20px);
}

/* ===== 입력 그리드 ===== */
.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.input-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: clamp(10px, 2.5vw, 12px);
  color: var(--color-text-secondary);
  font-weight: 500;
  text-align: left;
}

.input-grid input {
  padding: 8px 6px;
  border-radius: 6px;
  border: 1px solid var(--color-border-light);
  text-align: center;
  font-size: clamp(11px, 3vw, 13px);
  background-color: white;
  width: 100%;
  box-sizing: border-box;
}

.input-grid input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* ===== 고급 입력칸 ===== */
.advanced-inputs {
  display: none;
  margin-top: 16px;
  padding: 16px 0;
  border-top: 1px dashed #d0d0d0;
  background-color: transparent;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  animation: fadeIn 0.3s ease;
}

.advanced-inputs.active {
  display: block;
  max-height: 1000px;
  opacity: 1;
  padding: 16px 0;
}

.advanced-section {
  margin-bottom: 20px;
}

.advanced-section:last-child {
  margin-bottom: 0;
}

.advanced-section h4 {
  color: var(--color-primary);
  margin-bottom: 12px;
  font-size: clamp(11px, 3vw, 13px);
  font-weight: 600;
}

/* ===== 계산 버튼 ===== */
.star-level > button {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 16px 0 0 0;
  padding: 10px 18px;
  background: var(--color-primary, #4a90e2);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: clamp(12px, 3vw, 13px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.star-level > button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(74, 144, 226, 0.3);
}

/* ===== 결과 카드 ===== */
.result-card {
  display: none;
  background: white;
  border-radius: var(--border-radius-2xl);
  padding: 20px;
  box-shadow: var(--shadow-xl);
  margin: var(--spacing-xl) auto;
  max-width: 100%;
}

.result-card.active {
  display: block;
}

/* 결과 헤더 */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 11px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.result-header h3 {
  font-size: clamp(0.85rem, 3vw, 1rem);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin: 0;
  border-bottom: none !important;
  padding-bottom: 0 !important;
}

.result-gold {
  font-size: clamp(1rem, 4vw, 1.17rem);
  font-weight: var(--font-weight-bold);
  color: var(--color-danger);
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex-wrap: wrap;
}

.result-gold small {
  font-size: clamp(12px, 3vw, 15px);
  font-weight: var(--font-weight-semibold);
  color: #888;
}

/* ===== 최종 결과물 (상단 3개 카드) ===== */
.result-products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 11px;
  margin-bottom: 18px;
}

.result-products > div {
  background: var(--color-bg-card);
  border-radius: 11px;
  padding: 13px 9px;
  text-align: center;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.4;
}

.result-products > div .product-image {
  display: none !important;
}

.result-products > div .product-name {
  font-size: clamp(0.65rem, 2.5vw, 0.77rem);
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.result-products > div .product-count {
  display: block;
  margin-top: 7px;
  font-size: clamp(1rem, 4vw, 1.17rem);
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
}

/* ===== 결과 섹션 ===== */
.result-section {
  margin-bottom: 18px;
  text-align: left;
}

.result-section:last-child {
  margin-bottom: 0;
}

.result-section h4 {
  font-size: clamp(0.75rem, 3vw, 0.86rem);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin-bottom: 11px;
  text-align: left;
}

.result-section > div {
  font-size: clamp(11px, 3vw, 13px);
  line-height: 1.8;
  color: #666;
}

/* ===== 재료 카드 그리드 ===== */
.result-materials-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 9px;
  margin-bottom: 14px;
  width: 100%;
}

.material-card {
  background: var(--color-bg-card);
  border-radius: 9px;
  padding: 11px 7px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70px;
  width: 100%;
}

.material-card .icon {
  width: 29px;
  height: 29px;
  margin: 0 auto 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.material-card .icon img {
  width: 25px;
  height: 25px;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.material-card .name {
  font-size: clamp(0.6rem, 2vw, 0.7rem);
  color: #666;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  font-weight: var(--font-weight-medium);
}

.material-card .value {
  font-size: clamp(0.85rem, 3vw, 1rem);
  font-weight: var(--font-weight-semibold);
}

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

/* ===== 반응형 ===== */
@media (max-width: 768px) {
  .gold-optimizer-container {
    padding: 0 12px;
  }

  .star-level {
    padding: 16px;
  }

  .star-toggle {
    flex-direction: column;
    align-items: stretch;
  }

  .star-toggle label {
    text-align: center;
    padding: 10px 16px;
  }

  .switch-container {
    margin-left: 0;
    margin-top: 10px;
    width: 100%;
    justify-content: center;
  }

  .input-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .star-level > button {
    max-width: 100%;
  }

  .result-card {
    padding: 16px;
  }

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

  .result-materials-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .gold-optimizer-container {
    padding: 0 8px;
  }

  .star-level {
    padding: 12px;
  }

  .input-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .input-grid input {
    padding: 10px 4px;
  }

  .result-card {
    padding: 12px;
  }

  .result-products {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .result-products > div {
    padding: 10px 6px;
    min-height: 60px;
  }

  .result-materials-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .material-card {
    padding: 8px 4px;
    min-height: 60px;
  }

  .material-card .icon {
    width: 24px;
    height: 24px;
  }

  .material-card .icon img {
    width: 20px;
    height: 20px;
  }

  .switch-wrapper {
    padding: 2px 4px;
  }

  .switcher {
    width: 38px;
    height: 20px;
  }

  .switcher label::before {
    height: 14px;
    width: 14px;
  }

  .switcher input:checked + label::before {
    transform: translateX(18px);
  }
}

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

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

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