/* ===============================
   🎨 PROFESSIONAL TRADING PLATFORM CSS
   전문 트레이딩 플랫폼 스타일
================================ */

:root {
  /* Light Mode Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --border-color: #e2e8f0;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --success-green: #10b981;
  --danger-red: #ef4444;
  --warning-orange: #f59e0b;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

  /* Professional Gradients */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
  --gradient-danger: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --gradient-dark: linear-gradient(135deg, #434343 0%, #000000 100%);
}

/* Dark Mode Variables */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary: #64748b;
  --border-color: #334155;
}

/* ===============================
   🌐 GLOBAL BASE STYLE
================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Professional Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h2 {
  font-size: 1.875rem;
  margin-bottom: 1.5rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===============================
   🧱 CONTENT LAYOUT
================================ */
main.content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
  animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===============================
   💳 CARD SECTION - Professional Style
================================ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.card:hover::before {
  transform: scaleX(1);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
  border-color: var(--accent-blue);
}

.card h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: -0.01em;
}

/* Top 5 List - Premium Style */
.top5-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.top5-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.top5-list li:last-child {
  border-bottom: none;
}

.top5-list li:hover {
  background: var(--bg-tertiary);
  padding-left: 0.5rem;
  margin: 0 -0.5rem;
  border-radius: 8px;
}

.rank {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--accent-blue);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea20, #764ba220);
  border-radius: 8px;
}

.rate {
  font-weight: 600;
  font-size: 0.875rem;
  min-width: 80px;
  text-align: right;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
}

.rate.positive {
  color: var(--success-green);
  background: #10b98110;
}

.rate.negative {
  color: var(--danger-red);
  background: #ef444410;
}

/* ===============================
   📊 TABLE - Professional Trading Style
================================ */
.table-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 700px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  box-shadow: var(--shadow-lg);
  position: relative;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.875rem;
  color: var(--text-primary);
}

thead {
  background: var(--bg-tertiary);
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th {
  font-weight: 600;
  font-size: 0.813rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--accent-blue);
}

th, td {
  padding: 1rem 1.25rem;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

tbody tr:hover {
  background: var(--bg-tertiary);
  transform: scale(1.01);
}

.number-cell {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* Price Change Indicators */
.price-up {
  color: var(--success-green);
  font-weight: 600;
}

.price-down {
  color: var(--danger-red);
  font-weight: 600;
}

.price-neutral {
  color: var(--text-secondary);
}

/* Clickable Rows */
.clickable-row {
  cursor: pointer;
  transition: all 0.2s ease;
}

.clickable-row:hover {
  background: linear-gradient(90deg, transparent, var(--accent-blue)10, transparent);
}

/* ===============================
   🌐 BUTTON STYLE - Premium
================================ */
button {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: var(--accent-blue);
  opacity: 0.2;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

button:hover::before {
  width: 300px;
  height: 300px;
}

button:hover {
  background: var(--accent-blue);
  color: white;
  border-color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

button.active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow-md);
}

/* ===============================
   📌 PATTERN FILTER BUTTONS
================================ */
.pattern-filter {
  margin: 1.5rem 0;
  text-align: center;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.pattern-filter button {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.813rem;
  border: 2px solid var(--border-color);
  background: var(--bg-primary);
  transition: all 0.3s ease;
}

.pattern-filter button:hover {
  border-color: var(--accent-blue);
  background: var(--accent-blue)10;
}

.pattern-filter button.active {
  background: var(--gradient-primary);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ===============================
   📊 MODAL - Premium Design
================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  overflow: auto;
  padding: 1.5rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-primary);
  border-radius: 20px;
  max-width: 1200px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  padding: 2rem;
  position: relative;
  animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-color);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-close-btn {
  background: var(--bg-tertiary);
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background: var(--danger-red);
  color: white;
  transform: rotate(90deg);
}

/* ===============================
   📊 MODAL CHART & TOOLBAR
================================ */
#modal-chart {
  width: 100%;
  height: 500px;
  min-height: 400px;
  margin: 1.5rem 0;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

#modal-toolbar {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}

#modal-toolbar label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease;
}

#modal-toolbar label:hover {
  color: var(--accent-blue);
}

