/* ==========================================
   Global Variables & Reset
   ========================================== */
:root {
    --fcs-primary: #00b521;
    --fcs-primary-hover: #007f16;
    --fcs-bg-muted: #f8fafc;
    --fcs-border: #c2c2c2;
    --fcs-icon-color: #1e293b;
    --fcs-text: #1e293b;
    --fcs-text-light: #64748b;
    --fcs-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.fcs-comparison-page {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--fcs-text);
    line-height: 1.5;
}

/* Compare Buttons (Frontend) */
.fcs-compare-btn {
    border: 1px solid var(--fcs-border);
    background: #fff;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    color: var(--fcs-icon-color);
}

.fcs-compare-btn:hover {
    background: var(--fcs-bg-muted);
    border-color: var(--fcs-primary);
    color: var(--fcs-primary);
    transform: translateY(-2px);
    box-shadow: var(--fcs-shadow);
}

.fcs-compare-btn.active {
    background: var(--fcs-primary);
    color: #fff;
    border-color: var(--fcs-primary);
}

.fcs-compare-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
}

/* Header Count Badge */
.fcs-header-comparison {
    position: relative;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: #fff !important;
}

.fcs-header-comparison .fcs-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4d4d;
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* ==========================================
   Sidebar Prompt Styles
   ========================================== */
.fcs-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 340px;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
}

.fcs-sidebar.fcs-active {
    transform: translateX(0);
    visibility: visible;
}

.fcs-sidebar.fcs-shake {
    animation: fcs-sidebar-shake 0.2s ease-in-out 0s 2;
}

@keyframes fcs-sidebar-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.fcs-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.fcs-sidebar-overlay.fcs-active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Header */
.fcs-sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--fcs-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fcs-sidebar-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.fcs-sidebar-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    color: var(--fcs-text-light);
}

/* Sidebar Body & Product Items */
.fcs-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.fcs-sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--fcs-border);
    position: relative;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.fcs-sidebar-item:hover {
    background: var(--fcs-bg-muted);
}

.fcs-sidebar-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--fcs-border);
}

.fcs-sidebar-item-info {
    flex: 1;
}

.fcs-sidebar-item-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--fcs-text);
    display: block;
    text-decoration: none;
}

.fcs-sidebar-item-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.fcs-sidebar-item:hover .fcs-sidebar-item-remove {
    opacity: 1;
}

/* Sidebar Footer */
.fcs-sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--fcs-border);
    background: var(--fcs-bg-muted);
}

.fcs-sidebar-msg {
    font-size: 12px;
    color: var(--fcs-text-light);
    margin-bottom: 12px;
    min-height: 18px;
    text-align: center;
}

.fcs-sidebar-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.fcs-sidebar-empty {
    text-align: center;
    color: var(--fcs-text-light);
    margin-top: 50px;
}

/* ==========================================
   CSS Flex/Grid Responsive Matrix Page
   ========================================== */
.fcs-comparison-matrix-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 40px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.fcs-comparison-matrix {
    display: grid;
    /* Set fixed width for label column and flexible width for product columns */
    grid-template-columns: 180px repeat(var(--product-count, 4), minmax(200px, 1fr));
    grid-template-rows: repeat(calc(var(--row-count, 10) + 1), auto);
    /* Ensure matrix does not exceed container width */
    min-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.fcs-comparison-labels-column,
.fcs-comparison-product-column {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: 1 / span calc(var(--row-count, 10) + 1);
    min-width: 180px;
    /* Ensure it participates correctly in grid subgrid */
}

.fcs-comparison-labels-column {
    position: sticky;
    left: 0;
    top: 0; /* Ensure it stays on top when scrolling vertically */
    z-index: 30; /* Higher than other cells */
    background: #ffffff;
    min-width: 180px;
}

.fcs-matrix-cell {
    padding: 12px 20px;
    font-size: 14px;
    background: #ffffff;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
    transition: background-color 0.2s ease;
}

.fcs-matrix-header-cell, .fcs-matrix-value-cell {
    scroll-snap-align: start;
}

.fcs-matrix-corner-cell {
    position: sticky;
    top: 0;
    z-index: 25;
    background: #f8fafc;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.fcs-matrix-header-cell {
    position: sticky;
    top: 0;
    z-index: 15;
    background: #f8fafc;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.fcs-matrix-label-cell {
    background: #ffffff;
    font-weight: bold;
    color: var(--fcs-text-light);
}

.fcs-matrix-value-cell {
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Identical & Differences Styling */
.fcs-row-identical {
    background: #fcfcfc !important;
    color: var(--fcs-text-light) !important;
    font-style: italic;
}

.fcs-matrix-label-cell.fcs-row-identical.unchecked::after {
    display: none;
}

.fcs-matrix-label-cell.fcs-row-identical.checked::after {
    content: "SAME";
    font-size: 8px;
    background: #e2e8f0;
    color: #475569;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 8px;
    font-style: normal;
    font-weight: 700;
    display: inline-block;
    vertical-align: middle;
}

/* Portrait Image Switcher inside Header Cell */
.fcs-product-image {
    width: 140px;
    aspect-ratio: 2/3;
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    background-color: #f8fafc;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.fcs-product-image a {
    display: block;
    width: 100%;
    height: 100%;
}

.fcs-main-image-display {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: opacity 0.2s ease-in-out;
}

/* Alternate Switcher gallery thumbnails */
.fcs-thumb-selector {
    display: flex;
    justify-content: center;
}

.fcs-thumb-item {
    width: 32px;
    height: 32px;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: all 0.2s ease;
}

.fcs-thumb-item:hover, .fcs-thumb-item.active {
    border-color: #094F3A;
    transform: scale(1.05);
}

/* Empty Page msg */
.fcs-empty-msg {
    text-align: center;
    padding: 80px 20px;
    color: var(--fcs-text-light);
    font-size: 18px;
}

/* Responsive Swiper sticky cells labels overrides */
@media (max-width: 768px) {
    .fcs-comparison-matrix {
        grid-template-columns: repeat(var(--product-count, 4), minmax(200px, 1fr));
    }
    .fcs-comparison-labels-column {
        display: none;
    }
    .fcs-matrix-cell {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* Responsive Sidebar */
@media (max-width: 768px) {
    .fcs-sidebar {
        width: 100%;
    }
}
