.wtao-responsive {
    container-type: inline-size;
}

.wtao-table-wrap {
    overflow-x: auto;
    margin-bottom: 24px;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.wtao-table-wrap::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    display: block;
    width: 30px;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(to left, rgba(255,255,255,0.9), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.wtao-table-wrap.is-scrollable::after {
    opacity: 1;
}

.wtao-table-wrap.is-scrolled-end::after {
    opacity: 0;
}

.wtao-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    line-height: 1.6;
    border: none;
}

.wtao-table th,
.wtao-table td {
    border: none;
}

.wtao-table th {
    background-color: var(--wtao-head-bg, #B3D4F0);
    color: var(--wtao-head-color, #333);
    font-weight: 400;
    text-align: left;
    padding: 10px 14px;
}

.wtao-table td {
    padding: 10px 14px;
    vertical-align: top;
}

.wtao-table tr:hover td {
    background-color: color-mix(in srgb, var(--wtao-head-bg, #B3D4F0) 12%, transparent);
}

/* ─── 桌機樣式：簡約（預設） ─── */

.wtao-style-minimal .wtao-table th {
    border-bottom: 2px solid var(--wtao-head-bg, #B3D4F0);
}

.wtao-style-minimal .wtao-table td {
    border-bottom: 1px solid color-mix(in srgb, var(--wtao-head-bg, #B3D4F0) 25%, #E5DED6);
}

/* ─── 桌機樣式：格線 ─── */

.wtao-style-grid .wtao-table th,
.wtao-style-grid .wtao-table td {
    border: 1px solid color-mix(in srgb, var(--wtao-head-bg, #B3D4F0) 30%, #D5CEC6);
}

/* ─── 桌機樣式：斑馬紋 ─── */

.wtao-style-zebra .wtao-table th {
    border-bottom: 2px solid var(--wtao-head-bg, #B3D4F0);
}

.wtao-style-zebra .wtao-table tbody tr:nth-child(even) td {
    background-color: color-mix(in srgb, var(--wtao-head-bg, #B3D4F0) 8%, transparent);
}

.wtao-style-zebra .wtao-table tbody tr:nth-child(even):hover td {
    background-color: color-mix(in srgb, var(--wtao-head-bg, #B3D4F0) 15%, transparent);
}

/* ─── 手機卡片 ─── */

.wtao-cards {
    display: none;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.wtao-card {
    border: 1px solid color-mix(in srgb, var(--wtao-head-bg, #B3D4F0) 30%, #D5CEC6);
    border-radius: 12px;
    padding: 14px 16px;
    background: #fff;
}

.wtao-card-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid color-mix(in srgb, var(--wtao-head-bg, #B3D4F0) 30%, #D5CEC6);
    color: var(--wtao-card-title-color, #4A4543);
}

.wtao-card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 5px 0;
    font-size: 14px;
    line-height: 1.5;
}

.wtao-card-label {
    min-width: 36px;
    color: #7A726A;
    flex-shrink: 0;
    font-weight: 500;
}

.wtao-style-zebra .wtao-card:nth-child(even) {
    background-color: #EDE8E3;
}

/* ─── 徽章（莫蘭迪色） ─── */

.wtao-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.wtao-badge-ok {
    background-color: #DEF0D0;
    color: #2D6A1E;
}

.wtao-badge-warn {
    background-color: #FFF3D0;
    color: #8A6D00;
}

.wtao-badge-bad {
    background-color: #FDDEDE;
    color: #9A2626;
}

.wtao-badge-blue {
    background-color: #DBEAFE;
    color: #1E40AF;
}

.wtao-badge-purple {
    background-color: #EDE9FE;
    color: #5B21B6;
}

.wtao-badge-pink {
    background-color: #FCE7F3;
    color: #9D174D;
}

.wtao-badge-teal {
    background-color: #CCFBF1;
    color: #115E59;
}

.wtao-badge-orange {
    background-color: #FFEDD5;
    color: #9A3412;
}

.wtao-badge-gray {
    background-color: #F3F4F6;
    color: #4B5563;
}

/* ─── 圖例列 ─── */

.wtao-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 4px;
    font-size: 13px;
}

.wtao-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.wtao-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ─── 圓角 ─── */

.wtao-corner-round .wtao-table-wrap {
    border-radius: 8px;
    overflow: hidden;
}

.wtao-corner-round .wtao-table {
    border-collapse: separate;
    border-spacing: 0;
}

.wtao-corner-round .wtao-card {
    border-radius: 12px;
}

.wtao-corner-square .wtao-table-wrap {
    border-radius: 0;
}

.wtao-corner-square .wtao-card {
    border-radius: 0;
}

/* ─── 密度：緊湊 ─── */

.wtao-density-compact .wtao-table { font-size: 13px; }
.wtao-density-compact .wtao-table th,
.wtao-density-compact .wtao-table td { padding: 7px 10px; }
.wtao-density-compact .wtao-card { padding: 10px 12px; }
.wtao-density-compact .wtao-card-title { font-size: 13px; margin-bottom: 6px; padding-bottom: 6px; }
.wtao-density-compact .wtao-card-row { font-size: 12px; padding: 3px 0; }
.wtao-density-compact .wtao-cards { gap: 8px; }

/* ─── 密度：標準（預設） ─── */

.wtao-density-standard .wtao-table { font-size: 15px; }

/* ─── 密度：寬鬆 ─── */

.wtao-density-relaxed .wtao-table { font-size: 15px; line-height: 1.7; }
.wtao-density-relaxed .wtao-table th,
.wtao-density-relaxed .wtao-table td { padding: 10px 14px; }
.wtao-density-relaxed .wtao-card { padding: 14px 16px; }
.wtao-density-relaxed .wtao-card-title { font-size: 15px; margin-bottom: 10px; padding-bottom: 8px; }
.wtao-density-relaxed .wtao-card-row { font-size: 14px; padding: 4px 0; }
.wtao-density-relaxed .wtao-cards { gap: 12px; }

/* ─── Container Query 響應式切換 ─── */

@container (min-width: 601px) {
    .wtao-cards {
        display: none !important;
    }
    .wtao-table-wrap {
        display: block !important;
    }
}

@container (max-width: 600px) {
    .wtao-table-wrap {
        display: none !important;
    }
    .wtao-cards {
        display: flex !important;
    }
}

/* ─── Fallback：沒有卡片時手機版顯示表格 ─── */

.wtao-responsive:not(:has(.wtao-cards)) .wtao-table-wrap {
    display: block !important;
}
