/* =================================
   CASHBACK OFFERS TABLE CSS - UPDATED
   ================================= */

/* Wrapper - Remove top padding/margin */
.elementor .cashback-offers-wrapper,
.cashback-offers-wrapper {
    margin: 0 0 30px 0 !important; /* Force remove top margin */
    padding-top: 0 !important; /* Also remove any top padding */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* =================================
   FILTERS SECTION - UPDATED GRID
   ================================= */

.filter-grid-container {
    background: #f9f9f9;
    border: 1px solid #ddd;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    width: 100%;
}

.filter-grid {
    display: grid;
    gap: 12px;
    width: 100%;
}

/* Grid areas assignment */
.search-cell { grid-area: search; }
.category-cell { grid-area: category; }
.website-cell { grid-area: website; }
.cashback-type-cell { grid-area: cashback-type; }
.update-cell { grid-area: update; }
.apply-cell { grid-area: apply; }
.clear-cell { grid-area: clear; }

/* Remove any conflicting rules from theme */
.cashback-offers-wrapper .filter-grid-container {
    grid-template-columns: unset !important;
    grid-template-areas: unset !important;
}

/* Desktop layout - ALL elements in ONE row */
@media (min-width: 768px) {
    .cashback-offers-wrapper .filter-grid {
        grid-template-columns: 2fr 1fr 1fr 1fr 1fr 100px 100px !important;
        grid-template-areas: "search category website cashback-type update apply clear" !important;
        align-items: end;
        gap: 12px;
        width: 100%;
    }
    
    /* Hide labels on desktop for clean single row */
    .filter-cell h4 {
        display: none !important;
    }
    
    /* Ensure consistent styling for all form elements */
    .filter-input,
    .filter-select,
    .filter-btn,
    .last-update {
        width: 100%;
        min-width: 0;
        height: 36px !important;
        font-size: 14px !important;
        background-color: white !important;
        border: 1px solid #ddd !important;
        border-radius: 4px !important;
        padding: 6px 10px !important;
        box-sizing: border-box;
    }
    
    /* Button specific overrides */
    .filter-btn {
        background: #1F6A95 !important;
        color: white !important;
        border: none !important;
        cursor: pointer;
        font-weight: bold;
    }
    
    .filter-btn.secondary {
        background: #6b7280 !important;
    }
    
    /* Update display specific styling */
    .last-update {
        background-color: #f0f0f0 !important;
        color: #666 !important;
        display: flex;
        align-items: center;
        font-size: 12px !important;
        padding: 6px 8px !important;
    }
    
    /* Compact buttons on desktop */
    .apply-cell .filter-btn,
    .clear-cell .filter-btn {
        font-size: 13px !important;
        padding: 8px 12px !important;
        white-space: nowrap;
    }
}

/* Mobile layout - two columns */
@media (max-width: 767px) {
    .filter-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "search search"
            "category website"
            "cashback-type update"
            "apply clear";
        gap: 8px;
    }
    
    .search-cell h4 {
        margin-bottom: 4px;
    }
    
    /* Hide labels on mobile except for search */
    .filter-cell:not(.search-cell) h4 {
        display: none;
    }
}

/* Filter cell base styles */
.filter-cell {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.filter-cell h4 {
    margin-top: 0;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

/* Custom select wrapper */
.custom-select-wrapper {
    width: 100%;
}

/* All inputs, selects and buttons */
.filter-input,
.filter-select,
.filter-btn {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    height: 36px;
    box-sizing: border-box;
}

/* Filter button styling */
.filter-btn {
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    white-space: nowrap;
    border: none;
    background: #1F6A95;
    color: white;
}

.filter-btn:hover {
    background: #034063;
}

.filter-btn.primary {
    background: #1F6A95;
    color: white;
}

.filter-btn.primary:hover {
    background: #034063;
}

.filter-btn.secondary {
    background: #6b7280;
    color: white;
}

.filter-btn.secondary:hover {
    background: #4b5563;
}

/* Update display styling */
.last-update {
    font-size: 14px;
    color: #666;
    background-color: #f0f0f0;
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    height: 36px;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

/* Input focus styles */
.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: #1F6A95;
    box-shadow: 0 0 0 2px rgba(31, 106, 149, 0.1);
}

/* Placeholder styling */
.filter-input::placeholder {
    color: #6b7280;
}

/* Custom select dropdown arrow */
.custom-select-wrapper {
    position: relative;
}

.custom-select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #6b7280;
    font-size: 12px;
}

.filter-select {
    appearance: none;
    cursor: pointer;
    padding-right: 35px;
}

/* Small screen adjustments */
@media (max-width: 576px) {
    .filter-grid-container {
        padding: 10px;
        gap: 8px;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "search"
            "category"
            "website"
            "cashback-type"
            "update"
            "apply"
            "clear";
    }
    
    .filter-cell h4 {
        font-size: 12px;
        margin-bottom: 4px;
        display: block;
    }
    
    .filter-input,
    .filter-select,
    .filter-btn,
    .last-update {
        height: 34px;
        font-size: 13px;
        padding: 4px 8px;
    }
}

/* =================================
   TABLE STYLES
   ================================= */

/* Table Wrapper */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: white;
    margin-top: 20px; /* Add spacing from filters above */
}

