/**
 * TWSE 盤後成交量前 20 名表格樣式
 * 
 * 用於短代碼: [twstockyr_aht_top20]
 * 設計風格: 專業金融資訊表格
 * 
 * @package TwStockYR
 * @since 1.0.0
 */

/* ========================================
   容器樣式
   ======================================== */

.twstockyr-top20-container {
  max-width: 100%;
  margin: 20px auto;

  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* ========================================
   標題區域
   ======================================== */

.twstockyr-top20-header {
  background: var(--yr-notice-color);
  background-blend-mode: multiply;
  padding: 20px 24px;
  color: #ffffff;
}

.twstockyr-top20-title {
  margin: 0 0 10px 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--yr-text-light-color);
}

.twstockyr-top20-meta {
  display: flex;
  gap: 1rem;
  font-size: 13px;
  opacity: 0.95;
  flex-wrap: wrap;
}

.twstockyr-top20-meta .meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.twstockyr-top20-meta .meta-label {
  opacity: 0.85;
}

.twstockyr-top20-meta .meta-value {
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 10px;
  border-radius: 4px;
  line-height: 1;
}

.twstockyr-top20-meta .meta-badge {
  display: inline-block;
  font-weight: 700;
  font-size: 13px;
  padding: 0px 24px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--yr-primary-700);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.twstockyr-top20-meta .meta-badge.after-hours {
  background: var(--yr-primary-100);
  color: var(--yr-primary-700);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

/* ========================================
   表格容器
   ======================================== */

.twstockyr-top20-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========================================
   表格主體
   ======================================== */

.twstockyr-top20-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.6;
}

