@import url("../real-market/shared.css");

/* ==========================================================================
   Real Market - Students UI/UX (Modernized)
   ========================================================================== */

/* 1. 환율/정책 안내 배너 (Glassmorphism & Gradient) */
.exchange-rate-banner {
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary-soft) 40%, var(--glass-bg) 60%), color-mix(in srgb, var(--success-soft) 30%, var(--glass-bg) 70%));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 18px;
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  box-shadow: var(--glass-shadow);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.exchange-rate-banner:hover {
  transform: translateY(-2px);
}

.exchange-rate-banner .rate-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.exchange-guide-text {
  margin: 4px 0 12px;
}

.exchange-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.exchange-step-card {
  background: color-mix(in srgb, var(--card-bg) 84%, var(--primary-soft) 16%);
  border: 1px solid color-mix(in srgb, var(--border) 70%, #fff 30%);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exchange-step-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.exchange-step-head strong {
  font-size: 0.9rem;
  font-weight: 900;
}

.exchange-field-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-sub);
  font-weight: 800;
}

.exchange-field-label input[type="number"] {
  max-width: 180px;
}

.exchange-action-btn {
  width: 100%;
  border-radius: 12px;
  min-height: 40px;
}

.exchange-preview-text {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
}

/* 2. 시장 현황 필터 및 검색 영역 */
.filter-row,
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
  background: var(--glass-bg);
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.filter-bar select,
.filter-row select {
  min-width: 150px;
  flex: 0 0 auto;
  border-radius: 10px;
  padding: 8px 12px;
}

.stock-search,
.filter-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.95rem;
}

/* 3. 계좌 KPI 요약 박스 (Grid Layout & Hover Lift) */
.portfolio-summary,
.portfolio-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-box {
  background: var(--card-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease-out;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.kpi-box:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: var(--primary-soft);
}

.kpi-box .kpi-label {
  font-size: 0.8rem;
  color: var(--text-sub);
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-box .kpi-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-box .kpi-sub {
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-top: 4px;
}

/* 4. 포트폴리오(보유 주식) 테이블 개선 */
.portfolio-table,
.holdings-table {
  overflow-x: auto;
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 16px;
}

.holdings-table table {
  width: 100%;
  border-collapse: collapse;
}

.holdings-table th {
  background: color-mix(in srgb, var(--primary-soft) 30%, transparent 70%);
  color: var(--text-main);
  font-weight: 700;
  padding: 12px 16px;
  text-align: right;
  font-size: 0.85rem;
  border-bottom: 2px solid var(--border);
}

.holdings-table th:first-child,
.holdings-table td:first-child {
  text-align: left;
  /* 종목명은 좌측 정렬 */
}

.holdings-table td {
  padding: 14px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent 50%);
  font-size: 0.9rem;
  text-align: right;
  vertical-align: middle;
  transition: background 0.15s;
}

.holdings-table tbody tr:hover td {
  background: var(--primary-soft);
}

.holdings-table tbody tr:last-child td {
  border-bottom: none;
}

.holdings-table input[type="number"] {
  width: 70px;
  padding: 6px;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
}

/* 5. 매수 모달 주 수 입력기 (Stepper) */
.share-stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--input-bg);
  padding: 6px;
  border-radius: 24px;
  border: 1px solid var(--border);
}

.share-stepper button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.4rem;
  padding: 0;
  border: none;
  background: var(--glass-bg);
  color: var(--text-main);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.share-stepper button:hover {
  background: var(--primary);
  color: #fff;
  transform: scale(1.05);
}

.share-stepper input {
  width: 90px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  background: transparent;
  border: none;
  box-shadow: none;
}

.share-stepper input:focus {
  outline: none;
  box-shadow: none;
}

/* 6. 거래 기록 (Log Items) */
.trade-log-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trade-log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--glass-bg) 60%, transparent 40%);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.9rem;
  transition: transform 0.2s, background 0.2s;
}

.trade-log-item:hover {
  transform: translateX(4px);
  background: var(--glass-bg);
}

.trade-log-item .trade-type {
  font-weight: 800;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.trade-type.buy {
  background: var(--danger);
  /* 주식시장 통상 매수 Red 계열, 혹은 success 매핑 가능 */
  color: #fff;
}

.trade-type.sell {
  background: var(--primary);
  /* 주식시장 통상 매도 Blue 계열 */
  color: #fff;
}

/* 7. 가격 점핑/비공개 블러 처리 영역 */
.price-hidden {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
  opacity: 0.6;
  transition: filter 0.3s ease;
}

/* 8. 종목 카드 매수 버튼 오버라이드 (shared.css 보완) */
.stock-card .buy-btn {
  width: 100%;
  margin-top: 12px;
  border-radius: 12px;
  padding: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* 9. 포트폴리오 표 로고형 리디자인 */
.holding-name-cell {
  min-width: 220px;
}

.holding-stock-btn.rich {
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px 2px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  cursor: pointer;
}

.holding-stock-btn.rich:hover {
  transform: translateX(2px);
}

.holding-logo-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.97), rgba(239, 246, 255, 0.9));
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.16);
  border: 1px solid color-mix(in srgb, var(--border) 62%, #fff 38%);
  flex: 0 0 44px;
}

.holding-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.holding-logo-fallback {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.96rem;
  font-weight: 900;
  color: #13305d;
}

.holding-meta {
  min-width: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.holding-name {
  font-size: 0.93rem;
  font-weight: 900;
  color: var(--text-main);
  line-height: 1.15;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.holding-ticker-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.holding-ticker {
  font-size: 0.74rem;
  color: var(--text-sub);
  font-weight: 800;
  letter-spacing: 0.3px;
}

.holding-market-badge {
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.4px;
  border-radius: 999px;
  padding: 2px 6px;
  border: 1px solid transparent;
}

.holding-market-badge.kr {
  color: #1e3a8a;
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.28);
}

.holding-market-badge.us {
  color: #065f46;
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.32);
}

@media (max-width: 760px) {
  .exchange-step-grid {
    grid-template-columns: 1fr;
  }

  .exchange-field-label input[type="number"] {
    max-width: none;
  }

  .holding-name-cell {
    min-width: 180px;
  }

  .holding-logo-wrap {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .holding-name {
    max-width: 130px;
    font-size: 0.87rem;
  }

  .holding-ticker {
    font-size: 0.7rem;
  }
}