/* Main Table */
.cashback-offers-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: white;
    margin: 0;
}

/* Table Headers */
.cashback-offers-table th {
    background: #1F6A95;
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 16px 20px;
    font-size: 14px;
    border: none;
}

.cashback-offers-table thead th:first-child {
    border-top-left-radius: 12px;
}

.cashback-offers-table thead th:last-child {
    border-top-right-radius: 12px;
}

/* Table Cells */
.cashback-offers-table td {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 14px;
    color: #374151;
}

/* Row Styling */
.cashback-offers-table tbody tr {
    background: white;
    transition: background-color 0.2s ease;
}

.cashback-offers-table tbody tr:hover {
    background: #f8fafc;
}

.cashback-offers-table tbody tr:last-child td {
    border-bottom: none;
}

/* Priority Merchants - Subtle green highlight like the better example */
.cashback-offers-table tbody tr.priority-merchant {
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%) !important;
    position: relative; /* Enable positioning for the indicator */
}

.cashback-offers-table tbody tr.priority-merchant:hover {
    background: linear-gradient(135deg, #ecfdf5 0%, #f8fafc 100%) !important;
}

/* Highest rate indicator - positioned to avoid logo overlap */
.highest-rate-indicator {
    position: absolute;
    top: 8px;
    left: 90px; /* Move right to avoid 60px logo + 12px gap + padding */
    font-size: 10px;
    color: #059669 !important;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    z-index: 10;
    pointer-events: none; /* Don't interfere with table interactions */
}

/* Merchant Info */
.merchant-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.merchant-logo {
    width: 60px;
    height: 60px;
    border-radius: 15% !important;
    object-fit: contain;
    flex-shrink: 0;
    background: #f9fafb;
    padding: 4px;
    border: 1px solid #e5e7eb;
}

.merchant-name {
    font-weight: 600;
    color: #111827;
    font-size: 15px;
}

.priority-badge {
    background: #10b981;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Category Tags */
.category-tag {
    background: #e0f2fe;
    color: #0369a1;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

/* Cashback Site Badges */
.gpt_badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.swagbucks_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2024/09/Swagbucks-Savings-Cashback-App-Website-Logo.webp');
}

.topcashback_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2025/08/Topcashback-Logo.webp');
}

.rakuten_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2024/09/Rakuten-Cashback-App-Website-Logo.webp');
}

.quidco_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2024/09/Quidco-Cashback-App-Website-Logo.webp');
}

.custard_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2025/01/Custard-Logo.webp');
}

/* Gift card platform images */
.airtime_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2024/09/Airtime-Savings-Cashback-App-Website-Logo.webp');
}

.cheddar_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2024/09/Cheddar-Cashback-App-Website-Logo.webp');
}

.everup_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2024/09/EverUp-Cashback-Website-Logo.webp');
}

.jamdoughnut_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2025/08/JamDoughtnut-Logo.webp');
}

.onsi_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2025/09/Onsi-App-Logo.webp');
}

.sprive_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2024/09/Sprive-Cashback-App-Website-Logo.webp');
}

.swipii_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2025/09/Swippi.webp');
}

.tuck_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2024/09/Tuck-Cashback-App-Website-Logo.webp');
}

.topgiftcards_image {
    background-image: url('https://scrimpr.co.uk/wp-content/uploads/2025/08/Topcashback-Logo.webp');
}

.swagbucks_image, .topcashback_image, .rakuten_image, .quidco_image, .custard_image, .airtime_image, .cheddar_image, .everup_image, .jamdoughnut_image, .onsi_image, .sprive_image, .swipii_image, .tuck_image, .topgiftcards_image {
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    width: 45px;
    height: 45px;
    display: inline-block;
    border-radius: 15%;
    background-color: #f0f0f0;
}

