/**
 * Doors Finder Widget - Frontend Styles v2.0
 * Enhanced for Rav-Bariach / Doors Website
 */

:root {
    --pfw-primary: #1a365d;
    --pfw-primary-light: #2c5282;
    --pfw-secondary: #f7fafc;
    --pfw-accent: #c9a961;
    --pfw-text: #2d3748;
    --pfw-text-light: #718096;
    --pfw-border: #e2e8f0;
    --pfw-success: #38a169;
    --pfw-whatsapp: #25d366;
    --pfw-error: #e53e3e;
    --pfw-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --pfw-radius: 16px;
    --pfw-transition: 0.3s ease;
}

/* Overlay */
.pfw-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--pfw-transition), visibility var(--pfw-transition);
    backdrop-filter: blur(4px);
}

.pfw-overlay.active {
    opacity: 1;
    visibility: visible;
}

body.pfw-open {
    overflow: hidden;
}

/* Popup */
.pfw-popup {
    background: #fff;
    border-radius: var(--pfw-radius);
    box-shadow: var(--pfw-shadow);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--pfw-transition);
    direction: rtl;
}

.pfw-overlay.active .pfw-popup {
    transform: scale(1) translateY(0);
}

/* Close Button */
.pfw-close-btn {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--pfw-secondary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--pfw-transition);
    z-index: 10;
}

.pfw-close-btn:hover {
    background: #e2e8f0;
    transform: rotate(90deg);
}

.pfw-close-btn svg {
    width: 20px;
    height: 20px;
    color: var(--pfw-text);
}

/* Header */
.pfw-header {
    padding: 20px 24px 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
}

.pfw-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--pfw-primary);
    cursor: pointer;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all var(--pfw-transition);
    font-weight: 500;
}

.pfw-back-btn:hover {
    background: var(--pfw-secondary);
}

.pfw-back-btn svg {
    width: 18px;
    height: 18px;
}

.pfw-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    color: var(--pfw-text-light);
}

.pfw-breadcrumb-item:not(:last-child)::after {
    content: "←";
    margin-right: 8px;
    opacity: 0.5;
}

/* Content */
.pfw-content {
    padding: 8px 24px 24px;
    overflow-y: auto;
    flex: 1;
}

.pfw-question-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--pfw-text);
    margin: 0 0 24px;
    text-align: center;
    line-height: 1.3;
}

/* Options Grid */
.pfw-options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.pfw-option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--pfw-secondary);
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--pfw-transition);
    text-align: center;
    text-decoration: none;
    color: inherit;
    min-height: 140px;
    animation: pfw-fadeIn 0.4s ease forwards;
    opacity: 0;
}

@keyframes pfw-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.pfw-option-card:hover {
    border-color: var(--pfw-primary);
    background: #fff;
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.pfw-option-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 12px;
    color: var(--pfw-primary);
}

.pfw-option-icon svg {
    width: 100%;
    height: 100%;
}

.pfw-option-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--pfw-text);
    line-height: 1.3;
    margin-bottom: 4px;
}

.pfw-option-sublabel {
    font-size: 13px;
    color: var(--pfw-text-light);
    line-height: 1.4;
}

.pfw-option-arrow {
    margin-top: 8px;
    font-size: 18px;
    color: var(--pfw-primary);
    opacity: 0;
    transform: translateX(5px);
    transition: all var(--pfw-transition);
}

.pfw-option-card:hover .pfw-option-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ==================== */
/* Results Section      */
/* ==================== */

.pfw-results-section {
    padding-bottom: 10px;
}

/* Recommendation Card */
.pfw-recommendation-card {
    background: linear-gradient(135deg, var(--pfw-primary) 0%, var(--pfw-primary-light) 100%);
    border-radius: 16px;
    padding: 24px;
    color: #fff;
    margin-bottom: 24px;
}

.pfw-recommendation-header {
    text-align: center;
    margin-bottom: 20px;
}

