/* ============================================================
   PRODUCT COMPARE PAGE — Clean & Professional
   Match: meditechshop.com/compare style
   ============================================================ */

/* ========== Override theme .p-card-img svg ========== */
.md-card-actions svg,
.p-card-img .md-card-actions svg,
.md-compare-btn svg {
    width: 17px !important;
    height: 17px !important;
    stroke: currentColor !important;
    fill: none !important;
    opacity: 1 !important;
}

/* ========== Header Button ========== */
.md-compare-header-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    color: var(--nav-link, #1a1a2e);
    text-decoration: none;
}
.md-compare-header-btn svg { width: 22px; height: 22px; }
.md-compare-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: #2563eb;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    line-height: 1;
}
.md-compare-badge.show { display: flex; }

/* ========== Product Card Button ========== */
.md-card-actions {
    position: absolute;
    top: 50%;
    right: 8px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 3px 14px rgba(0,0,0,0.12);
    overflow: visible;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.p-card:hover .md-card-actions,
.md-card-actions.always-visible {
    opacity: 1;
    pointer-events: auto;
}
.md-compare-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-bottom: 1px solid #eee;
    background: #fff;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}
.md-compare-btn:last-child { border-bottom: none; }
.md-compare-btn svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
.md-compare-btn:hover { background: #eff6ff; color: #2563eb; }
.md-compare-btn.active { background: #2563eb; color: #fff; }
.md-compare-btn.active svg { stroke: #fff; }

/* ========== Single Product Page Button ========== */
.pd-cta .md-compare-btn-single {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: #fff;
    border: 1px solid #d4d4d8;
    border-radius: 8px;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s ease;
    text-decoration: none;
}
.pd-cta .md-compare-btn-single:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}
.pd-cta .md-compare-btn-single.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* ============================================================
   COMPARE PAGE — Exact match: meditechshop.com/compare style
   Clean, minimal, no blue header, gray labels, thin borders
   ============================================================ */

/* ========== Page Wrapper ========== */
.md-compare-page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0;
}

/* ========== Simple Header (breadcrumb + title) ========== */
.md-compare-simple-header {
    padding: 24px 0 16px;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 20px;
}
.md-compare-breadcrumb {
    font-size: 13px;
    color: #888;
    margin-bottom: 6px;
}
.md-compare-breadcrumb a {
    color: #2563eb;
    text-decoration: none;
}
.md-compare-breadcrumb a:hover { text-decoration: underline; }
.md-compare-breadcrumb span { margin: 0 6px; color: #ccc; }
.md-compare-simple-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #222;
    margin: 0 0 4px;
}
.md-compare-simple-header p {
    font-size: 13px;
    color: #888;
    margin: 0;
}

/* ============================================================
   COMPARISON TABLE — meditechshop.com exact clone
   No colored header. All rows are body rows.
   ============================================================ */
.md-compare-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;

    background: #fff;
}
.md-compare-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    font-size: 14px;
    line-height: 1.6;
}