/* 表頭樣式 */
.twstockyr-top20-table thead {
  background: linear-gradient(to bottom, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 2px solid #dee2e6;
}

.twstockyr-top20-table thead th {
  padding: 14px 12px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  color: #495057;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #dee2e6;
}

/* 表身樣式 */
.twstockyr-top20-table tbody tr {
  border-bottom: 1px solid #f1f3f5;
  transition: all 0.2s ease;
}

.twstockyr-top20-table tbody tr:hover {
  background-color: #f8f9fa;
  transform: scale(1.01);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.twstockyr-top20-table tbody td {
  padding: 14px 12px;
  text-align: center;
  color: #212529;
}

/* ========================================
   列樣式
   ======================================== */

/* 排名列 */
.col-rank {
  width: 60px;
  min-width: 60px;
}

.rank-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 70%;
  margin: auto;
  min-width: 16px;
  min-height: 16px;
  aspect-ratio: 1/1;
  padding: 4px;
  border-radius: var(--yr-unit-full);
  font-weight: 700;
  font-size: 13px;
}

.rank-badge.rank-top {
  background: var(--site-btn-hover-color);
  color: #ffffff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--site-btn-hover-color) 30%, transparent);
}

.rank-badge.rank-normal {
  background: #e9ecef;
  color: #6c757d;
}

/* 代號列 */
.col-symbol {
  width: 90px;
  min-width: 90px;
  font-weight: 600;
  color: #495057;
}

/* 名稱列 */
.col-name {
  width: 120px;
  min-width: 120px;
  text-align: left;
  font-weight: 500;
}

/* 成交量列 */
.col-volume {
  width: 140px;
  min-width: 140px;
  font-family: "Courier New", monospace;
  font-weight: 500;
}

/* 價格列 */
.col-open,
.col-high,
.col-low,
.col-close {
  width: 90px;
  min-width: 90px;
  font-family: "Courier New", monospace;
}

.col-close strong {
  font-weight: 700;
  font-size: 15px;
}

/* 漲跌符號列 */
.col-change {
  width: 70px;
  min-width: 70px;
}

.change-symbol {
  display: inline-block;
  font-size: 18px;
  font-weight: 700;
}

/* 漲跌價差列 */
.col-change-price {
  width: 140px;
  min-width: 140px;
  text-align: right;
  padding-right: 20px !important;
}

.col-change-price strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.change-percent {
  display: block;
  font-size: 12px;
  margin-top: 2px;
  opacity: 0.85;
}

/* ========================================
   漲跌顏色樣式
   ======================================== */

/* 上漲 (紅色) */
.text-up {
  color: #dc3545 !important;
}

.text-up .change-symbol {
  color: #dc3545;
}

/* 下跌 (綠色) */
.text-down {
  color: #28a745 !important;
}

.text-down .change-symbol {
  color: #28a745;
}

/* 平盤 */
.text-flat {
  color: #6c757d !important;
}

.text-flat .change-symbol {
  color: #6c757d;
}

/* ========================================
   註記說明區域
   ======================================== */

.twstockyr-top20-notes {
  background: #f8f9fa;
  padding: 16px 24px;
  border-top: 1px solid #dee2e6;
}

.twstockyr-top20-notes .note-item {
  margin: 6px 0;
  font-size: 12px;
  color: #6c757d;
  line-height: 1.6;
}

.twstockyr-top20-notes .note-icon {
  margin-right: 6px;
}

/* ========================================
   錯誤訊息樣式
   ======================================== */

.twstockyr-top20-error {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  border-radius: 8px;
  padding: 16px 20px;
  margin: 20px 0;
  color: #856404;
  font-size: 14px;
}

.twstockyr-top20-error p {
  margin: 0;
}

/* ========================================
   響應式設計
   ======================================== */

/* 平板 (768px - 1024px) */
@media (max-width: 1024px) {
  .twstockyr-top20-table {
    font-size: 13px;
  }

  .twstockyr-top20-table thead th,
  .twstockyr-top20-table tbody td {
    padding: 12px 10px;
  }

  .col-name {
    min-width: 100px;
  }

  .col-volume {
    min-width: 120px;
  }
}

/* 手機直式 (小於 768px) */
@media (max-width: 768px) {
  .twstockyr-top20-container {
    border-radius: 8px;
    margin: 15px 0;
  }

  .twstockyr-top20-header {
    padding: 16px 16px;
  }

  .twstockyr-top20-title {
    font-size: 16px;
  }

  .twstockyr-top20-meta {
    font-size: 12px;
    gap: 12px;
  }

  .twstockyr-top20-table {
    font-size: 12px;
  }

  .twstockyr-top20-table thead th {
    padding: 10px 6px;
    font-size: 11px;
  }

  .twstockyr-top20-table tbody td {
    padding: 10px 6px;
  }

  /* 調整列寬 */
  .col-rank {
    width: 45px;
    min-width: 45px;
  }

  .rank-badge {
    min-width: 28px;
    padding: 3px 6px;
    font-size: 12px;
  }

  .col-symbol {
    width: 70px;
    min-width: 70px;
    font-size: 12px;
  }

  .col-name {
    width: 90px;
    min-width: 90px;
    font-size: 12px;
  }

  .col-volume {
    width: 110px;
    min-width: 110px;
    font-size: 11px;
  }

  .col-open,
  .col-high,
  .col-low,
  .col-close {
    width: 70px;
    min-width: 70px;
    font-size: 12px;
  }

  .col-close strong {
    font-size: 13px;
  }

  .col-change {
    width: 50px;
    min-width: 50px;
  }

  .change-symbol {
    font-size: 16px;
  }

  .col-change-price {
    width: 110px;
    min-width: 110px;
    padding-right: 12px !important;
  }

  .col-change-price strong {
    font-size: 13px;
  }

  .change-percent {
    font-size: 11px;
  }

  /* 註記區域 */
  .twstockyr-top20-notes {
    padding: 12px 16px;
  }

  .twstockyr-top20-notes .note-item {
    font-size: 11px;
    margin: 4px 0;
  }
}

/* 手機橫式 (小於 480px) */
@media (max-width: 480px) {
  .twstockyr-top20-title {
    font-size: 14px;
  }

  .twstockyr-top20-meta {
    font-size: 11px;
  }

  .twstockyr-top20-table {
    font-size: 11px;
  }

  .twstockyr-top20-table thead th {
    padding: 8px 4px;
    font-size: 10px;
  }

  .twstockyr-top20-table tbody td {
    padding: 8px 4px;
  }

  /* 進一步壓縮列寬 */
  .col-rank {
    width: 40px;
    min-width: 40px;
  }

  .col-symbol {
    width: 60px;
    min-width: 60px;
  }

  .col-name {
    width: 80px;
    min-width: 80px;
  }

  .col-volume {
    width: 100px;
    min-width: 100px;
  }

  .col-open,
  .col-high,
  .col-low,
  .col-close {
    width: 60px;
    min-width: 60px;
  }

  .col-change-price {
    width: 100px;
    min-width: 100px;
  }
}

/* ========================================
   列印樣式
   ======================================== */

@media print {
  .twstockyr-top20-container {
    box-shadow: none;
    border: 1px solid #dee2e6;
  }

  .twstockyr-top20-table tbody tr:hover {
    background-color: transparent;
    transform: none;
    box-shadow: none;
  }

  .twstockyr-top20-notes {
    page-break-inside: avoid;
  }
}

/* ========================================
   載入動畫 (可選)
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.twstockyr-top20-container {
  animation: fadeIn 0.5s ease-out;
}

/* ========================================
   無障礙支援
   ======================================== */

/* .twstockyr-top20-table:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

.twstockyr-top20-table tbody tr:focus-within {
  background-color: #e7f1ff;
  outline: 2px solid #667eea;
} */

/* 高對比模式支援 */
/* @media (prefers-contrast: high) {
  .twstockyr-top20-table thead {
    background: #000000;
    color: #ffffff;
  }

  .text-up {
    color: #ff0000 !important;
    font-weight: 700;
  }

  .text-down {
    color: #00ff00 !important;
    font-weight: 700;
  }
} */

/* 深色模式支援 */
/* @media (prefers-color-scheme: dark) {
  .twstockyr-top20-container {
    background: #1a1a1a;
    color: #e0e0e0;
  }

  .twstockyr-top20-table thead {
    background: linear-gradient(to bottom, #2a2a2a 0%, #1f1f1f 100%);
  }

  .twstockyr-top20-table thead th {
    color: #e0e0e0;
    border-bottom-color: #3a3a3a;
  }

  .twstockyr-top20-table tbody tr {
    border-bottom-color: #2a2a2a;
  }

  .twstockyr-top20-table tbody tr:hover {
    background-color: #2a2a2a;
  }

  .twstockyr-top20-table tbody td {
    color: #e0e0e0;
  }

  .twstockyr-top20-notes {
    background: #1f1f1f;
    border-top-color: #3a3a3a;
  }

  .twstockyr-top20-notes .note-item {
    color: #b0b0b0;
  }

  .rank-badge.rank-normal {
    background: #3a3a3a;
    color: #b0b0b0;
  }
} */
