/**
 * Frontend styles for PC Offers
 *
 * @package PC_Offers
 * @since 1.0.0
 */

/* Main wrapper */
.pco-offers-wrapper {
    margin: 2rem 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Disclosure text */
.pco-disclosure {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: #6c757d;
}

.pco-disclosure p {
    margin: 0;
    line-height: 1.5;
}

/* Table container */
.pco-offers-table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background: #fff;
}

/* Main table */
.pco-offers-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

/* Table headers */
.pco-offers-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.pco-offers-table th {
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    white-space: nowrap;
}

.pco-offers-table th:first-child {
    border-top-left-radius: 8px;
}

.pco-offers-table th:last-child {
    border-top-right-radius: 8px;
}

/* Table cells */
.pco-offers-table td {
    padding: 1rem 0.75rem;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: middle;
}

.pco-offers-table tbody tr:last-child td {
    border-bottom: none;
}

/* Offer rows */
.pco-offer-row {
    transition: background-color 0.2s ease;
}

.pco-offer-row:hover {
    background-color: #f8f9fa;
}

.pco-offer-row.is-best {
    background-color: #e8f5e8;
    border-left: 4px solid #28a745;
}

/* Sold out — overrides best-price row styling for clarity */
.pco-offer-row.is-out-of-stock {
    background-color: #fdf2f2;
    border-left: 4px solid #dc3545;
}

.pco-offer-row.is-out-of-stock.is-best {
    background-color: #fdf2f2;
    border-left-color: #dc3545;
}

.pco-offer-row.is-out-of-stock:hover {
    background-color: #fce8e8;
}

.pco-stock--out::before {
    content: '';
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #dc3545;
    margin-right: 0.4rem;
    vertical-align: 0.08em;
    flex-shrink: 0;
}

.pco-stock--out {
    display: inline-flex;
    align-items: baseline;
    max-width: 100%;
}

/* Screen reader only (stock status prefix) */
.pco-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.pco-offer-row.is-stale {
    opacity: 0.7;
    position: relative;
}

.pco-offer-row.is-stale::after {
    content: "⚠️";
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
}

/* Vendor cell */
.pco-cell-vendor {
    font-weight: 600;
    color: #212529;
}

.pco-vendor-name {
    display: inline-block;
    margin-right: 0.5rem;
}

.pco-best-badge {
    display: inline-block;
    font-size: 1rem;
    margin-left: 0.5rem;
}

/* Price cell */
.pco-cell-price {
    font-weight: 600;
    color: #28a745;
    font-size: 1.1rem;
}

.pco-price {
    display: block;
}

/* Shipping cell */
.pco-cell-ship {
    color: #6c757d;
    font-size: 0.9rem;
}

.pco-ship {
    display: block;
}

/* Stock cell */
.pco-cell-stock {
    color: #6c757d;
    font-size: 0.9rem;
}

.pco-cell-stock.pco-cell-stock--out {
    color: #842029;
    font-weight: 600;
}

.pco-stock {
    display: block;
}

/* Action cell */
.pco-cell-action {
    text-align: center;
    white-space: nowrap;
}

/* Buttons */
.pco-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: 2px solid #007cba;
    border-radius: 6px;
    background: transparent;
    color: #007cba;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.pco-btn:hover {
    background: #007cba;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 124, 186, 0.3);
}

.pco-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Affiliate button */
.pco-btn-affiliate {
    border-color: #28a745;
    color: #28a745;
}

.pco-btn-affiliate:hover {
    background: #28a745;
    color: #fff;
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

/* Disabled button */
.pco-btn-disabled {
    border-color: #6c757d;
    color: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
    border-style: dashed;
    position: relative;
}

.pco-btn-disabled:hover {
    background: transparent;
    color: #6c757d;
    transform: none;
    box-shadow: none;
    opacity: 0.8;
}

/* Disabled button with copy functionality */
.pco-btn-disabled[data-vendor] {
    cursor: pointer;
    opacity: 0.7;
}

.pco-btn-disabled[data-vendor]:hover {
    opacity: 1;
    background: #f8f9fa;
    border-color: #007cba;
    color: #007cba;
}

/* Copy success state */
.pco-btn-copied {
    background: #28a745 !important;
    color: #fff !important;
    border-color: #28a745 !important;
    opacity: 1 !important;
}

/* Loading state */
.pco-btn-loading {
    position: relative;
    color: transparent !important;
}

.pco-btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: pco-spin 1s linear infinite;
}

@keyframes pco-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Tooltip styles */
.pco-tooltip {
    position: absolute;
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.3;
    max-width: 250px;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.pco-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: #333;
}

/* CSS tooltips removed - using JavaScript tooltips instead */

/* Table footer */
.pco-table-footer {
    margin-top: 1rem;
    text-align: center;
}

