/**
 * Product Features Widget Frontend Styles
 * Version: 1.0.0
 */

/* CSS Custom Properties for theming */
.elementor-widget-product-features-widget {
    --pfw-bg: #f7f9fc;
    --pfw-card-bg: #ffffff;
    --pfw-text: #0f172a;
    --pfw-muted: #475569;
    --pfw-accent: #10b981;
    --pfw-accent-contrast: #064e3b;
    --pfw-ring: 0 6px 24px rgba(16, 185, 129, 0.18);
    --pfw-shadow: 0 10px 30px rgba(2, 8, 23, 0.07);
    --pfw-transition: all 0.15s ease;
    --pfw-border-radius: 20px;
    --pfw-content-gap: clamp(16px, 2.5vw, 28px);
}

/* Screen reader only utility */
.pfw-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Main container */
.pfw-features-container {
    margin: 0 auto;
    display: grid;
    gap: clamp(20px, 3vw, 32px);
    width: 100%;
}

/* Feature item */
.pfw-feature {
    display: grid;
    grid-template-columns: minmax(260px, 1.05fr) minmax(280px, 1fr);
    gap: var(--pfw-content-gap);
    background: var(--pfw-card-bg);
    border-radius: var(--pfw-border-radius);
    box-shadow: var(--pfw-shadow);
    overflow: hidden;
    position: relative;
    transition: var(--pfw-transition);
}

.pfw-feature:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(2, 8, 23, 0.12);
}

/* Image column */
.pfw-feature__image {
    position: relative;
    min-height: 300px;
    overflow: hidden;
}

.pfw-feature__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: var(--pfw-transition);
}

.pfw-feature:hover .pfw-feature__image img {
    transform: scale(1.02);
}

/* Content column */
.pfw-feature__content {
    padding: clamp(20px, 3vw, 36px);
    align-self: center;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Eyebrow text */
.pfw-eyebrow {
    color: var(--pfw-accent-contrast);
    background: color-mix(in oklab, var(--pfw-accent) 12%, transparent);
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 10px 0;
    width: fit-content;
}

/* Feature title */
.pfw-feature__title {
    margin: 10px 0 8px 0;
    font-size: clamp(1.4rem, 1.2rem + 1.2vw, 2rem);
    line-height: 1.4;
    color: var(--pfw-text);
    font-weight: 700;
}

/* Feature description */
.pfw-feature__text {
    color: var(--pfw-muted);
    margin: 0 0 18px 0;
    line-height: 1.9;
}

/* Actions container */
.pfw-feature__actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
    flex-wrap: wrap;
}

/* Button styles */
.pfw-btn {
    --btn-bg: var(--pfw-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 12px;
    background: var(--btn-bg);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    box-shadow: var(--pfw-ring);
    transition: var(--pfw-transition);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
}

.pfw-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.pfw-btn:hover::before {
    left: 100%;
}

.pfw-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.25);
}

.pfw-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.pfw-btn:focus {
    outline: 2px solid var(--pfw-accent);
    outline-offset: 2px;
}

/* Reverse layout */
.pfw-feature--reverse .pfw-feature__image {
    order: 2;
}

.pfw-feature--reverse .pfw-feature__content {
    order: 1;
}

/* Decorative pattern */
.pfw-feature__content::before {
    content: "";
    position: absolute;
    top: 16px;
    right: 16px; /* Changed from left to right for better RTL support */
    width: 60px;
    height: 60px;
    opacity: 0.4;
    background-image: radial-gradient(circle at center, var(--pfw-accent-contrast) 2px, transparent 2px);
    background-size: 20px 20px;
    background-repeat: repeat;
    pointer-events: none;
}

/* RTL Support */
[dir="rtl"] .pfw-feature__content::before {
    right: auto;
    left: 16px;
}

[dir="rtl"] .pfw-eyebrow {
    margin-left: 0;
    margin-right: auto;
}

/* Animation classes */
.pfw-animate {
    opacity: 0;
    transform: translateY(20px);
    animation: pfw-fade-in-up 0.6s ease forwards;
}

@keyframes pfw-fade-in-up {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation delay for multiple features */
.pfw-feature:nth-child(1) {
    animation-delay: 0ms;
}

.pfw-feature:nth-child(2) {
    animation-delay: 100ms;
}

.pfw-feature:nth-child(3) {
    animation-delay: 200ms;
}

.pfw-feature:nth-child(4) {
    animation-delay: 300ms;
}

.pfw-feature:nth-child(5) {
    animation-delay: 400ms;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .pfw-feature {
        grid-template-columns: minmax(220px, 1fr) minmax(240px, 1fr);
        gap: clamp(14px, 2vw, 24px);
    }

    .pfw-feature__content {
        padding: clamp(16px, 2.5vw, 28px);
    }
}

@media (max-width: 768px) {
    .pfw-feature {
        grid-template-columns: 1fr;
        max-width: 500px;
        margin: 0 auto;
    }

    .pfw-feature__image {
        min-height: 240px;
        order: 1 !important; /* Ensure image is always first on mobile */
    }

    .pfw-feature__content {
        order: 2 !important; /* Ensure content is always second on mobile */
    }

    .pfw-feature--reverse .pfw-feature__image {
        order: 1 !important;
    }

    .pfw-feature--reverse .pfw-feature__content {
        order: 2 !important;
    }
}

@media (max-width: 480px) {
    .pfw-features-container {
        gap: clamp(16px, 4vw, 24px);
    }

    .pfw-feature {
        border-radius: 16px;
    }

    .pfw-feature__content {
        padding: clamp(16px, 4vw, 24px);
    }

    .pfw-feature__title {
        font-size: clamp(1.2rem, 4vw, 1.6rem);
    }

    .pfw-btn {
        padding: 10px 16px;
        font-size: 0.9rem;
        width: 100%;
        justify-content: center;
    }

    .pfw-feature__actions {
        flex-direction: column;
    }
}

/* High contrast mode support */
@media (forced-colors: active) {
    .pfw-feature {
        border: 2px solid CanvasText;
        box-shadow: none !important;
    }

    .pfw-eyebrow {
        border: 1px solid CanvasText;
        background: transparent !important;
        color: CanvasText !important;
    }

    .pfw-btn {
        border: 2px solid CanvasText;
        background: ButtonFace !important;
        color: ButtonText !important;
        box-shadow: none !important;
    }

    .pfw-btn:focus {
        outline: 2px solid Highlight;
        outline-offset: 2px;
        border-color: Highlight;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .pfw-animate {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .pfw-feature,
    .pfw-feature__image img,
    .pfw-btn,
    .pfw-btn::before {
        transition: none;
    }

    .pfw-feature:hover {
        transform: none;
    }

    .pfw-feature:hover .pfw-feature__image img {
        transform: none;
    }

    .pfw-btn:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .pfw-feature {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .pfw-btn {
        background: transparent !important;
        color: var(--pfw-text) !important;
        border: 1px solid var(--pfw-text) !important;
        box-shadow: none !important;
    }
}

/* Dark mode support (when parent has dark mode class) */
.elementor-widget-product-features-widget.dark-mode {
    --pfw-bg: #0f172a;
    --pfw-card-bg: #1e293b;
    --pfw-text: #f1f5f9;
    --pfw-muted: #94a3b8;
    --pfw-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Focus management for accessibility */
.pfw-feature:focus-within {
    outline: 2px solid var(--pfw-accent);
    outline-offset: 2px;
}

/* Loading state (optional) */
.pfw-features-container.loading {
    opacity: 0.7;
    pointer-events: none;
}

.pfw-features-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--pfw-accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}