.pfw-rec-badge {
    display: inline-block;
    background: var(--pfw-accent);
    color: var(--pfw-primary);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.pfw-recommendation-title {
    font-size: 20px;
    font-weight: 400;
    margin: 0;
    line-height: 1.4;
}

.pfw-recommendation-title strong {
    display: block;
    font-size: 24px;
    font-weight: 700;
    margin-top: 8px;
}

.pfw-recommendation-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.pfw-recommendation-image {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    padding: 20px;
}

.pfw-recommendation-image img {
    max-width: 100%;
    max-height: 140px;
    object-fit: contain;
}

.pfw-recommendation-placeholder {
    width: 80px;
    height: 80px;
    opacity: 0.5;
}

.pfw-recommendation-placeholder svg {
    width: 100%;
    height: 100%;
}

.pfw-recommendation-specs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
}

.pfw-spec-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(255,255,255,0.1);
    padding: 12px;
    border-radius: 8px;
}

.pfw-spec-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    opacity: 0.8;
}

.pfw-spec-icon svg {
    width: 100%;
    height: 100%;
}

.pfw-spec-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pfw-spec-label {
    font-size: 11px;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pfw-spec-value {
    font-size: 14px;
    font-weight: 600;
}

.pfw-recommendation-actions {
    text-align: center;
}

.pfw-btn-primary {
    display: inline-block;
    background: #fff;
    color: var(--pfw-primary);
    padding: 14px 32px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    transition: all var(--pfw-transition);
}

.pfw-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

/* Upsell Section */
.pfw-upsell-section {
    margin-bottom: 24px;
}

.pfw-upsell-section h3,
.pfw-products-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--pfw-text);
    margin: 0 0 16px;
}

.pfw-upsell-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.pfw-upsell-card {
    background: var(--pfw-secondary);
    border: 1px solid var(--pfw-border);
    border-radius: 10px;
    padding: 16px;
    text-decoration: none;
    color: inherit;
    transition: all var(--pfw-transition);
    text-align: center;
}

.pfw-upsell-card:hover {
    border-color: var(--pfw-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.pfw-upsell-content strong {
    display: block;
    font-size: 14px;
    color: var(--pfw-text);
    margin-bottom: 4px;
}

.pfw-upsell-content span {
    font-size: 12px;
    color: var(--pfw-text-light);
}

/* Products Grid */
.pfw-products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.pfw-product-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--pfw-secondary);
    border: 1px solid var(--pfw-border);
    border-radius: 10px;
    padding: 16px;
    text-decoration: none;
    color: inherit;
    transition: all var(--pfw-transition);
}

.pfw-product-card:hover {
    border-color: var(--pfw-primary);
    background: #fff;
}

.pfw-product-icon {
    width: 40px;
    height: 40px;
    color: var(--pfw-primary);
    flex-shrink: 0;
}

.pfw-product-icon svg {
    width: 100%;
    height: 100%;
}

.pfw-product-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--pfw-text);
}

/* ==================== */
/* CTA Footer           */
/* ==================== */

.pfw-cta-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--pfw-border);
    background: var(--pfw-secondary);
}

.pfw-whatsapp-btn {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--pfw-whatsapp);
    color: #fff;
    padding: 14px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    transition: all var(--pfw-transition);
}

.pfw-whatsapp-btn:hover {
    background: #22c55e;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
}

.pfw-whatsapp-btn svg {
    width: 22px;
    height: 22px;
}

.pfw-pdf-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
    color: var(--pfw-text);
    border: 1px solid var(--pfw-border);
    padding: 14px 16px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    transition: all var(--pfw-transition);
}

.pfw-pdf-btn:hover {
    border-color: var(--pfw-primary);
    color: var(--pfw-primary);
}

.pfw-pdf-btn svg {
    width: 20px;
    height: 20px;
}

/* Skip Section */
.pfw-skip-section {
    padding: 16px 24px;
    text-align: center;
    border-top: 1px solid var(--pfw-border);
}

.pfw-skip-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: transparent;
    border: 2px dashed var(--pfw-accent);
    border-radius: 25px;
    color: var(--pfw-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--pfw-transition);
}

.pfw-skip-btn:hover {
    background: var(--pfw-accent);
    border-style: solid;
    color: #fff;
}

