/**
 * Cdsoft Product Compare — Styles
 * PS 8.2.6 / Bootstrap 4 / Classic theme
 */

/* ---- Add to Compare button ---- */
.cdsoft-compare-btn-wrap {
    display: inline-block;
    margin-top: 8px;
}

.cdsoft-compare-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: none;
    border-radius: 4px;
    padding: 7px 13px;
    cursor: pointer;
    font-size: 0.8125rem; /* 13px — matches PS8 Classic button size */
    font-weight: 500;
    line-height: 1.4;
    transition: opacity .2s, transform .1s;
    white-space: nowrap;
}

.cdsoft-compare-btn:hover,
.cdsoft-compare-btn:focus {
    opacity: .82;
    transform: translateY(-1px);
    outline: 2px solid transparent; /* rely on box-shadow for focus */
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .15);
}

.cdsoft-compare-btn.cdsoft-added {
    opacity: .75;
}

.cdsoft-compare-btn .material-icons {
    font-size: 16px;
    line-height: 1;
    pointer-events: none;
}

/* ---- Floating compare bar ---- */
.cdsoft-compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1040; /* PS8 Classic z-index for fixed elements above content */
    background: #fff;
    border-top: 3px solid #25b9d7;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, .12);
    padding: 10px 20px;
    animation: cdsoftSlideUp .25s ease;
}

@keyframes cdsoftSlideUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.cdsoft-compare-bar-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.cdsoft-compare-bar-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: .875rem;
    white-space: nowrap;
}

.cdsoft-compare-bar-title .material-icons { font-size: 20px; color: #25b9d7; }

.cdsoft-count-badge {
    background: #25b9d7;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.cdsoft-compare-bar-items {
    display: flex;
    gap: 8px;
    flex: 1;
    overflow-x: auto;
    padding-bottom: 2px; /* prevent scrollbar clipping */
    min-height: 52px;
}

.cdsoft-bar-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8f9fa; /* PS8 $gray-100 */
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 8px;
    min-width: 130px;
    max-width: 180px;
    flex-shrink: 0;
}

.cdsoft-bar-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
}

.cdsoft-bar-item-name {
    flex: 1;
    font-size: .75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cdsoft-remove-item {
    background: none;
    border: none;
    color: #adb5bd;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
    transition: color .15s;
}
.cdsoft-remove-item:hover { color: #dc3545; }

.cdsoft-compare-bar-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}

.cdsoft-go-btn {
    background: #25b9d7 !important;
    border-color: #25b9d7 !important;
    color: #fff !important;
}
.cdsoft-go-btn:hover { background: #1da5c0 !important; border-color: #1da5c0 !important; }

/* ---- Compare page ---- */
.cdsoft-compare-page { padding: 20px 0; }

/* Comparison Table design */
.cdsoft-comparison-table-wrap { overflow-x: auto; }

.cdsoft-comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
    min-width: 480px;
}

.cdsoft-comparison-table th,
.cdsoft-comparison-table td {
    border: 1px solid #dee2e6;
    padding: 12px 16px;
    text-align: center;
    vertical-align: middle;
}

.cdsoft-comparison-table thead th {
    background: #f8f9fa;
    font-weight: 700;
}

.cdsoft-label-col {
    width: 160px;
    min-width: 120px;
    text-align: left !important;
    background: #f8f9fa;
}

.cdsoft-label {
    text-align: left;
    font-weight: 600;
    background: #f8f9fa;
}

.cdsoft-product-img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 8px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.cdsoft-product-name {
    display: block;
    font-weight: 600;
    font-size: .8125rem;
    margin-bottom: 6px;
    color: #212529;
    text-decoration: none;
}
.cdsoft-product-name:hover { color: #25b9d7; text-decoration: underline; }

/* PS8 Bootstrap 4 badge colors */
.cdsoft-comparison-table .badge-success,
.cdsoft-data-table .badge-success { background-color: #28a745; color: #fff; }
.cdsoft-comparison-table .badge-danger,
.cdsoft-data-table .badge-danger  { background-color: #dc3545; color: #fff; }

.cdsoft-comparison-table tbody tr:nth-child(even) { background: #f8f9fa; }
.cdsoft-comparison-table tbody tr:hover { background: #e8f8fc; }

.cdsoft-cart-row td { background: #f0fdf4; }

/* Data Table design — reuses Bootstrap 4 table classes from PS8 */
.cdsoft-data-table-wrap { overflow-x: auto; }

.cdsoft-data-table td:first-child { text-align: left; }

/* ---- Quick View modal ---- */
.cdsoft-quick-modal {
    position: fixed;
    inset: 0; /* modern; falls back on next 4 lines for older browsers */
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 1060; /* above .cdsoft-compare-bar */
    background: rgba(0, 0, 0, .5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cdsoft-quick-modal-inner {
    background: #fff;
    border-radius: .375rem;
    padding: 24px;
    max-width: 480px;
    width: 90%;
    position: relative;
    box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
    animation: cdsoftFadeIn .2s ease;
}

@keyframes cdsoftFadeIn {
    from { opacity: 0; transform: scale(.97); }
    to   { opacity: 1; transform: scale(1);   }
}

.cdsoft-quick-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.375rem;
    line-height: 1;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
}
.cdsoft-quick-close:hover { color: #212529; }

/* ---- Admin BO toggle (PS 8 material-style) ---- */
/* PS8 BO ships its own .ps-toggle; this is a lightweight fallback in case
   the page context does not load it for the module configure template. */
.ps-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.ps-toggle__checkbox { display: none; }
.ps-toggle__label {
    display: inline-flex;
    cursor: pointer;
    user-select: none;
}
.ps-toggle__on  { display: none; }
.ps-toggle__off { display: flex; align-items: center; gap: 4px; color: #6c757d; }
.ps-toggle__checkbox:checked ~ .ps-toggle__label .ps-toggle__on  { display: flex; align-items: center; gap: 4px; color: #28a745; }
.ps-toggle__checkbox:checked ~ .ps-toggle__label .ps-toggle__off { display: none; }

/* ---- Responsive ---- */
@media (max-width: 767.98px) {
    .cdsoft-comparison-table { font-size: .8125rem; }
    .cdsoft-comparison-table th,
    .cdsoft-comparison-table td { padding: 8px; }
    .cdsoft-product-img { width: 70px; height: 70px; }
    .cdsoft-compare-bar-inner { flex-direction: column; align-items: flex-start; }
    .cdsoft-compare-bar-actions { width: 100%; justify-content: flex-end; }
    .cdsoft-label-col { width: 100px; min-width: 80px; }
}
