/**
 * Comparison Table Frontend Styles
 * 
 * Styles for displaying comparison tables on the frontend
 * 
 * @package ReviewPro
 * @since 1.1.0
 */

/* ============================================
   Table Wrapper
   ============================================ */

.rp-comparison-table-wrapper {
    margin: 2rem 0;
    font-size: 1rem;
    line-height: 1.5;
}

.rp-table-description {
    margin: 0 0 1rem;
    color: var(--wp--preset--color--contrast-2, #666);
    font-size: 0.95em;
}

.rp-table-footer {
    margin: 1rem 0 0;
    color: var(--wp--preset--color--contrast-2, #666);
    font-size: 0.875em;
    font-style: italic;
}

/* ============================================
   Table Scroll Container
   ============================================ */

.rp-table-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================
   Base Table Styles
   ============================================ */

.rp-comparison-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 0.9375rem;
    background: var(--wp--preset--color--base, #fff);
}

.rp-comparison-table th,
.rp-comparison-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    vertical-align: middle;
}

.rp-comparison-table th {
    font-weight: 600;
    background: var(--wp--preset--color--base-2, #f6f7f7);
    color: var(--wp--preset--color--contrast, #1e1e1e);
    position: relative;
}

.rp-comparison-table td {
    color: var(--wp--preset--color--contrast, #1e1e1e);
}

/* First column (feature column) */
.rp-comparison-table td:first-child {
    font-weight: 500;
    background: var(--wp--preset--color--base-2, #f9f9f9);
}

/* ============================================
   Table Modifiers
   ============================================ */

/* Bordered */
.rp-table-bordered th,
.rp-table-bordered td {
    border: 1px solid var(--wp--preset--color--contrast-3, #ddd);
}

/* Striped */
.rp-table-striped tbody tr:nth-child(even) td {
    background: var(--wp--preset--color--base-2, #f9f9f9);
}

.rp-table-striped tbody tr:nth-child(even) td:first-child {
    background: var(--wp--preset--color--base-3, #f0f0f1);
}

/* Hover */
.rp-table-hover tbody tr:hover td {
    background: var(--wp--preset--color--primary, #2271b1);
    background: color-mix(in srgb, var(--wp--preset--color--primary, #2271b1) 8%, transparent);
}

/* Sticky header */
.rp-table-sticky-header thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.rp-table-sticky-header th {
    box-shadow: 0 1px 0 var(--wp--preset--color--contrast-3, #ddd);
}

/* ============================================
   Layout Variants
   ============================================ */

/* Compact */
.rp-table-layout-compact th,
.rp-table-layout-compact td {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

/* Spacious */
.rp-table-layout-spacious th,
.rp-table-layout-spacious td {
    padding: 1.25rem 1.5rem;
}

/* ============================================
   Style Variants
   ============================================ */

/* Modern style */
.rp-table-style-modern {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.rp-table-style-modern th {
    background: var(--wp--preset--color--primary, #2271b1);
    color: #fff;
}

.rp-table-style-modern th .rp-highlight-badge {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Minimal style */
.rp-table-style-minimal {
    border: none;
}

.rp-table-style-minimal th,
.rp-table-style-minimal td {
    border: none;
    border-bottom: 1px solid var(--wp--preset--color--contrast-3, #eee);
}

.rp-table-style-minimal th {
    background: transparent;
    border-bottom-width: 2px;
}

.rp-table-style-minimal td:first-child {
    background: transparent;
}

/* Dark style */
.rp-table-style-dark {
    background: #1e1e1e;
}

.rp-table-style-dark th {
    background: #0d0d0d;
    color: #fff;
}

.rp-table-style-dark td {
    color: #e0e0e0;
    border-color: #333;
}

.rp-table-style-dark td:first-child {
    background: #252525;
}

.rp-table-style-dark.rp-table-striped tbody tr:nth-child(even) td {
    background: #252525;
}

.rp-table-style-dark.rp-table-striped tbody tr:nth-child(even) td:first-child {
    background: #2a2a2a;
}

.rp-table-style-dark .rp-yes { color: #4ade80; }
.rp-table-style-dark .rp-no { color: #f87171; }
.rp-table-style-dark .rp-na { color: #6b7280; }

/* ============================================
   Highlighted Column
   ============================================ */

.rp-col-highlighted {
    background: color-mix(in srgb, var(--wp--preset--color--primary, #2271b1) 8%, transparent) !important;
    position: relative;
}

.rp-comparison-table th.rp-col-highlighted {
    background: var(--wp--preset--color--primary, #2271b1) !important;
    color: #fff;
}

.rp-highlight-badge {
    display: inline-block;
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--wp--preset--color--secondary, #00a32a);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.2em 0.6em;
    border-radius: 0 0 4px 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* ============================================
   Cell Types
   ============================================ */

/* Yes/No indicators */
.rp-yes {
    color: var(--wp--preset--color--success, #00a32a);
    font-size: 1.25em;
    font-weight: 700;
}

.rp-no {
    color: var(--wp--preset--color--error, #d63638);
    font-size: 1.25em;
    font-weight: 700;
}

.rp-partial {
    color: var(--wp--preset--color--warning, #dba617);
    font-size: 1.25em;
    font-weight: 700;
}

.rp-na {
    color: var(--wp--preset--color--contrast-3, #999);
}

/* Star rating */
.rp-star-rating {
    color: #f0b849;
    font-size: 1em;
    letter-spacing: 1px;
    white-space: nowrap;
}

.rp-star-rating .rp-star-full {
    color: #f0b849;
}

.rp-star-rating .rp-star-half {
    color: #f0b849;
    position: relative;
}

.rp-star-rating .rp-star-empty {
    color: #ddd;
}

/* Price */
.rp-price {
    font-weight: 600;
    color: var(--wp--preset--color--primary, #2271b1);
}

/* Number */
.rp-number {
    font-variant-numeric: tabular-nums;
}

/* Image */
.rp-cell-image {
    max-width: 60px;
    max-height: 60px;
    border-radius: 4px;
    object-fit: cover;
    vertical-align: middle;
}

/* Link/Button */
.rp-table-button {
    display: inline-block;
    padding: 0.5em 1em;
    background: var(--wp--preset--color--primary, #2271b1);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 4px;
    font-size: 0.875em;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.rp-table-button:hover {
    background: var(--wp--preset--color--primary-dark, #135e96);
    transform: translateY(-1px);
}

/* ============================================
   Responsive Design
   ============================================ */

.rp-table-responsive {
    /* Enable responsive mode */
}

@media screen and (max-width: 768px) {
    .rp-table-responsive {
        display: block;
    }

    .rp-table-responsive thead {
        display: none;
    }

    .rp-table-responsive tbody {
        display: block;
    }

    .rp-table-responsive tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--wp--preset--color--contrast-3, #ddd);
        border-radius: 8px;
        overflow: hidden;
    }

    .rp-table-responsive td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        border: none;
        border-bottom: 1px solid var(--wp--preset--color--contrast-3, #eee);
    }

    .rp-table-responsive td:last-child {
        border-bottom: none;
    }

    .rp-table-responsive td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--wp--preset--color--contrast, #1e1e1e);
        flex-shrink: 0;
        margin-right: 1rem;
    }

    .rp-table-responsive td:first-child {
        background: var(--wp--preset--color--base-2, #f6f7f7);
        font-weight: 600;
        font-size: 1.1em;
        justify-content: center;
    }

    .rp-table-responsive td:first-child::before {
        display: none;
    }

    .rp-table-responsive .rp-col-highlighted {
        background: color-mix(in srgb, var(--wp--preset--color--primary, #2271b1) 12%, transparent) !important;
    }

    .rp-table-responsive .rp-highlight-badge {
        position: static;
        transform: none;
        margin-right: 0.5em;
    }

    /* Hide first column's content as it's shown in each card's header */
    .rp-table-responsive.rp-hide-feature-mobile td:first-child {
        display: none;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .rp-comparison-table-wrapper {
        page-break-inside: avoid;
    }

    .rp-comparison-table {
        font-size: 10pt;
    }

    .rp-table-button {
        background: none;
        color: inherit !important;
        border: 1px solid #000;
    }

    .rp-yes::after { content: ' Yes'; }
    .rp-no::after { content: ' No'; }
    .rp-partial::after { content: ' Partial'; }
}

/* ============================================
   Block Editor Preview
   ============================================ */

.rp-preview-mode .rp-comparison-table {
    pointer-events: none;
}

.rp-preview-mode .rp-table-button {
    cursor: default;
}
