/* CSS Variables for consistent theming */
:root {
  --primary-color: #667eea;
  --primary-hover: #5a67d8;
  --success-color: #4CAF50;
  --success-hover: #45a049;
  --warning-color: #f59e0b;
  --warning-hover: #d97706;
  --text-primary: #26282b;
  --text-secondary: #6f7985;
  --text-muted: #b5bdc6;
  --bg-primary: #f4f5f6;
  --bg-white: #ffffff;
  --bg-light: #fafbfc;
  --bg-medium: #d0d6db;
  --bg-dark: #8e99a6;
  --border-color: #e6eaed;
  --border-light: #f4f5f6;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: all 0.3s ease;
  --transition-fast: all 0.2s ease;
  /* Logo responsive sizing */
  --logo-height: 32px;
  --logo-width: 120px;
}

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');

/* Loading Spinner Styles */
#loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f5f5f5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease-out;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0;
    border-top: 5px solid #00b4ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 20px;
    color: #666;
    font-size: 16px;
    font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-spinner.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Reset and Base Styles */
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  margin: 0;
  background: var(--bg-primary);
  min-height: 100vh;
  line-height: 1.6;
  box-sizing: border-box;
  /* Korean text wraps at spaces; long tokens still break safely */
  word-break: keep-all;
  overflow-wrap: break-word;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0 16px;
}

/* Header Styles */
.header-container {
  max-width: 1000px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0 16px;
}

.header-section {
  margin: 24px 0;
  padding: 24px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  padding-bottom: 20px;
}

.menu-container {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

/* Hamburger Menu */
.hamburger-menu {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 24px;
  height: 24px;
  transition: var(--transition);
  border-radius: 4px;
  position: relative;
  align-items: center;
}

.hamburger-check {
  display: none;
}

.hamburger-menu:hover {
  background: rgba(102, 126, 234, 0.1);
  transform: scale(1.05);
}

.hamburger-line {
  width: 100%;
  height: 3px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition);
  transform-origin: center;
}

.hamburger-check:checked ~ .hamburger-line:nth-child(2) {
  transform: translate(0, 8px) rotate(45deg);
}

.hamburger-check:checked ~ .hamburger-line:nth-child(3) {
  transform: scale(0);
  opacity: 0;
}

.hamburger-check:checked ~ .hamburger-line:nth-child(4) {
  transform: translate(0, -8px) rotate(-45deg);
}

/* Menu Dropdown */
.menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  min-width: 200px;
  max-width: calc(100vw - 32px);
  display: none;
  padding: 8px 0;
  opacity: 0;
  transform: translateY(-10px);
  transition: var(--transition);
}

.menu-dropdown.show {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.menu-item {
  display: block;
  padding: 12px 20px;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition-fast);
  border-bottom: 1px solid var(--border-light);
  font-weight: 500;
  transform: translateX(-10px);
}

.menu-item:hover {
  background: var(--bg-light);
  color: var(--primary-color);
  padding-left: 24px;
  transform: translateX(0);
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item.active {
  background: var(--primary-color);
  color: var(--bg-white);
  font-weight: 600;
  transform: translateX(0);
  position: relative;
  padding-left: 24px;
}

.menu-item.active::before {
  content: "●";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
  color: var(--bg-white);
}

.menu-item.active:hover {
  background: var(--primary-hover);
  color: var(--bg-white);
  padding-left: 24px;
}

/* Logo and Bitsaving Button */
.logo-link {
  display: inline-block;
  transition: var(--transition);
}

.logo-link:hover {
  transform: scale(1.05);
}

.logo {
  height: var(--logo-height);
  width: var(--logo-width);
  transition: var(--transition);
  object-fit: contain;
}

.bitsaving-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #00b4ff;
  color: var(--bg-white);
  text-decoration: none;
  border-radius: 20px;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0, 180, 255, 0.2);
}

.bitsaving-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 180, 255, 0.3);
  color: var(--bg-white);
  text-decoration: none;
}