#modal-toolbar input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

#modal-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

#modal-error-box {
  padding: 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: var(--danger-red);
  font-size: 0.875rem;
  margin: 1rem 0;
}

/* ===============================
   📊 PREDICTION TABLE - Premium
================================ */
.prediction-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  box-shadow: var(--shadow-md);
  margin: 1.5rem 0;
}

.prediction-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  min-width: 600px;
}

.prediction-table thead {
  background: var(--gradient-primary);
  color: white;
}

.prediction-table th {
  padding: 1rem 0.75rem;
  text-align: center;
  font-size: 0.813rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.prediction-table td {
  padding: 1rem 0.75rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

.prediction-table tbody tr {
  transition: all 0.2s ease;
}

.prediction-table tbody tr:hover {
  background: var(--bg-tertiary);
}

/* ===============================
   🎨 Clickable Name
================================ */
.clickable-name {
  cursor: pointer;
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  position: relative;
}

.clickable-name::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent-blue);
  transition: width 0.3s ease;
}

.clickable-name:hover::after {
  width: 100%;
}

.clickable-name:hover {
  color: var(--accent-purple);
}

/* ===============================
   📱 RESPONSIVE - MOBILE OPTIMIZED
================================ */

/* 테이블 가로 스크롤 컨테이너 */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
  main.content {
    padding: 1rem 0.5rem 4rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h3 {
    font-size: 1.25rem;
  }

  /* 카드 2열로 */
  .cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .card {
    padding: 0.875rem;
  }

  .card-value {
    font-size: 1.25rem;
  }

  .card-label {
    font-size: 0.75rem;
  }

  /* 테이블 최적화 */
  .table-container {
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
  }

  table {
    font-size: 0.8rem;
    min-width: 100%;
    white-space: nowrap;
  }

  th, td {
    padding: 0.5rem 0.375rem;
    font-size: 0.75rem;
  }

  th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
  }

  .number-cell {
    text-align: right;
  }

  button {
    font-size: 0.8rem;
    padding: 0.5rem 0.875rem;
  }

  .pattern-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .pattern-filter button {
    flex: 1 1 auto;
    min-width: 70px;
    font-size: 0.75rem;
    padding: 0.5rem 0.625rem;
  }

  .modal-content {
    width: 95%;
    max-width: 95%;
    padding: 1rem;
    border-radius: 12px;
  }

  #modal-chart {
    height: 300px;
    min-height: 250px;
  }

  #modal-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
  }

  #modal-toolbar label {
    font-size: 0.875rem;
  }

  .month-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .month-tabs button {
    flex-shrink: 0;
    font-size: 0.8rem;
    padding: 0.5rem 0.875rem;
  }
}

/* 작은 모바일 (최대 480px) */
@media (max-width: 480px) {
  .cards {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 0.7rem;
  }

  th, td {
    padding: 0.375rem 0.25rem;
    font-size: 0.7rem;
  }

  .pattern-filter button {
    font-size: 0.7rem;
    padding: 0.4rem 0.5rem;
  }
}

/* ===============================
   🌙 Dark Mode Toggle (Optional)
================================ */
.theme-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: var(--shadow-xl);
  transition: all 0.3s ease;
  z-index: 1000;
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  box-shadow: 0 20px 40px rgba(102, 126, 234, 0.4);
}

/* ===============================
   ✨ Loading Animation
================================ */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===============================
   🎯 Toast Notification
================================ */
.toast {
  position: fixed;
  top: 2rem;
  right: 2rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow-xl);
  z-index: 10000;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.success {
  border-left: 4px solid var(--success-green);
}

.toast.error {
  border-left: 4px solid var(--danger-red);
}

.toast.warning {
  border-left: 4px solid var(--warning-orange);
}

/* ===============================
   🦶 FOOTER
================================ */
footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 2rem;
}