/* ========================================================================== */
/* 被動投資資訊站 ｜ 蒙地卡羅模擬器專用樣式 (KOYO BASE Aesthetic & RWD)        */
/* ========================================================================== */

/* 數字對齊 (避免數字跳動與不等寬變形) */
input, select, table, .tabular-nums, #kpi-cards-grid {
  font-variant-numeric: tabular-nums lining-nums;
}

/* KOYO BASE 卡片外框 */
.glass-card {
  background: #FFFFFF;
  border: 1px solid #DFDACD !important;
  border-radius: 1.25rem;
  box-shadow: 0 2px 8px -2px rgba(26, 47, 69, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-card:hover {
  border-color: #1285C5 !important;
}

/* KPI 核心指標卡片排版與防裁切 */
#kpi-cards-grid .glass-card {
  padding: 0.875rem 1rem !important;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@media (min-width: 1280px) {
  #kpi-cards-grid .glass-card {
    padding: 1rem 1.125rem !important;
  }
}

#kpi-p50, #kpi-p10, #kpi-success-rate, #kpi-drawdown {
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap !important;
  overflow: visible !important;
}

/* 資產選單完整寬度 */
.asset-key-select {
  max-width: 100%;
}

/* 強化所有輸入框與選單邊框線條 */
input[type="number"],
input[type="text"],
select {
  border-color: #DFDACD !important;
  border-width: 1px !important;
}

input:focus,
select:focus {
  border-color: #1285C5 !important;
  box-shadow: 0 0 0 3px rgba(18, 133, 197, 0.15) !important;
}

/* 隱藏 number input 預設 spinner */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* 滑動條 accent 色彩 */
input[type="range"] {
  accent-color: #1285C5;
}

/* 捲軸美化 */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: #F0ECE1;
}

::-webkit-scrollbar-thumb {
  background: #B4C0CA;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #8A9BA8;
}

/* 動畫與過渡 */
.fade-in {
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* 權重總和狀態指示 */
.weight-badge-valid {
  background-color: #E6F4EA;
  color: #137333;
  border: 1.5px solid #34A853 !important;
}

.weight-badge-invalid {
  background-color: #FCE8E6;
  color: #C5221F;
  border: 1.5px solid #EA4335 !important;
}

/* 運算更新高亮動畫 (點擊執行後的視覺反饋) */
.flash-update {
  animation: flashHighlight 0.6s ease-out;
}

@keyframes flashHighlight {
  0% {
    background-color: rgba(18, 133, 197, 0.18);
    transform: scale(1.01);
  }
  50% {
    background-color: rgba(18, 133, 197, 0.08);
  }
  100% {
    background-color: transparent;
    transform: scale(1);
  }
}

/* 按鈕點擊波紋與縮放 */
#btn-run-simulation:active {
  transform: scale(0.96) !important;
}

.btn-simulation-running {
  background: #F0ECE1 !important;
  color: #566A7C !important;
  border-color: #B4C0CA !important;
  cursor: wait !important;
}

.btn-simulation-success {
  background: #E6F4EA !important;
  color: #137333 !important;
  border-color: #34A853 !important;
}

/* 行動裝置排版優化 */
.no-scrollbar::-webkit-scrollbar {
  display: none !important;
}
.no-scrollbar {
  -ms-overflow-style: none !important;
  scrollbar-width: none !important;
}

.touch-scroll-x {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  scroll-behavior: smooth !important;
  overscroll-behavior-x: contain !important;
}

@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent;
  }

  .glass-card {
    padding: 0.875rem !important;
    border-radius: 1rem !important;
  }

  #main-content {
    padding-bottom: 5.5rem !important;
  }

  table {
    word-break: keep-all;
    white-space: nowrap;
  }

  label {
    line-height: 1.35;
  }
}

/* 手機版專屬底部浮動快捷導航 Bar */
.mobile-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(248, 246, 237, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid #E2DDD1;
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 20px -2px rgba(26, 47, 69, 0.08);
}

/* 列印專用樣式 */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
  }

  .no-print,
  .mobile-bottom-bar,
  header,
  footer {
    display: none !important;
  }

  .glass-card {
    box-shadow: none !important;
    border: 1px solid #607382 !important;
    break-inside: avoid;
    margin-bottom: 1rem !important;
  }

  canvas {
    max-height: 320px !important;
  }

  table {
    font-size: 9pt !important;
  }
}
