/* =========================================================================
   DevVN So sánh — styles
   Dùng biến --primary-color của theme (có fallback).
   ========================================================================= */
:root {
    --dcb-primary: var(--primary-color, #d70018);
    --dcb-radius: 8px;
    --dcb-border: #e5e7eb;
    --dcb-text: #1f2937;
    --dcb-muted: #6b7280;
    --dcb-bg: #ffffff;
    --dcb-shadow: 0 -4px 24px rgba(0, 0, 0, .12);
    --dcb-diff: #fff8e1;
}

/* -------------------------------------------------------------------------
   Nút "So sánh" trên trang sản phẩm
   ------------------------------------------------------------------------- */
.devvn-compare-add .label-ss {
    display: inline-block;
    padding: 2px 6px;
    color: #3858e9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: transparent;
    font-weight: 400;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.devvn-compare-add span::before {
    content: "\e00c";
    font-family: "fl-icons";
    display: inline-block;
    font-size: 10px;
    margin-right: 4px;
}
.devvn-compare-add.added span::before {
    content: "\e00a";
}
.devvn-compare-add:focus-visible {
    outline: 2px solid var(--dcb-primary);
    outline-offset: 2px;
}

.devvn-compare-add span:hover, .devvn-compare-add.added span {
    background: var(--dcb-primary);
    border-color: var(--dcb-primary);
    color: #fff;
    
}

.devvn-compare-add.added i { transform: rotate(180deg); }

/* -------------------------------------------------------------------------
   Thanh so sánh nổi (bar)
   ------------------------------------------------------------------------- */
.devvn-compare-bar button {
    margin-bottom: 0;
}

.devvn-compare-bar {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: var(--dcb-bg);
    box-shadow: var(--dcb-shadow);
    transform: translateY(110%);
    transition: transform .28s cubic-bezier(.16, 1, .3, 1);
}
.devvn-compare-bar.is-active {
    display: block;
}
.devvn-compare-bar.is-active { transform: translateY(0); }
.devvn-compare-bar.is-active.is-collapsed {
    transform: translateY(calc(100% - 3px));
    background-color: var(--primary-color);
}

.devvn-compare-bar .dcb-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 16px;
}

.devvn-compare-bar .dcb-toggle {
    position: absolute;
    top: -32px;
    left: 15px;
    width: auto;
    height: 32px;
    min-height: 32px;
    border: none;
    border-radius: 8px 8px 0 0 !important;
    background: var(--dcb-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 400;
    padding: 0 10px;
    letter-spacing: unset;
    line-height: 1;
    cursor: pointer;
}
.devvn-compare-bar .dcb-toggle::before {
    content: "Thu gọn \f107";
    font-family: "fl-icons";
    font-size: 16px;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
}
.devvn-compare-bar.is-collapsed .dcb-toggle::before { content: "So sánh \f106"; }

.devvn-compare-bar .dcb-title {
    font-weight: 700;
    color: var(--dcb-text);
    white-space: nowrap;
}

.devvn-compare-bar .dcb-slots {
    display: flex;
    gap: 20px;
    flex: 1;
    overflow-x: auto;
}

.devvn-compare-bar .dcb-slot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 96px;
    min-width: 96px;
    height: 84px;
    padding: 6px;
    border: 1px solid var(--dcb-border);
    border-radius: var(--dcb-radius);
    background: #fafafa;
}
.devvn-compare-bar .dcb-slot.is-filled { background: #fff; }
.devvn-compare-bar .dcb-slot img {
    max-width: 40px;
    max-height: 40px;
    object-fit: contain;
}
.devvn-compare-bar .dcb-slot-name {
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    color: var(--dcb-text);
    max-height: 26px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.devvn-compare-bar .dcb-slot-remove {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    min-width: 18px;
    height: 20px;
    min-height: 18px;
    border: none;
    border-radius: 50% !important;
    background: var(--dcb-muted);
    color: #fff;
    font-size: 14px;
    padding: 0;
    margin: 0;
    line-height: 18px;
    cursor: pointer;
}
.devvn-compare-bar .dcb-slot-remove:hover { background: var(--dcb-primary); }

.devvn-compare-bar .dcb-slot-add {
    border-style: dashed;
    cursor: pointer;
    color: var(--dcb-muted);
}
.devvn-compare-bar .dcb-slot-add:hover {
    border-color: var(--dcb-primary);
    color: var(--dcb-primary);
}
.devvn-compare-bar .dcb-plus { font-size: 22px; line-height: 1; }

.devvn-compare-bar .dcb-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.devvn-compare-bar .dcb-clear {
    border: none;
    background: none;
    color: var(--dcb-muted);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
}
.devvn-compare-bar .dcb-compare {
    padding: 10px 22px;
    border: none;
    border-radius: var(--dcb-radius);
    background: var(--dcb-primary);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.devvn-compare-bar .dcb-compare:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* -------------------------------------------------------------------------
   Modal tìm sản phẩm
   ------------------------------------------------------------------------- */
.devvn-compare-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    background: rgba(0, 0, 0, .5);
    padding: 8vh 16px;
}
.devvn-compare-modal.is-open { display: flex; }
.devvn-compare-modal .dcm-box {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
}
.devvn-compare-modal .dcm-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: none;
    background: none;
    font-size: 24px;
    line-height: 1;
    color: var(--dcb-muted);
    cursor: pointer;
}
.devvn-compare-modal .dcm-head {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 12px;
}
.devvn-compare-modal .dcm-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--dcb-border);
    border-radius: var(--dcb-radius);
    font-size: 14px;
    box-sizing: border-box;
}
.devvn-compare-modal .dcm-input:focus {
    outline: none;
    border-color: var(--dcb-primary);
}
.devvn-compare-modal .dcm-results {
    margin-top: 10px;
    max-height: 50vh;
    overflow-y: auto;
}
.devvn-compare-modal .dcm-msg {
    padding: 16px;
    text-align: center;
    color: var(--dcb-muted);
    font-size: 14px;
}
.devvn-compare-modal .dcm-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--dcb-radius);
    cursor: pointer;
}
.devvn-compare-modal .dcm-result:hover { background: #f3f4f6; }
.devvn-compare-modal .dcm-result img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    flex: 0 0 auto;
}
.devvn-compare-modal .dcm-result-name {
    flex: 1;
    font-size: 14px;
    color: var(--dcb-text);
}
.devvn-compare-modal .dcm-result-name small {
    display: block;
    color: var(--dcb-primary);
    font-size: 12px;
}
.devvn-compare-modal .dcm-result-add {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--dcb-primary);
    color: #fff;
    text-align: center;
    line-height: 26px;
    font-size: 18px;
    flex: 0 0 auto;
}