/* All table cells: thin borders, consistent padding */
.md-compare-table td {
    padding: 14px 18px;
    border: 1px solid #f0f0f0;
    vertical-align: middle;
    color: #333;
    background: #fff;
}
.md-compare-table tr:last-child td { border-bottom: 1px solid #e8e8e8; }

/* Label column (first column) — white background, only hover gets color */
.md-label-cell {
    background: #fff;
    font-weight: 600;
    color: #222;
    width: 160px;
    min-width: 160px;
    white-space: nowrap;
    position: sticky;
    left: 0;
    z-index: 1;
    text-align: left;
    vertical-align: middle;
}

/* Product row — image centered, name bold, stock status below */
.md-product-row td { vertical-align: top; text-align: center; }
/* Label cell inside product row: left align + vertical center (override) */
.md-product-row td.md-label-cell {
    vertical-align: middle !important;
    text-align: left !important;
}
.md-product-cell {
    vertical-align: top !important;
    text-align: center !important;
    padding-top: 28px !important;
    padding-bottom: 24px !important;
    position: relative;
}
.md-prod-img {
    max-width: 140px;
    max-height: 120px;
    object-fit: contain;
    display: block;
    margin: 0 auto 10px;
}
.md-prod-name {
    font-size: 15px;
    font-weight: 700;
    color: #222;
    margin-bottom: 3px;
    line-height: 1.35;
}
.md-stock-status {
    display: inline-block;
    font-size: 12px;
    color: #2e7d32;
    font-weight: 500;
}

/* Description row */
.md-compare-table tbody tr:nth-child(2) td {
    line-height: 1.65;
    font-size: 13px;
    color: #444;
}

/* Data rows: white background by default, only hover gets color */
/* Product row (first row) — no hover background */
.md-compare-table tbody tr:first-child:hover td {
    background-color: #fff;
}
.md-compare-table tbody tr:first-child:hover .md-label-cell {
    background-color: #fff !important;
}
/* Other rows: hover gets light gray */
.md-compare-table tbody tr:nth-child(n+2):hover td {
    background-color: #f8f8f8;
}
.md-compare-table tbody tr:nth-child(n+2):hover .md-label-cell {
    background-color: #f0f0f0 !important;
}

/* Remove button in product cell (top-right corner) */
.md-product-remove-btn {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: 1px solid #ddd;
    color: #999;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}
.md-product-remove-btn:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    color: #fff;
}

/* ========== Empty State ========== */
.md-compare-empty {
    text-align: center;
    padding: 60px 24px;
    max-width: 400px;
    margin: 0 auto;
}
.md-compare-empty-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    background: #f5f5f5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.md-compare-empty-icon svg { width: 32px; height: 32px; stroke: #999; fill: none; stroke-width: 1.5; }
.md-compare-empty h2 { font-size: 19px; font-weight: 700; color: #222; margin: 0 0 8px; }
.md-compare-empty p { font-size: 14px; color: #888; margin: 0 0 24px; line-height: 1.6; }
.md-compare-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #555;
    color: #fff;
    padding: 10px 24px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.25s;
}
.md-compare-back-btn:hover { background: #333; transform: translateY(-1px); }

/* ========== Loading ========== */
.md-compare-loading {
    text-align: center;
    padding: 60px;
    color: #888;
    font-size: 14px;
}

/* ========== Compare Page Toolbar ========== */
.md-compare-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    margin-bottom: 20px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    flex-wrap: wrap;
}
.md-compare-tool {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    color: #444;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    line-height: 1;
}
.md-compare-tool:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #f4f8ff;
}
.md-compare-tool.disabled,
.md-compare-tool:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: #e0e0e0;
    color: #999;
    background: #fafafa;
}
.md-compare-tool svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}
.md-compare-select-all {
    padding-left: 10px;
    user-select: none;
}
.md-compare-select-all input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0 6px 0 0;
    cursor: pointer;
    accent-color: #2563eb;
}
.md-compare-select-all span { cursor: pointer; }
.md-compare-tool-separator {
    width: 1px;
    height: 22px;
    background: #e0e0e0;
    margin: 0 4px;
}
.md-compare-delete { color: #c0392b; }
.md-compare-delete:hover {
    border-color: #c0392b;
    color: #c0392b;
    background: #fdf2f1;
}
.md-compare-delete.disabled,
.md-compare-delete:disabled {
    color: #999;
    background: #fafafa;
    border-color: #e0e0e0;
}

/* ========== Compare Page Share Popover（灰色调，契合网站整体风格）========== */
.md-compare-share-popover {
    position: absolute;
    z-index: 1000;
    background: #f5f5f5;
    color: #333;
    border: 1px solid #e0e0e0;
    padding: 24px 20px 18px;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
    text-align: center;
}
.md-compare-share-popover.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.md-compare-share-popover::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 8px 8px;
    border-style: solid;
    border-color: transparent transparent #f5f5f5;
}
.md-compare-share-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .5px;
    margin-bottom: 14px;
    text-transform: uppercase;
    color: #222;
}
.md-compare-share-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}
.md-compare-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 4px;
    color: #fff;
    text-decoration: none;
    transition: transform .15s ease, opacity .15s;
}
.md-compare-share-btn:hover {
    transform: translateY(-2px);
    opacity: .92;
}
.md-compare-share-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    stroke: none;
    flex-shrink: 0;
}
.md-compare-share-linkedin { background: #0077b5; }
.md-compare-share-x { background: #000000; }
.md-compare-share-email { background: #777; }
.md-compare-share-email svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.md-compare-share-close {
    position: absolute;
    top: 6px;
    right: 6px;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color .15s;
}
.md-compare-share-close:hover { color: #222; }
.md-compare-share-close svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ========== Product Column Checkbox ========== */
.md-product-select {
    position: absolute;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 2;
}
.md-product-select input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.md-product-checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #c8c8c8;
    border-radius: 4px;
    background: #fff;
    transition: all 0.15s ease;
    position: relative;
}
.md-product-select:hover .md-product-checkmark { border-color: #2563eb; }
.md-product-select input:checked + .md-product-checkmark {
    background: #2563eb;
    border-color: #2563eb;
}
.md-product-select input:checked + .md-product-checkmark::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.md-product-select input:focus + .md-product-checkmark { box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

/* ========== Print Styles ========== */
@media print {
    body * { visibility: hidden; }
    .md-compare-page,
    .md-compare-page * { visibility: visible; }
    .md-compare-toolbar,
    .md-compare-toolbar * { display: none !important; }
    .md-product-select { display: none !important; }
    .md-compare-page {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        max-width: none;
        padding: 0 10px;
        margin: 0;
    }
    .md-compare-table-wrap { overflow: visible !important; }
    .md-compare-table { min-width: auto !important; }
    .md-compare-table td { padding: 10px 8px !important; font-size: 12px !important; }
    .md-prod-img { max-width: 100px !important; max-height: 80px !important; }
}

/* ========== Hide theme title ========== */
body.page-template-default .entry-header,
body.page-template-default .page-title,
.md-compare-page .entry-header { display: none !important; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .md-compare-simple-header { padding: 20px 0 14px; }
    .md-compare-simple-header h1 { font-size: 19px; }
    .md-compare-page { padding: 0; }
    .md-compare-toolbar { padding: 10px 12px; gap: 6px; }
    .md-compare-tool { padding: 6px 10px; font-size: 12px; }
    .md-compare-tool svg { width: 14px; height: 14px; }
    .md-compare-tool-separator { height: 18px; }
    .md-compare-table { font-size: 13px; }
    .md-compare-table td { padding: 10px 12px; }
    .md-label-cell { min-width: 110px; width: 110px; font-size: 13px; }
    .md-prod-img { max-width: 100px; max-height: 90px; }
    .md-prod-name { font-size: 14px; }
    .md-product-select { top: 6px; left: 6px; }
}
