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

:root {
  --primary:       #E8722A;
  --primary-light: #F59A5A;
  --primary-dark:  #C45A18;
  --accent:        #E8722A;
  --accent-dark:   #C45A18;
  --success:       #16A34A;
  --danger:        #DC2626;
  --neutral:       #6B7280;
  --bg:            #FFFFFF;
  --bg2:           #FFF8F3;
  --bg3:           #FFF3EA;
  --card-bg:       #FFFFFF;
  --card-border:   #FFD9BB;
  --text-primary:  #1A1A1A;
  --text-secondary:#6B5A4E;
  --text-muted:    #A8907E;
  --radius:        16px;
  --shadow:        0 4px 24px rgba(232,114,42,0.10);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #FFFFFF;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== BACKGROUND GRADIENT ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%,   rgba(255,200,150,0.30) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 95% 100%,  rgba(255,180,100,0.20) 0%, transparent 55%),
    radial-gradient(ellipse 100% 40% at 50% 50%,  rgba(255,240,220,0.25) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ===== PAGE WRAPPER ===== */
.page-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 36px;
  padding: 24px 32px;
  background: linear-gradient(135deg, #ffffff 0%, #fff5ec 100%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: 0 2px 16px rgba(232,114,42,0.10);
}

.header-icon {
  font-size: 2.8rem;
  filter: drop-shadow(0 0 14px rgba(232,114,42,0.45));
}

.header-brand {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #E8722A;
  margin-bottom: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.header-brand::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 2px;
  background: #E8722A;
  border-radius: 2px;
}

.header-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: #1A1A1A;
  line-height: 1.2;
}

.header-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 5px;
  font-weight: 500;
}

/* ===== LAYOUT ===== */
.calculator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 780px) {
  .calculator-layout { grid-template-columns: 1fr; }
}

/* ===== CARD ===== */
.card {
  background: #FFFFFF;
  border: 1px solid #FFD9BB;
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 2px 16px rgba(232,114,42,0.08);
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 22px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title i { color: var(--primary-light); }

/* ===== INPUT GROUPS ===== */
.input-group-block { margin-bottom: 4px; }

.input-group-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.divider {
  height: 1px;
  background: var(--card-border);
  margin: 20px 0;
}

/* ===== FIELD ROW ===== */
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.field-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 110px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
  background: #FFF8F3;
  border: 1.5px solid #FFCFA0;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  flex: 1;
  max-width: 200px;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,114,42,0.14);
}

.field-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 12px;
  outline: none;
  font-family: inherit;
  min-width: 0;
  text-align: right;
}

.field-input::-webkit-outer-spin-button,
.field-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field-input[type=number] { -moz-appearance: textfield; }

.input-unit, .currency-select {
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: #FFF0E4;
  border: none;
  border-left: 1px solid #FFCFA0;
  white-space: nowrap;
}

.currency-select {
  color: var(--primary-light);
  cursor: pointer;
  outline: none;
  font-family: inherit;
}

.currency-select option { background: #FFF8F3; }

/* ===== 오늘의 환율 ===== */
.rate-row { align-items: flex-start; }

.rate-display-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 220px;
}

.rate-badge {
  flex: 1;
  background: #FFF8F3;
  border: 1.5px solid #FFCFA0;
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 44px;
  justify-content: center;
}

.rate-loading {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.rate-value-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.rate-date {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.rate-error-text {
  font-size: 0.78rem;
  color: var(--danger);
}

.rate-refresh-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid #FFCFA0;
  background: #FFF0E4;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.rate-refresh-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(232,114,42,0.10);
}

.rate-refresh-btn.spinning i { animation: spin 0.8s linear infinite; }

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

.rate-manual-label {
  color: var(--text-muted) !important;
  font-size: 0.82rem !important;
}

/* ===== TOOLTIP ===== */
.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tooltip-icon {
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
}

.tooltip-icon:hover { color: var(--primary-light); }

.tooltip-box {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #FFCFA0;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 400;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(232,114,42,0.12);
  pointer-events: none;
}

.tooltip-box::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #FFCFA0;
}