/* -------------------------------------------------------------------------
   Toast
   ------------------------------------------------------------------------- */
.devvn-compare-toast {
    position: fixed;
    left: 50%;
    bottom: 120px;
    transform: translateX(-50%) translateY(20px);
    z-index: 10001;
    max-width: 90vw;
    padding: 12px 18px;
    border-radius: var(--dcb-radius);
    background: #1f2937;
    color: #fff;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.devvn-compare-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* -------------------------------------------------------------------------
   Bảng so sánh
   ------------------------------------------------------------------------- */
.devvn_compare_result_wrap {
    background: #fff;
    padding: 15px;
    margin-bottom: 30px;
} 
.devvn_compare_result_wrap .title-page {
    font-size: 22px;
    margin: 0 0 12px;
}
.devvn-only-diff {
    margin-right: 6px;
    vertical-align: middle;
}
.devvn-only-diff-toggle {
    display: inline-block !important;
    vertical-align: middle;
    margin-bottom: 12px;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}
.devvn_compare_result_content {
    overflow-x: auto;            /* cuộn ngang trên mobile */
    -webkit-overflow-scrolling: touch;
}
.devvn-compare-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.devvn-compare-table td:first-child, .devvn-compare-table th:first-child {
    padding-left: 10px;
}
.devvn-compare-table th,
.devvn-compare-table td {
    border: 1px solid var(--dcb-border);
    padding: 10px;
    vertical-align: middle;
    word-wrap: break-word;
}
.devvn-compare-table .devvn-cell-center { text-align: center; }

.devvn-compare-table .devvn-section-row th {
    background: var(--dcb-primary);
    color: #fff;
    text-align: left;
    font-weight: 700;
}

/* Cột nhãn ghim trái khi cuộn ngang */
.devvn-compare-table td:first-child,
.devvn-compare-table th:first-child {
    position: sticky;
    left: 0;
    background: #f9fafb;
    z-index: 1;
}
.devvn-compare-table .devvn-section-row th:first-child { background: var(--dcb-primary); }

/* Ảnh + tên + nút mua */
.devvn-cell-image .picture_small { text-align: center; }
.devvn-cell-image img {
    width: auto;
    max-height: 120px;
    object-fit: contain;
    margin: 0 auto;
}
.devvn-cell-image h2 {
    font-size: 14px;
    margin: 8px 0;
    color: var(--fs-color-base);
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 28px;
    max-height: 38px !important;
}
.devvn-cell-image .buy-button {
    display: inline-block;
    margin-top: 4px;
    padding: 8px 18px;
    border-radius: var(--dcb-radius);
    background: var(--dcb-primary);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}
.devvn-cell-image .price { color: var(--dcb-primary); font-weight: 700; }

/* Highlight điểm khác nhau */
.devvn-compare-table tr.is-different td:not(:first-child) {
    background: var(--dcb-diff);
    font-weight: 600;
}
.devvn-compare-table tr.is-different td:first-child { background: #fef3c7; }

/* Toggle "chỉ hiện khác nhau" — thuần CSS */
.devvn-only-diff:checked ~ .devvn_compare_result_content tr.devvn-attr-row.is-same {
    display: none;
}

/* =========================================================================
   Desktop — sticky row ảnh khi cuộn dọc
   ========================================================================= */
.devvn-compare-table .devvn-row-image td {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.devvn-compare-table .devvn-row-image td.devvn-label-col {
    z-index: 3;
    background: #f9fafb;
}

/* =========================================================================
   Bar — mobile
   ========================================================================= */
@media (max-width: 849px) {
    .devvn-compare-bar .dcb-title  { display: none; }
    
    .devvn-compare-bar .dcb-slot   { width: 72px; min-width: 72px; height: 72px; }
    .devvn-compare-bar .dcb-slots {gap: 10px;}
    .devvn-compare-bar .dcb-compare { padding: 5px 12px; font-size: 13px; margin-right: 0;}
}

@media (max-width: 549px) {
    .devvn-compare-bar .dcb-clear  { display: none; }
}

/* =========================================================================
   Bảng so sánh — Mobile (≤ 849px)
   ========================================================================= */
@media (max-width: 849px) {

    .devvn-compare-bar .dcb-toggle {
        left: 0;
    }
    
    .devvn_compare_result_content { overflow-x: visible; }

    /* Reset tất cả phần tử table về block */
    .devvn-compare-table,
    .devvn-compare-table tbody,
    .devvn-compare-table tr { display: block; width: 100%; }
    .devvn-compare-table colgroup { display: none; }

    /* ── Row ảnh: 3 ô sản phẩm xếp ngang, không có nhãn ──────────────── */
    .devvn-compare-table .devvn-row-image {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 5;
        background: #fff;
        box-shadow: 0 2px 6px rgba(0,0,0,.1);
        border-bottom: 2px solid var(--dcb-primary);
    }
    .devvn-compare-table .devvn-row-image .devvn-label-col { display: none; }
    .devvn-compare-table .devvn-row-image .devvn-cell-image {
        flex: 1;
        border: none;
        border-right: 1px solid var(--dcb-border);
        padding: 10px 6px;
        text-align: center;
    }
    .devvn-compare-table .devvn-row-image .devvn-cell-image:last-child { border-right: none; }
    .devvn-compare-table .devvn-row-image img { width: auto; max-height: 64px; }
    .devvn-compare-table .devvn-row-image h2  { font-size: 11px; margin: 5px 0 4px; }
    .devvn-compare-table .devvn-row-image .buy-button { padding: 5px 8px; font-size: 11px; }

    /* ── Section header: full width ───────────────────────────────────── */
    .devvn-compare-table .devvn-section-row { display: block; }
    .devvn-compare-table .devvn-section-row th {
        display: block;
        width: 100%;
        font-size: 13px;
        padding: 8px 10px;
        box-sizing: border-box;
    }

    /* ── Các row thuộc tính: nhãn trên, giá trị dưới ─────────────────── */
    .devvn-compare-table .devvn-attr-row,
    .devvn-compare-table .devvn-row-price { display: block; margin-bottom: 2px; }

    /* Ẩn cột nhãn trong table — nhãn sẽ hiển thị qua ::before của tr */
    .devvn-compare-table .devvn-attr-row .devvn-label-col,
    .devvn-compare-table .devvn-row-price .devvn-label-col { display: none; }

    /* Nhãn thuộc tính: hiện như 1 dòng tiêu đề trên cùng của row */
    .devvn-compare-table .devvn-attr-row::before,
    .devvn-compare-table .devvn-row-price::before {
        content: attr(data-row-label);
        display: block;
        font-weight: 700;
        font-size: 13px;
        color: var(--dcb-text);
        padding: 8px 10px 0;
        background: #f9fafb;
    }

    /* Các td giá trị xếp ngang bằng flexbox */
    .devvn-compare-table .devvn-attr-row,
    .devvn-compare-table .devvn-row-price {
        display: flex;
        flex-wrap: wrap;
    }
    .devvn-compare-table .devvn-attr-row::before,
    .devvn-compare-table .devvn-row-price::before {
        flex: 0 0 100%;   /* chiếm full width */
    }
    .devvn-compare-table .devvn-attr-row td,
    .devvn-compare-table .devvn-row-price td {
        flex: 1;
        border: none;
        border-top: 1px solid var(--dcb-border);
        border-right: 1px solid var(--dcb-border);
        padding: 8px 6px;
        text-align: center;
        font-size: 13px;
        background: #fff;
    }
    .devvn-compare-table .devvn-attr-row td:last-child,
    .devvn-compare-table .devvn-row-price td:last-child { border-right: none; }

    /* Viền ngoài cho mỗi block row */
    .devvn-compare-table .devvn-attr-row,
    .devvn-compare-table .devvn-row-price {
        border: 1px solid var(--dcb-border);
        border-radius: 6px;
        overflow: hidden;
        margin-bottom: 6px;
        background: #f9fafb;
    }
    .devvn-compare-table .devvn-attr-row td,
    .devvn-compare-table .devvn-row-price td { border-top: 1px solid var(--dcb-border); }

    /* Highlight điểm khác nhau */
    .devvn-compare-table .devvn-attr-row.is-different::before { color: var(--dcb-primary); }
    .devvn-compare-table .devvn-attr-row.is-different td      { background: var(--dcb-diff); font-weight: 600; }

    /* Toggle chỉ-khác-nhau */
    .devvn-only-diff:checked ~ .devvn_compare_result_content .devvn-attr-row.is-same { display: none; }

    /* Giá  */
    .devvn-compare-table .devvn-row-price .price { font-size: 13px; color: var(--dcb-primary); font-weight: 700; }
}