.pco-offer-count {
    color: #6c757d;
    font-size: 0.9rem;
    margin: 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .pco-offers-table {
        font-size: 0.85rem;
    }
    
    .pco-offers-table th,
    .pco-offers-table td {
        padding: 0.75rem 0.5rem;
    }
    
    .pco-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
        min-width: 100px;
    }
    
    .pco-cell-vendor {
        font-size: 0.9rem;
    }
    
    .pco-cell-price {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .pco-offers-table th,
    .pco-offers-table td {
        padding: 0.5rem 0.25rem;
    }
    
    .pco-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
        min-width: 80px;
    }
    
    .pco-best-badge {
        font-size: 0.9rem;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .pco-offers-wrapper {
        color: #e9ecef;
    }
    
    .pco-disclosure {
        background: #343a40;
        border-color: #495057;
        color: #adb5bd;
    }
    
    .pco-offers-table-container {
        background: #212529;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    }
    
    .pco-offers-table thead {
        background: #343a40;
    }
    
    .pco-offers-table th {
        color: #e9ecef;
        border-bottom-color: #495057;
    }
    
    .pco-offers-table td {
        border-bottom-color: #495057;
    }
    
    .pco-offer-row:hover {
        background-color: #343a40;
    }
    
    .pco-offer-row.is-best {
        background-color: #1e3a1e;
        border-left-color: #28a745;
    }

    .pco-offer-row.is-out-of-stock {
        background-color: #3d2424;
        border-left-color: #f87171;
    }

    .pco-offer-row.is-out-of-stock.is-best {
        background-color: #3d2424;
        border-left-color: #f87171;
    }

    .pco-offer-row.is-out-of-stock:hover {
        background-color: #4a2d2d;
    }

    .pco-stock--out::before {
        background: #f87171;
    }
    
    .pco-cell-vendor {
        color: #e9ecef;
    }
    
    .pco-cell-ship,
    .pco-cell-stock {
        color: #adb5bd;
    }

    .pco-cell-stock.pco-cell-stock--out {
        color: #fca5a5;
    }
    
    .pco-offer-count {
        color: #adb5bd;
    }
}

/* Blocksy theme compatibility */
.blocksy-compatible .pco-offers-table {
    border-radius: var(--theme-border-radius, 8px);
    box-shadow: var(--theme-box-shadow, 0 2px 10px rgba(0,0,0,0.1));
}

.blocksy-compatible .pco-btn {
    border-radius: var(--theme-button-border-radius, 6px);
    transition: var(--theme-transition, all 0.3s ease);
}

.blocksy-compatible .pco-btn:hover {
    transform: translateY(-1px);
}

/* Elementor compatibility */
.elementor-widget-shortcode .pco-offers-table {
    width: 100%;
    margin: 0;
}

.elementor-widget-shortcode .pco-offers-wrapper {
    padding: 0;
}

.elementor-widget-shortcode .pco-btn {
    min-width: auto;
}

/* Banner högst upp på alternativa produktsidor */
.pco-alt-product-banner {
    margin: 0 0 1.75rem;
    padding: 1.25rem 1.35rem;
    border: 1px solid #cfe8f7;
    border-radius: 10px;
    background: linear-gradient(165deg, #f4fbff 0%, #fff 55%);
    box-shadow: 0 2px 12px rgba(0, 124, 186, 0.08);
    clear: both;
}

.pco-alt-product-banner__badge {
    display: inline-block;
    margin: 0 0 0.5rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #0b5d89;
    background: #dbeaf7;
    border-radius: 4px;
}

.pco-alt-product-banner__title {
    margin: 0 0 0.65rem;
    font-size: 1.35rem;
    line-height: 1.25;
    font-weight: 700;
    color: #212529;
}

.pco-alt-product-banner__intro {
    font-size: 0.95rem;
    color: #495057;
    line-height: 1.55;
    margin-bottom: 0.85rem;
}

.pco-alt-product-banner__intro p {
    margin: 0 0 0.5rem;
}

.pco-alt-product-banner__intro p:last-child {
    margin-bottom: 0;
}

.pco-alt-product-banner__original {
    margin: 0 0 1rem;
    font-size: 0.95rem;
}

.pco-alt-product-banner__original a {
    font-weight: 600;
    color: #007cba;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pco-alt-product-banner__original a:hover {
    color: #005a87;
}

.pco-alt-product-banner__originals {
    margin: 0 0 1rem;
    font-size: 0.95rem;
}

.pco-alt-product-banner__originals-label {
    margin: 0 0 0.35rem;
    font-weight: 600;
    color: #495057;
}

.pco-alt-product-banner__originals-list {
    margin: 0;
    padding-left: 1.25rem;
    line-height: 1.55;
}

.pco-alt-product-banner__originals-list li {
    margin: 0.2rem 0;
}

.pco-alt-product-banner__originals-list a {
    font-weight: 600;
    color: #007cba;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pco-alt-product-banner__originals-list a:hover {
    color: #005a87;
}

.pco-alt-product-banner__price-block {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
    margin-bottom: 1.1rem;
}

.pco-alt-product-banner__price-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6c757d;
}

.pco-alt-product-banner__price-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: #198754;
    line-height: 1.2;
}