.swagbucks_image, .topcashback_image, .rakuten_image, .quidco_image, .custard_image, .airtime_image, .cheddar_image {
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    width: 45px;
    height: 45px;
    display: inline-block;
    border-radius: 15%;
    background-color: #f0f0f0;
}

/* Website Names */
.website-name {
    font-weight: 600;
    color: #1F6A95;
    font-size: 14px;
}

/* Cashback Display */
.cashback-display {
    text-align: center;
}

.cashback-value {
    font-weight: 700;
    font-size: 18px;
    color: #059669;
    display: block;
    line-height: 1;
}

.cashback-type {
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.no-cashback {
    color: #9ca3af;
    font-style: italic;
    font-size: 13px;
}

/* Bonus info styling for gift card offers */
.bonus-info {
    font-size: 11px;
    color: #10b981;
    font-weight: 600;
    display: block;
    margin-top: 2px;
}

/* CTA Buttons */
.cashback-cta,
.platform-cta {
    background: #1F6A95;
    color: white !important;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none !important;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-block;
    text-align: center;
    white-space: nowrap;
    margin-bottom: 4px;
    border: none;
    cursor: pointer;
}

.cashback-cta:hover,
.platform-cta:hover {
    background: #034063;
    color: white !important;
    text-decoration: none !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(31, 106, 149, 0.3);
}

/* Instructions button for gift card setup */
.instructions-btn {
    background: #6b7280;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    margin-top: 4px;
}

.instructions-btn:hover {
    background: #4b5563;
}

/* Modal action buttons */
.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e5e7eb;
}

.modal-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none !important;
    text-align: center;
    display: inline-block;
}

.modal-btn.primary {
    background: #1F6A95;
    color: white !important;
}

.modal-btn.primary:hover {
    background: #034063;
    color: white !important;
    text-decoration: none !important;
}

.modal-btn.secondary {
    background: #6b7280;
    color: white !important;
}

.modal-btn.secondary:hover {
    background: #4b5563;
    color: white !important;
}

.modal-btn.copied {
    background: #10b981 !important;
    color: white !important;
}

.modal-btn.error {
    background: #ef4444 !important;
    color: white !important;
}

.no-link {
    color: #9ca3af;
    font-style: italic;
    font-size: 13px;
}

/* Instructions Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background-color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Mobile adjustments */
@media screen and (max-width: 768px) {
    .modal-content {
        width: 90%;
        max-height: 85vh;
        top: 45%; /* Slightly higher on mobile for better UX */
    }
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
}

.close:hover {
    color: #000;
}

.instructions-content h3 {
    color: #1F6A95;
    margin-bottom: 15px;
}

.instructions-content ol {
    margin: 15px 0;
    padding-left: 20px;
}

.instructions-content li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.instructions-bonus {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 12px;
    margin-top: 15px;
    color: #059669;
    font-weight: 600;
}

/* No Results */
.no-results {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 40px 20px;
}

/* Pagination */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    padding: 15px 0;
    border-top: 1px solid #e5e7eb;
}

.pagination-info {
    color: #6b7280;
    font-size: 14px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
}

.pagination-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    text-decoration: none;
    color: #111827;
}

.pagination-btn.active {
    background: #1F6A95;
    color: white;
    border-color: #1F6A95;
}

.pagination-dots {
    color: #9ca3af;
    padding: 0 4px;
}

