/**
 * Styles for [thuoc_lo_ban] — layout kiểu tuvi.vn:
 *   - Stacked rulers: 3 thước xếp ngang, share 1 viewport scroll horizontal
 *   - Pointer (vertical line + label cm) cố định ở giữa viewport
 *   - Diễn giải text bên dưới update realtime theo vị trí pointer
 *   - Bảng kích thước chuẩn + tra ngược + kiến thức giữ nguyên
 */

.tlb-wrap { /* inherit từ .xnc-wrap */ }

/* ===== Form input row ===== */
.tlb-form .tlb-input-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-top: 12px;
}
.tlb-field-size { flex: 2 1 220px; }
.tlb-field-unit { flex: 1 1 140px; }
.tlb-submit { flex: 0 0 auto; align-self: flex-end; height: 44px; }
.tlb-cm-equivalent {
    font-size: 14px;
    color: #888;
    font-weight: 400;
    margin-left: 6px;
}

/* ===== Demo note (khi chưa có input) ===== */
.tlb-demo-note {
    background: #fff8e1;
    border-left: 4px solid #b8860b;
    padding: 10px 14px;
    margin-top: 12px;
    color: #6b5510;
    font-size: 15.5px;
    line-height: 1.5;
    border-radius: 4px;
}
.tlb-demo-note strong { color: #7b1414; }

/* ===========================================================
   STACKED RULERS  — layout kiểu tuvi.vn
   =========================================================== */
.tlb-stacked-section {
    margin-top: 16px;
}

.tlb-drag-hint {
    background: #f5f3ed;
    border: 1px dashed #c8b97a;
    padding: 8px 12px;
    border-radius: 6px;
    color: #6b5510;
    font-size: 13px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tlb-hint-icon { font-size: 16px; }

/* Container giữ pointer + viewport — relative để pointer position absolute */
.tlb-stacked-wrap {
    position: relative;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    overflow: hidden; /* clip pointer outside */
    margin-bottom: 16px;
}

/* Pointer: absolute ở giữa viewport, fullheight */
.tlb-pointer {
    position: absolute;
    left: 50%;
    top: 36px;            /* dưới drag-hint */
    bottom: 0;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.tlb-pointer-label {
    background: #d4a017;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(212, 160, 23, 0.5);
    margin-bottom: 2px;
    white-space: nowrap;
    border: 2px solid #fff;
}
.tlb-pointer-arrow {
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 9px solid #d4a017;
    margin-bottom: -2px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}
.tlb-pointer-line {
    flex: 1;
    width: 2px;
    background: linear-gradient(to bottom,
        rgba(212, 160, 23, 0.95) 0%,
        rgba(212, 160, 23, 0.6) 70%,
        rgba(212, 160, 23, 0.3) 100%);
    box-shadow: 0 0 4px rgba(212, 160, 23, 0.4);
}

/* Viewport: scrollable horizontally */
.tlb-stacked-viewport {
    overflow-x: auto;
    overflow-y: hidden;
    cursor: grab;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #c0a060 #f5f0e8;
    padding-bottom: 4px;
}
.tlb-stacked-viewport.tlb-dragging { cursor: grabbing; }
.tlb-stacked-viewport::-webkit-scrollbar { height: 10px; }
.tlb-stacked-viewport::-webkit-scrollbar-track { background: #f5f0e8; }
.tlb-stacked-viewport::-webkit-scrollbar-thumb {
    background: #c0a060;
    border-radius: 6px;
}
.tlb-stacked-viewport::-webkit-scrollbar-thumb:hover { background: #a07840; }

.tlb-stacked-track {
    /* width set inline (15000px) */
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
}

/* === cm scale row === */
.tlb-cm-scale {
    position: relative;
    height: 28px;
    background: linear-gradient(to bottom, #fafaf7, #f0ece2);
    border-bottom: 1px solid #d8c89e;
}
.tlb-cm-tick {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}
.tlb-cm-tick-line {
    width: 1px;
    height: 6px;
    background: #999;
}
.tlb-cm-tick.tlb-cm-major .tlb-cm-tick-line {
    height: 10px;
    width: 2px;
    background: #555;
}
.tlb-cm-tick-label {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
    transform: translateX(-50%);
    position: relative;
    left: 0; /* labels are positioned relative to tick */
    white-space: nowrap;
}
.tlb-cm-tick.tlb-cm-major .tlb-cm-tick-label {
    font-weight: 700;
    color: #333;
}

/* === Ruler band === */
.tlb-ruler-band {
    border-bottom: 2px solid #f0ece2;
}
.tlb-ruler-band:last-child {
    border-bottom: none;
}

/* Label row (sticky-left) */
.tlb-band-label {
    position: sticky;
    left: 0;
    z-index: 4;
    display: inline-block;
    background: rgba(255, 255, 255, 0.97);
    padding: 8px 14px;
    border-left: 4px solid #b8860b;
    border-bottom-right-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.04);
    max-width: 90vw;
}
.tlb-band-label strong { color: #7b1414; }
.tlb-band-use {
    color: #555;
    font-size: 12px;
    margin-left: 6px;
}

/* Cung lớn row */
.tlb-cung-lon-row {
    display: flex;
    height: 34px;
    margin-top: 4px;
}
.tlb-cung-lon-cell {
    flex: 0 0 auto;
    height: 34px;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-right: 1px solid rgba(255,255,255,0.3);
    box-sizing: border-box;
    padding: 0 4px;
}
.tlb-cung-lon-cell:last-child { border-right: none; }
.tlb-cung-lon-cell.tlb-good { background: #c0392b; }
.tlb-cung-lon-cell.tlb-bad  { background: #1c1c1c; }
.tlb-cung-lon-cell span {
    text-shadow: 0 1px 1px rgba(0,0,0,0.4);
    letter-spacing: 0.3px;
}

/* Cung con row */
.tlb-cung-con-row {
    display: flex;
    height: 28px;
    background: #fafafa;
    border-top: 1px solid #fff;
}
.tlb-cung-con-cell {
    flex: 0 0 auto;
    height: 28px;
    background: #fff;
    border-right: 1px solid #eee;
    border-bottom: 3px solid;
    font-size: 10px;
    line-height: 1.1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box;
    padding: 0 3px;
}
.tlb-cung-con-cell.tlb-good {
    border-bottom-color: #c0392b;
    color: #1c1c1c;
}
.tlb-cung-con-cell.tlb-bad {
    border-bottom-color: #1c1c1c;
    color: #333;
}

/* ===========================================================
   READINGS — diễn giải text bên dưới rulers
   =========================================================== */
.tlb-readings {
    background: #fffdf5;
    border: 1px solid #e8d8a8;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.tlb-reading {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px dashed #e0d8c4;
}
.tlb-reading:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.tlb-reading-head {
    margin-bottom: 6px;
}
.tlb-reading-head strong { color: #7b1414; font-size: 14px; }
.tlb-reading-use {
    color: #666;
    font-size: 12px;
    margin-left: 4px;
}
.tlb-reading-body {
    margin: 0 0 6px;
    line-height: 1.6;
    color: #2c2c2c;
    font-size: 15.5px;
}
.tlb-reading-cm {
    color: #d4a017;
    font-size: 15px;
}
.tlb-name { font-size: 15px; }
.tlb-good-text { color: #c0392b; }
.tlb-bad-text  { color: #1c1c1c; }
.tlb-reading-summary {
    color: #4a4a4a;
    font-style: italic;
}
.tlb-reading-sub {
    margin: 0;
    padding: 6px 10px;
    background: #f5f0e0;
    border-radius: 4px;
    font-size: 14.5px;
    color: #555;
    line-height: 1.5;
}
.tlb-reading-sub em { color: #b8860b; font-style: italic; }

/* ===== Hướng dẫn chọn thước ===== */
.tlb-guide {
    background: #fff8e1;
    border-left: 4px solid #b8860b;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.tlb-guide-title { margin: 0 0 8px; color: #7b1414; font-size: 15px; }
.tlb-guide-list {
    padding-left: 22px;
    margin: 0;
    line-height: 1.6;
}
.tlb-guide-list li { margin-bottom: 4px; color: #4a4a4a; }

/* ===========================================================
   PHẦN 2: BẢNG KÍCH THƯỚC CHUẨN
   =========================================================== */
.tlb-standard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    margin-top: 12px;
}
.tlb-std-card {
    background: #fff;
    border: 1px solid #e8e0d4;
    border-radius: 8px;
    padding: 12px 14px;
}
.tlb-std-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.tlb-std-name { color: #7b1414; font-size: 15px; }
.tlb-std-ruler {
    font-size: 11px;
    color: #888;
    background: #f5f0e8;
    padding: 3px 8px;
    border-radius: 10px;
}
.tlb-std-note {
    margin: 0 0 10px;
    color: #666;
    font-size: 12px;
    font-style: italic;
    line-height: 1.4;
}
.tlb-std-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tlb-std-list li {
    padding: 8px 10px;
    background: #fafaf7;
    border-radius: 6px;
    border-left: 3px solid #2e7d32;
    transition: background 0.15s;
}
.tlb-std-list li:hover { background: #f0ede5; }
.tlb-std-size {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: inherit;
    margin-bottom: 4px;
}
.tlb-std-dim {
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tlb-std-value { color: #2e7d32; font-size: 16px; font-weight: 700; }
.tlb-std-size:hover .tlb-std-value { text-decoration: underline; }
.tlb-std-desc {
    display: block;
    color: #555;
    font-size: 12px;
    line-height: 1.4;
}

/* ===========================================================
   PHẦN 3: TRA NGƯỢC
   =========================================================== */
.tlb-reverse {
    background: #f5f3ed;
    border-left: 4px solid #b8860b;
}
.tlb-reverse-form { margin-top: 8px; }
.tlb-reverse-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: wrap;
}
.tlb-reverse-select { flex: 2 1 280px; min-height: 44px; }
.tlb-reverse-submit { flex: 0 0 auto; height: 44px; align-self: stretch; }

.tlb-reverse-result {
    margin-top: 14px;
    background: #fff;
    border: 1px solid #e0d8c4;
    border-radius: 8px;
    padding: 14px 16px;
}
.tlb-reverse-header h5 { margin: 0 0 4px; color: #7b1414; font-size: 16px; }
.tlb-reverse-header p { margin: 0 0 12px; color: #555; font-style: italic; font-size: 13px; }
.tlb-reverse-groups {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.tlb-reverse-group {
    padding: 10px 12px;
    background: #fafaf7;
    border-radius: 6px;
}
.tlb-rev-sub-head { margin-bottom: 8px; }
.tlb-rev-sub-head strong { color: #c0392b; font-size: 14px; }
.tlb-rev-sub-head small { color: #666; font-size: 12px; }
.tlb-rev-sizes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tlb-rev-pill {
    display: inline-block;
    padding: 6px 14px;
    background: #2e7d32;
    color: #fff;
    border-radius: 16px;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
}
.tlb-rev-pill:hover {
    background: #1b5e20;
    transform: translateY(-1px);
    color: #fff;
    text-decoration: none;
}
.tlb-reverse-note { margin: 12px 0 0; color: #6b5510; font-size: 13px; }
.tlb-reverse-empty {
    margin-top: 12px;
    padding: 14px;
    background: #fff;
    border-radius: 6px;
    color: #888;
    font-style: italic;
    text-align: center;
}

/* ===========================================================
   PHẦN 4: KIẾN THỨC
   =========================================================== */
.tlb-knowledge { background: #fafaf7; }
.tlb-knowledge summary {
    cursor: pointer;
    padding: 6px 0;
    font-size: 15px;
    color: #7b1414;
}
.tlb-knowledge-body {
    margin-top: 12px;
    line-height: 1.65;
    color: #4a4a4a;
}
.tlb-knowledge-body h5 {
    color: #7b1414;
    margin: 14px 0 8px;
    font-size: 15px;
}
.tlb-knowledge-body ul { padding-left: 22px; margin: 6px 0; }
.tlb-knowledge-body li { margin-bottom: 5px; }
.tlb-knowledge-body em { color: #b8860b; font-style: italic; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .tlb-input-row {
        flex-direction: column;
        align-items: stretch;
    }
    .tlb-field-size, .tlb-field-unit { flex: 1 1 auto; }
    .tlb-submit { width: 100%; }
    .tlb-standard-grid { grid-template-columns: 1fr; }
    .tlb-reverse-row { flex-direction: column; }
    .tlb-reverse-submit { width: 100%; }

    .tlb-band-label { font-size: 12px; padding: 6px 10px; }
    .tlb-band-use { display: block; margin-left: 0; font-size: 11px; }
    .tlb-cung-lon-cell { font-size: 10px; }
    .tlb-cung-con-cell { font-size: 9px; }
    .tlb-cm-tick-label { font-size: 9px; }
    .tlb-pointer-label { font-size: 12px; padding: 3px 9px; }
}