.pco-alt-product-banner__price-value .woocommerce-Price-amount {
    font-weight: 700;
}

.pco-alt-product-banner__cta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
}

.pco-alt-product-banner__cta .pco-btn-hero {
    font-size: 1.05rem;
    padding: 0.95rem 1.85rem;
    min-width: 220px;
    border-radius: 8px;
    text-align: center;
}

.pco-alt-product-banner .pco-btn-amazon {
    border-color: #ff9900;
    color: #c45500;
    background: #fff8f0;
}

.pco-alt-product-banner .pco-btn-amazon:hover {
    background: linear-gradient(180deg, #fff4e6 0%, #ffe8cc 100%);
    border-color: #e47911;
    color: #232f3e;
    box-shadow: 0 5px 14px rgba(255, 153, 0, 0.35);
}

.pco-alt-product-banner__aff-note {
    margin: 0;
    font-size: 0.82rem;
    color: #6c757d;
    line-height: 1.45;
    max-width: 36rem;
}

.pco-alt-product-banner__aff-note--solo {
    margin-top: 0.25rem;
}

@media (prefers-color-scheme: dark) {
    .pco-alt-product-banner {
        border-color: #495057;
        background: linear-gradient(165deg, #1e2933 0%, #212529 55%);
        box-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
    }

    .pco-alt-product-banner__badge {
        color: #b8dcef;
        background: #2d4a5f;
    }

    .pco-alt-product-banner__title {
        color: #f8f9fa;
    }

    .pco-alt-product-banner__intro {
        color: #ced4da;
    }

    .pco-alt-product-banner__original a {
        color: #6ec7ff;
    }

    .pco-alt-product-banner__originals-label {
        color: #ced4da;
    }

    .pco-alt-product-banner__originals-list a {
        color: #6ec7ff;
    }

    .pco-alt-product-banner__price-label {
        color: #adb5bd;
    }

    .pco-alt-product-banner__price-value {
        color: #75d193;
    }

    .pco-alt-product-banner__aff-note {
        color: #adb5bd;
    }

    .pco-alt-product-banner .pco-btn-amazon {
        background: #2d2419;
        border-color: #cc8629;
        color: #ffc876;
    }

    .pco-alt-product-banner .pco-btn-amazon:hover {
        color: #fff5e6;
    }
}

/* Alternativa produkter (Amazon m.m.) på originalprodukten */
.pco-alternatives-wrapper {
    margin: 2rem 0 0;
    padding: 0;
    clear: both;
}

.pco-alternatives-intro {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 0.75rem;
}

.pco-alternatives-intro p {
    margin: 0 0 0.5rem;
}

.pco-alternatives-heading {
    font-size: 1.25rem;
    margin: 0 0 1rem;
    font-weight: 600;
}

.pco-alternatives-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.pco-alternatives-card {
    margin: 0;
}

.pco-alternatives-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: #fff;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.pco-alternatives-card-link:hover {
    border-color: #007cba;
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.15);
    text-decoration: none;
    color: inherit;
}

.pco-alternatives-thumb {
    display: block;
    margin-bottom: 0.75rem;
    text-align: center;
}

.pco-alternatives-img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.pco-alternatives-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.pco-alternatives-title {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.35;
}

.pco-alternatives-rating {
    display: block;
    margin: 0.35rem 0 0.25rem;
    line-height: 1;
}

.pco-alternatives-rating .star-rating {
    float: none;
    margin: 0;
    display: inline-block;
    vertical-align: middle;
    font-size: 0.85rem;
}

.pco-alternatives-price {
    font-size: 1rem;
    color: #28a745;
    font-weight: 600;
}

.pco-alternatives-price del {
    font-weight: 400;
    color: #6c757d;
}

@media (prefers-color-scheme: dark) {
    .pco-alternatives-intro {
        color: #adb5bd;
    }

    .pco-alternatives-card-link {
        background: #212529;
        border-color: #495057;
        color: #e9ecef;
    }

    .pco-alternatives-card-link:hover {
        border-color: #007cba;
        color: #e9ecef;
    }

    .pco-alternatives-price del {
        color: #adb5bd;
    }
}

/* Accessibility improvements */
.pco-offers-table:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.pco-btn:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .pco-offers-table {
        border: 2px solid #000;
    }
    
    .pco-offers-table th {
        background: #000;
        color: #fff;
    }
    
    .pco-btn {
        border-width: 3px;
    }
    
    .pco-offer-row.is-best {
        border-left-width: 6px;
    }

    .pco-offer-row.is-out-of-stock {
        border-left-width: 6px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .pco-btn,
    .pco-offer-row {
        transition: none;
    }
    
    .pco-btn:hover {
        transform: none;
    }
}