/* Offers Count */
.offers-count {
    margin-top: 15px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* =================================
   MOBILE RESPONSIVE STYLES
   ================================= */

@media screen and (max-width: 768px) {
    /* Table mobile view */
    .cashback-offers-table {
        font-size: 13px;
    }
    
    .cashback-offers-table th,
    .cashback-offers-table td {
        padding: 12px 16px;
    }
    
    /* Stack merchant info vertically on small screens */
    .merchant-info {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .merchant-logo {
        width: 45px;
        height: 45px;
    }
    
    /* Pagination mobile adjustments */
    .pagination-wrapper {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    /* Modal adjustments for mobile */
    .modal-content {
        width: 90%;
        margin: 10% auto;
        padding: 15px;
    }
    
    .instructions-btn {
        width: 100%;
        margin-top: 8px;
    }
}

@media screen and (max-width: 600px) {
    /* Full mobile card layout */
    .table-wrapper {
        border-radius: 0;
        box-shadow: none;
    }
    
    .cashback-offers-table,
    .cashback-offers-table thead,
    .cashback-offers-table tbody,
    .cashback-offers-table th,
    .cashback-offers-table td,
    .cashback-offers-table tr {
        display: block;
    }
    
    .cashback-offers-table thead {
        display: none;
    }
    
    .cashback-offers-table tr {
        background: white;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        margin-bottom: 16px;
        padding: 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .cashback-offers-table td {
        border: none;
        padding: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        border-bottom: 1px solid #f1f5f9;
    }
    
    .cashback-offers-table td:last-child {
        border-bottom: none;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .cashback-offers-table td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #374151;
        width: 180px;
        flex-shrink: 0;
    }
    
    /* Mobile merchant info */
    .merchant-info {
        flex-direction: row;
        justify-content: flex-end; /* Change to right alignment */
        text-align: right;
        flex: 1;
    }
    
    /* Mobile cashback display */
    .cashback-display {
        text-align: right;
    }
    
    /* Mobile CTA */
    .cashback-cta {
        padding: 8px 16px;
        font-size: 13px;
        width: 100%;
        margin-bottom: 4px;
    }
    .highest-rate-indicator {
        position: static; /* Remove absolute positioning */
        display: inline-block;
        background: #f0fdf4;
        border: 1px solid #bbf7d0;
        border-radius: 4px;
        padding: 2px 6px;
        margin-left: 8px;
        font-size: 9px;
        top: auto;
        left: auto;
        transform: none;
    }
    /* Hide labels for any cell containing a CTA button */
    .cashback-offers-table td:has(.platform-cta):before,
    .cashback-offers-table td:has(.cashback-cta):before {
        display: none;
    }
}

/* =================================
   GIFT CARD SIMPLE FILTERS LAYOUT
   ================================= */

/* Override existing grid layout for gift card simple filters */
.gift-card-wrapper .filter-grid-container .filter-grid.simple-filters {
    display: flex !important;
    grid-template-columns: none !important;
    grid-template-areas: none !important;
    gap: 12px !important;
    align-items: center !important;
}

.gift-card-wrapper .simple-filters .search-cell {
    flex: 1 !important;
    width: auto !important;
}

.gift-card-wrapper .simple-filters .reset-cell {
    flex-shrink: 0 !important;
    width: auto !important;
}

.gift-card-wrapper .simple-filters .filter-input {
    width: 100% !important;
    margin: 0 !important;
    min-width: 200px;
}

.gift-card-wrapper .simple-filters .filter-btn {
    width: auto !important;
    min-width: 80px !important;
    white-space: nowrap !important;
}

@media (max-width: 768px) {
    .gift-card-wrapper .filter-grid-container .filter-grid.simple-filters {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .gift-card-wrapper .simple-filters .reset-cell {
        margin-top: 8px;
    }
    
    .gift-card-wrapper .simple-filters .filter-btn {
        width: 100% !important;
    }
}

/* Gift card loading overlay styles - FIXED POSITIONING */
.gift-card-wrapper .table-loading-overlay {
    position: absolute;
    top: 60px; /* Position just below the table header */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 40px; /* Add some space from the top */
    z-index: 10;
    border-radius: 0 0 12px 12px; /* Only round bottom corners */
}

.gift-card-wrapper .table-wrapper {
    position: relative !important;
}

.gift-card-wrapper .loading-spinner {
    text-align: center;
    padding: 20px;
    font-size: 16px;
    color: #666;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
}

/* Modal header with platform logo */
.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-platform-logo {
    width: 45px;
    height: 45px;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    border-radius: 15%;
    background-color: #f0f0f0;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    flex: 1;
}

.savings-calculation-wrapper {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f9f0 100%);
    border: 2px solid #28a745;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.savings-calculation h4 {
    color: #155724;
    margin: 0 0 15px 0;
    font-size: 1.3em;
}

.calculation-text {
    color: #155724;
    margin: 0 0 10px 0;
    line-height: 1.5;
    font-size: 1.1em;
}

.highlight-savings {
    color: #28a745;
    font-weight: bold;
    font-size: 1.2em;
}

.bonus-text {
    font-size: 1.1em;
    color: #155724;
    font-weight: 600;
    margin: 10px 0 0 0;
}

.modal-btn {
    text-decoration: none !important;
}

.modal-btn:hover {
    text-decoration: none !important;
}

#join-platform-btn {
    text-decoration: none !important;
    display: inline-block;
}