/* CSS Variables */
:root {
  --bg: #0b0d10;
  --card: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --ok: #3fb950;
  --danger: #f85149;
  --radius: 8px;
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, Apple SD Gothic Neo, Malgun Gothic, "Noto Sans KR", sans-serif;
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

body::-webkit-scrollbar {
  display: none;
}

/* Layout */
header {
  padding: 28px 24px 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  max-width: 1100px;
  margin: 0 auto;
}

header h1 {
  font-size: 28px;
  margin: 0;
  letter-spacing: .2px;
}

main {
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

footer {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  max-width: 1100px;
  margin: 0 auto;
}

/* Card Components */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.card .body {
  padding: 20px;
}

.card h3 {
  margin: 0 0 16px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

/* Buttons */
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn:hover {
  background: #1f6feb;
}

.btn:active {
  background: #1158d4;
}

.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: var(--border);
}

/* Form Elements */
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* 옵션 체인 스타일 */
.options-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 150px;
}

.control-group label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.control-group input,
.control-group select {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

.control-group input:focus,
.control-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.control-group input[type="checkbox"] {
  margin-right: 8px;
}

.chain-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.underlying-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.underlying-info .price {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.underlying-info .change {
  font-size: 14px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
}

.underlying-info .change.positive {
  color: var(--ok);
  background: rgba(63, 185, 80, 0.1);
}

.underlying-info .change.negative {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
}

.price-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.previous-close-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.previous-close-info .label {
  font-size: 12px;
  color: var(--muted);
}

.previous-close-info .value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.chain-table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
}

.options-chain-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.options-chain-table th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.options-chain-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.options-chain-table tbody tr:hover {
  background: rgba(47, 129, 247, 0.05);
}

.strike-row {
  cursor: pointer;
}

.strike-row:hover {
  background: rgba(47, 129, 247, 0.1);
}

.expiration {
  color: var(--muted);
  font-size: 11px;
}

.strike {
  font-weight: 600;
  color: var(--accent);
}

.call-price,
.put-price {
  font-weight: 600;
}

.call-price.positive,
.put-price.positive {
  color: var(--ok);
}

.call-price.negative,
.put-price.negative {
  color: var(--danger);
}

.call-price.no-price,
.put-price.no-price {
  color: var(--muted);
}

.call-volume,
.put-volume {
  text-align: right;
  color: var(--muted);
}

.call-oi,
.put-oi {
  text-align: right;
  color: var(--muted);
}

.call-delta,
.put-delta {
  text-align: right;
  font-family: 'Courier New', monospace;
}

.call-iv,
.put-iv {
  text-align: right;
  font-weight: 500;
}

.call-time,
.put-time {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  font-family: 'Courier New', monospace;
}

.chain-stats {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  padding: 12px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.chain-stats .stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chain-stats .stat .label {
  font-size: 12px;
  color: var(--muted);
}

.chain-stats .stat .value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.loading,
.error,
.no-data {
  text-align: center;
  padding: 32px;
  color: var(--muted);
  font-style: italic;
}

.error-message {
  color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
  padding: 16px;
  border-radius: 6px;
  border: 1px solid rgba(248, 81, 73, 0.2);
}

.error-message strong {
  display: block;
  margin-bottom: 8px;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .options-controls {
    flex-direction: column;
  }
  
  .control-group {
    min-width: auto;
  }
  
  .chain-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  
  .options-chain-table {
    font-size: 11px;
  }
  
  .options-chain-table th,
  .options-chain-table td {
    padding: 6px 4px;
  }
  
  .chain-stats {
    flex-direction: column;
    gap: 12px;
  }
}

/* 옵션 차트 스타일 */
.options-chart-section {
  margin-top: 20px;
  padding: 20px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.options-chart-container {
  width: 100%;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.chart-header h4 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.chart-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chart-select {
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
}

.chart-select:focus {
  outline: none;
  border-color: var(--accent);
}

.chart-wrapper {
  position: relative;
  height: 400px;
  margin: 16px 0;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.chart-wrapper canvas {
  border-radius: var(--radius);
}

.chart-legend {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.legend-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.legend-text strong {
  color: var(--text);
}

@media (max-width: 768px) {
  .chart-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  
  .chart-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  .chart-wrapper {
    height: 300px;
  }
}

/* 테스트 페이지 스타일 */
.api-setup {
  padding: 16px;
  background: rgba(47, 129, 247, 0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(47, 129, 247, 0.2);
}

.api-setup p {
  margin: 0 0 16px 0;
  color: var(--text);
}

.api-setup ol {
  margin: 16px 0;
  padding-left: 20px;
  color: var(--muted);
}

.api-setup ol li {
  margin-bottom: 8px;
}

.api-setup a {
  color: var(--accent);
  text-decoration: none;
}

.api-setup a:hover {
  text-decoration: underline;
}

.api-setup code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  color: var(--accent);
}

.api-key-input {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.api-key-input label {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 500;
}

.api-key-input input {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

.api-key-input input:focus {
  outline: none;
  border-color: var(--accent);
}

.feature-info {
  margin-top: 20px;
  padding: 16px;
  background: rgba(63, 185, 80, 0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(63, 185, 80, 0.2);
}

.feature-info h4 {
  margin: 0 0 12px 0;
  color: var(--text);
  font-size: 16px;
}

.feature-info p {
  margin: 0 0 12px 0;
  color: var(--muted);
  line-height: 1.5;
}

.feature-info ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.feature-info ul li {
  margin-bottom: 6px;
}

.troubleshooting-info {
  margin-top: 16px;
  padding: 16px;
  background: rgba(248, 81, 73, 0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(248, 81, 73, 0.2);
}

.troubleshooting-info h4 {
  margin: 0 0 12px 0;
  color: var(--text);
  font-size: 16px;
}

.troubleshooting-info p {
  margin: 0 0 12px 0;
  color: var(--muted);
  line-height: 1.5;
}

.troubleshooting-info ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.troubleshooting-info ul li {
  margin-bottom: 6px;
}

.api-key-status {
  margin-top: 8px;
  padding: 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.api-key-help {
  margin-top: 16px;
  padding: 16px;
  background: rgba(47, 129, 247, 0.1);
  border-radius: var(--radius);
  border: 1px solid rgba(47, 129, 247, 0.2);
}

.api-key-help h5 {
  margin: 0 0 12px 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.api-key-help ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.api-key-help ol li {
  margin-bottom: 6px;
}

.api-key-help a {
  color: var(--accent);
  text-decoration: none;
}

.api-key-help a:hover {
  text-decoration: underline;
}

/* Expected Move box */
.em-box {
  display: flex;
  gap: 24px;
  margin-top: 8px;
  font-size: 14px;
  flex-wrap: wrap;
}

.em-box span {
  font-weight: 600;
}

.em-box .hint {
  flex: 1;
  color: #888;
}