/* Typography */
h1 {
  color: #1a202c;
  font-size: 2.2em;
  font-weight: 900;
  text-align: center;
  margin-top: 24px;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

h2 {
  color: #2d3748;
  font-weight: 800;
  letter-spacing: -0.025em;
  padding-bottom: 8px;
  border-bottom: 1px solid #777;
}

h3 {
  margin: 0 0 16px 0;
  color: var(--text-primary);
  font-size: 1.2em;
  font-weight: 700;
}

/* Notice Message */
.notice-message {
  text-align: center;
  margin-bottom: 16px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.notice-message p {
  margin: 2px 0;
  font-size: 0.85em;
  color: #6c757d;
  line-height: 1.3;
}

/* Settings Section */
.settings-section {
  margin: 24px auto;
  padding: 24px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  max-width: 950px;
}

.strategy-section {
  margin-bottom: 40px;
  padding: 20px;
  background: var(--bg-light);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

/* Form Elements */
label {
  display: block;
  font-weight: 600;
  color: #4a5568;
  font-size: 0.95em;
}

.input-description {
  display: block;
  margin-top: 8px;
  font-size: 0.85em;
  color: #718096;
  line-height: 1.6;
  margin-bottom: 8px;
}

input, select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  font-size: 16px;
  background: var(--bg-white);
  transition: var(--transition-fast);
  outline: none;
  margin-top: 12px;
}

input:focus, select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

input::placeholder {
  color: #cccccc;
  font-style: italic;
  opacity: 0.8;
}

input::-webkit-input-placeholder { color: #a0aec0; font-style: italic; }
input::-moz-placeholder { color: #a0aec0; font-style: italic; opacity: 1; }
input:-ms-input-placeholder { color: #a0aec0; font-style: italic; }

select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

input[type="date"] {
  cursor: pointer;
  margin-bottom: 16px;
}

input[type="date"]:hover {
  border-color: var(--primary-color);
}

/* Buttons */
button {
  background: var(--primary-color);
  color: var(--bg-white);
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  align-items: center;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

button:active {
  transform: translateY(0);
}

button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.2);
  transition: left 0.5s;
}

button:hover::before {
  left: 100%;
}

#calculateButton {
  margin: 24px auto;
  max-width: 1000px;
  display: block;
}

/* Quick Date Buttons */
.quick-date-buttons {
  display: flex;
  flex-direction: row;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 8px;
}

.quick-date-btn, .market-btn {
  background: transparent;
  color: var(--primary-color);
  padding: 8px 14px;
  border: 1px solid var(--primary-color);
  margin: 10px 0px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition-fast);
  min-height: 36px;
  width: 125px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.2;
}

.market-btn {
  color: var(--warning-color);
  border-color: var(--warning-color);
}

.quick-date-btn.active {
  background: var(--primary-color);
  color: var(--bg-white);
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.market-btn.active {
  background: var(--warning-color);
  color: var(--bg-white);
  border-color: var(--warning-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.quick-date-btn:hover {
  background: rgba(102, 126, 234, 0.2);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.market-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--warning-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

.quick-date-btn.active:hover {
  background: var(--primary-hover);
  color: var(--bg-white);
  border-color: var(--primary-hover);
}

.market-btn.active:hover {
  background: var(--warning-hover);
  color: var(--bg-white);
  border-color: var(--warning-hover);
}

.quick-date-btn:active, .market-btn:active {
  transform: translateY(0);
}

/* Asset Selection */
.asset-selection {
  margin-bottom: 20px;
  padding: 16px;
  background: var(--bg-light);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.asset-buttons, .period-buttons {
  display: flex;
  flex-direction: row;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-top: 16px;
  padding: 4px;
}

.asset-btn, .period-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  width: 160px;
  min-height: 36px;
  flex-shrink: 0;
  white-space: nowrap;
}

.asset-btn:hover, .period-btn:hover {
  border-color: var(--success-color);
  background: #f8fff8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.15);
}

.asset-btn.active, .period-btn.active {
  border-color: var(--success-color);
  background: var(--success-color);
  color: var(--bg-white);
  box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.asset-btn.active:hover, .period-btn.active:hover {
  background: var(--success-hover);
  transform: translateY(-1px);
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Chart Container */
.chart-container {
  background-color: var(--bg-white);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  margin: 16px 0px;
  display: block;
  height: 500px;
  min-height: 400px;
  max-height: 700px;
  transition: height 0.3s ease;
}

/* Chart controls */
.chart-controls {
  padding: 12px;
  background-color: var(--bg-light);
  align-items: center;
}

.chart-toggle {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #495057;
  transition: color 0.2s ease;
}

.toggle-item:hover {
  color: var(--primary-color);
}

.toggle-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary-color);
  align-items: center;
  margin-top: 0;
}

.toggle-label {
  user-select: none;
}

/* Dual chart container */
.dual-chart-container {
  display: block;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 16px 0px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.dual-chart-container .chart-container {
  margin: 0;
}

/* Chart legend */
.chart-legend {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85em;
  color: var(--text-secondary);
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  display: inline-block;
}

/* Sell dates container */
.sell-dates-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: right;
}

.sell-dates-container .date-row {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.sell-dates-container .date-item {
  white-space: nowrap;
  color: #2d3748 !important;
  font-weight: 600 !important;
  font-size: inherit !important;
}

.sell-dates-container * {
  color: #2d3748 !important;
  font-weight: 600 !important;
  font-size: inherit !important;
}

/* Chart tooltip */
.chartjs-tooltip {
  background: rgba(0, 0, 0, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: var(--radius-md) !important;
  color: var(--bg-white) !important;
  font-size: 12px !important;
  padding: 8px 12px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.chartjs-tooltip .chartjs-tooltip-title {
  color: var(--bg-white) !important;
  font-weight: bold !important;
  margin-bottom: 4px !important;
}

.chartjs-tooltip .chartjs-tooltip-body {
  color: var(--bg-white) !important;
}

/* Profit/Loss styles */
.profit { color: #28a745; font-weight: 600; }
.loss { color: #dc3545; font-weight: 600; }

/* ===========================================
   RESPONSIVE DESIGN - SIMPLIFIED
   =========================================== */

/* Tablet and smaller */
@media (max-width: 768px) {
  /* Logo responsive sizing */
  :root {
    --logo-height: 28px;
    --logo-width: 105px;
  }
  
  .quick-date-buttons {
    gap: 6px;
  }
  
  .quick-date-btn, .market-btn {
    padding: 6px 10px;
    font-size: 13px;
    min-height: 32px;
  }
  
  .asset-buttons, .period-buttons {
    gap: 8px;
  }
  
  .asset-btn, .period-btn {
    width: 140px;
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .chart-container {
    height: 450px;
  }
  
  .dual-chart-container {
    grid-template-columns: 1fr;
    gap: 16px;
  }

}

/* Mobile */
@media (max-width: 480px) {
  /* Logo responsive sizing for mobile */
  :root {
    --logo-height: 24px;
    --logo-width: 90px;
  }
  
  .header-section {
    margin-bottom: 24px;
    padding: 16px;
    border-radius: var(--radius-md);
  }
  
  .header-top {
    flex-direction: row;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
  }
  
  .menu-container {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
  }
  
  .menu-dropdown {
    position: fixed;
    top: 70px;
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
    border-radius: var(--radius-lg);
    margin-top: 0;
  }
  
  .hamburger-menu {
    width: 21px;
    height: 21px;
    padding: 8px;
  }

  .hamburger-check:checked ~ .hamburger-line:nth-child(2) {
    transform: translate(0, 7px) rotate(45deg);
  }
  
  .hamburger-check:checked ~ .hamburger-line:nth-child(3) {
    transform: scale(0);
    opacity: 0;
  }
  
  .hamburger-check:checked ~ .hamburger-line:nth-child(4) {
    transform: translate(0, -7px) rotate(-45deg);
  }
  
  .logo {
    height: 28px;
  }
  
  .bitsaving-btn {
    font-size: 12px;
    padding: 8px 14px;
  }
  
  h1 {
    font-size: 1.8em;
    margin-top: 24px;
    margin-bottom: 20px;
  }

  .settings-section {
    padding: 16px;
    border-radius: var(--radius-md);
  }
  
  .strategy-section {
    padding: 16px;
    border-radius: var(--radius-sm);
  }
  
  .chart-container {
    height: 350px;
  }
  
  .quick-date-buttons {
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .quick-date-buttons::-webkit-scrollbar {
    display: none;
  }
  
  .quick-date-btn, .market-btn {
    flex-shrink: 0;
    padding: 8px 10px;
    font-size: 12px;
  }
  
  .asset-buttons, .period-buttons {
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .asset-buttons::-webkit-scrollbar,
  .period-buttons::-webkit-scrollbar {
    display: none;
  }
  
  .asset-btn, .period-btn {
    width: 120px;
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 12px;
  }
}