.tooltip-wrap:hover .tooltip-box { display: block; }

/* ===== CALC BUTTON ===== */
.calc-btn {
  width: 100%;
  margin-top: 24px;
  padding: 15px 24px;
  background: linear-gradient(135deg, #E8722A 0%, #F59A5A 100%);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.25s;
  box-shadow: 0 4px 18px rgba(232,114,42,0.30);
  font-family: inherit;
  letter-spacing: 0.02em;
}

.calc-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(232,114,42,0.42);
  background: linear-gradient(135deg, #F07830 0%, #FFB07A 100%);
}

.calc-btn:active { transform: translateY(0); }

/* ===== RESULT CARD ===== */
.result-card {
  min-height: 480px;
  display: flex;
  flex-direction: column;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px 0;
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.95rem;
  line-height: 1.8;
}

/* ===== CALC FLOW ===== */
.calc-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.flow-step {
  display: flex;
  flex-direction: column;
  background: #FFF8F3;
  border: 1px solid #FFD9BB;
  border-radius: 12px;
  padding: 14px 18px;
  transition: all 0.3s;
  animation: fadeSlideIn 0.4s ease forwards;
  opacity: 0;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.flow-step:nth-child(1) { animation-delay: 0.05s; }
.flow-step:nth-child(3) { animation-delay: 0.15s; }
.flow-step:nth-child(5) { animation-delay: 0.25s; }
.flow-step:nth-child(7) { animation-delay: 0.35s; }

.highlight-step {
  background: linear-gradient(135deg, #fff5ec 0%, #fff0e0 100%);
  border-color: #E8722A;
  box-shadow: 0 4px 18px rgba(232,114,42,0.14);
}

.flow-step > div:first-child { /* icon */
  display: none; /* we use label directly */
}

.flow-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flow-icon {
  display: none;
}

.flow-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.highlight-step .flow-label {
  color: #E8722A;
  font-weight: 700;
  font-size: 0.9rem;
}

.flow-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.main-price {
  font-size: 1.5rem;
  font-weight: 800;
  color: #E8722A;
}

.flow-formula {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 5px;
  font-family: 'Pretendard', monospace;
}

.flow-arrow {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #C45A18;
  padding: 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.flow-arrow i {
  font-size: 0.65rem;
  background: rgba(232,114,42,0.12);
  border-radius: 50%;
  padding: 4px;
}

/* ===== MARGIN DETAIL ===== */
.margin-detail {
  margin-top: 20px;
  animation: fadeSlideIn 0.5s ease 0.4s forwards;
  opacity: 0;
}

.detail-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-item {
  background: #FFF8F3;
  border: 1px solid #FFD9BB;
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.4;
}

.detail-val {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.detail-val.positive { color: var(--success); }
.detail-val.negative { color: var(--danger); }
.detail-val.neutral  { color: var(--text-secondary); }

/* ===== PRICE ADJUSTER ===== */
.price-adjuster {
  margin-top: 20px;
  background: #FFF8F3;
  border: 1px solid #FFD9BB;
  border-radius: 12px;
  padding: 18px;
  animation: fadeSlideIn 0.5s ease 0.55s forwards;
  opacity: 0;
}

.adjuster-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-min, .slider-max {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.price-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--primary) var(--val, 50%), var(--card-border) var(--val, 50%));
  outline: none;
  cursor: pointer;
}

.price-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #E8722A;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(232,114,42,0.35);
  cursor: pointer;
  transition: transform 0.15s;
}

.price-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.slider-current {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.slider-current strong {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

/* ===== FOOTER ===== */
.app-footer {
  text-align: center;
  padding: 32px 0 0;
  font-size: 0.8rem;
  color: #C0907A;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #FFF5EE; }
::-webkit-scrollbar-thumb { background: #FFCFA0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #E8722A; }

/* ===== RESPONSIVE ===== */
@media (max-width: 500px) {
  .app-header { flex-direction: column; text-align: center; gap: 10px; padding: 20px; }
  .header-title { font-size: 1.3rem; }
  .card { padding: 20px 16px; }
  .field-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .input-wrapper { max-width: 100%; width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
}