/* Form Section */
.pfw-form-section {
    padding: 24px;
}

.pfw-form-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--pfw-text);
    margin: 0 0 24px;
    text-align: center;
}

.pfw-lead-form {
    max-width: 360px;
    margin: 0 auto;
}

.pfw-form-row {
    margin-bottom: 14px;
}

.pfw-form-row input,
.pfw-form-row textarea {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--pfw-border);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: all var(--pfw-transition);
    direction: rtl;
}

.pfw-form-row input:focus,
.pfw-form-row textarea:focus {
    outline: none;
    border-color: var(--pfw-primary);
    box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

.pfw-submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--pfw-primary);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--pfw-transition);
}

.pfw-submit-btn:hover:not(:disabled) {
    background: var(--pfw-primary-light);
}

.pfw-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.pfw-form-error {
    margin-top: 12px;
    padding: 12px;
    background: #fed7d7;
    border-radius: 8px;
    color: var(--pfw-error);
    font-size: 14px;
    text-align: center;
}

/* Success Section */
.pfw-success-section {
    padding: 48px 24px;
    text-align: center;
}

.pfw-success-icon {
    color: var(--pfw-success);
    margin-bottom: 20px;
}

.pfw-success-icon svg {
    width: 80px;
    height: 80px;
}

.pfw-success-message {
    font-size: 18px;
    color: var(--pfw-text);
    margin: 0 0 24px;
    line-height: 1.5;
}

.pfw-continue-btn {
    padding: 12px 32px;
    background: var(--pfw-secondary);
    border: none;
    border-radius: 8px;
    color: var(--pfw-text);
    font-size: 15px;
    cursor: pointer;
    transition: all var(--pfw-transition);
}

.pfw-continue-btn:hover {
    background: #e2e8f0;
}

/* Footer Progress */
.pfw-footer {
    padding: 12px 24px 16px;
}

.pfw-progress {
    height: 4px;
    background: var(--pfw-secondary);
    border-radius: 2px;
    overflow: hidden;
}

.pfw-progress-bar {
    height: 100%;
    background: var(--pfw-accent);
    border-radius: 2px;
    transition: width 0.5s ease;
    width: 0;
}

/* Trigger Button */
.pfw-trigger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    background: var(--pfw-primary);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--pfw-transition);
}

.pfw-trigger-btn:hover {
    background: var(--pfw-primary-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(26, 54, 93, 0.3);
}

/* ==================== */
/* Responsive           */
/* ==================== */

@media (max-width: 640px) {
    .pfw-overlay {
        padding: 0;
        align-items: flex-end;
    }
    
    .pfw-popup {
        max-height: 95vh;
        border-radius: 20px 20px 0 0;
        max-width: 100%;
    }
    
    .pfw-content {
        padding: 8px 16px 16px;
    }
    
    .pfw-question-title {
        font-size: 22px;
        margin-bottom: 20px;
    }
    
    .pfw-options-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .pfw-option-card {
        padding: 20px 12px;
        min-height: 120px;
    }
    
    .pfw-option-icon {
        width: 44px;
        height: 44px;
    }
    
    .pfw-option-label {
        font-size: 14px;
    }
    
    .pfw-option-sublabel {
        font-size: 11px;
    }
    
    /* Results responsive */
    .pfw-recommendation-body {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .pfw-recommendation-image {
        min-height: 120px;
    }
    
    .pfw-upsell-grid {
        grid-template-columns: 1fr;
    }
    
    .pfw-products-grid {
        grid-template-columns: 1fr;
    }
    
    .pfw-cta-footer {
        flex-direction: column;
        padding: 12px 16px;
    }
    
    .pfw-whatsapp-btn,
    .pfw-pdf-btn {
        width: 100%;
    }
}

/* Animation for success */
@keyframes pfw-checkmark {
    0% { stroke-dashoffset: 100; }
    100% { stroke-dashoffset: 0; }
}

.pfw-success-icon svg path,
.pfw-success-icon svg polyline {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: pfw-checkmark 0.6s ease forwards 0.2s;
}
