/* Global Steps Layout */
.qfp-step1-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.qfp-step1-form {
    flex: 1;
}

.qfp-step1-image-col {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.qfp-step1-image-col img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .qfp-step1-layout {
        flex-direction: column-reverse;
        /* Inputs primeiro no mobile */
    }

    .qfp-step1-image-col {
        width: 100%;
        margin-bottom: 20px;
    }
}

/* Step 2 ... (previous content starts here) */
/* Step 2 - Product Selection New Layout */

/* Categories Grid */
.qfp-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.qfp-category-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.qfp-category-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.qfp-category-icon {
    width: 60px;
    height: 60px;
    background: #f3f4f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.qfp-category-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qfp-category-name {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    line-height: good;
}

.qfp-category-count {
    font-size: 12px;
    color: #6b7280;
}

/* Products View Header */
.qfp-products-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.qfp-btn-back-cats {
    background: transparent;
    border: 1px solid #d1d5db;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #4b5563;
    transition: all 0.2s;
}

.qfp-btn-back-cats:hover {
    background: #f3f4f6;
    color: #111827;
}

#qfp-current-cat-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

/* Products List */
.qfp-products-list {
    max-height: 400px;
    overflow-y: auto;
    /* No border needed here if inside the view wrapper */
}

/* Reusing previous list styles... */
.qfp-product-item {
    display: flex;
    /* Hidden by default via JS/HTML, shown when filtered */
    align-items: center;
    gap: 16px;
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

/* ... rest of item styles ... */
.qfp-product-item:hover {
    background: #f9f9f9;
}

.qfp-product-item-image {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qfp-product-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qfp-product-placeholder {
    font-size: 30px;
}

.qfp-product-item-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qfp-product-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
}

.qfp-product-item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qfp-qty-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.qfp-qty-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
    margin-left: 4px;
}

.qfp-qty-controls {
    display: flex;
    align-items: center;
}

.qfp-qty-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    color: #334155;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    padding: 0;
    line-height: 1;
}

.qfp-qty-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.qfp-product-qty {
    width: 40px;
    text-align: center;
    border: none !important;
    background: transparent !important;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    -moz-appearance: textfield;
    padding: 0 !important;
    box-shadow: none !important;
}

.qfp-product-qty::-webkit-outer-spin-button,
.qfp-product-qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qfp-btn-add-product {
    padding: 6px 0;
    /* Adjusted padding since visual width is set */
    width: 32px;
    /* Fixed width for icon */
    background: #4A90E2;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;

    /* FIX: Hide any injected text from conflicting themes */
    font-size: 0 !important;
    position: relative;
}

.qfp-btn-add-product::after {
    content: "+";
    font-size: 20px !important;
    font-weight: bold;
    display: block;
    line-height: 1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.qfp-btn-add-product:hover {
    background: #357ABD;
}

/* Layout 2 Colunas */
.qfp-step2-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.qfp-col-main {
    flex: 2;
    /* Ocupa 2/3 */
}

.qfp-col-sidebar {
    flex: 1;
    /* Ocupa 1/3 */
    background: #e6f4ff;
    /* Azul clarinho destaque */
    border-radius: 8px;
    padding: 16px;
    min-height: 200px;
    position: sticky;
    top: 0;
    border: 1px solid #bae3ff;
    /* Borda suave opcional para reforçar */
}

@media (max-width: 768px) {
    .qfp-step2-layout {
        flex-direction: column;
    }

    .qfp-col-sidebar {
        width: 100%;
        min-height: auto;
    }
}

/* Categories Grid */
.qfp-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    /* Card menor para caber mais */
    gap: 12px;
}

/* ... previous styles ... */

/* Selected Products Fixes */
.qfp-selected-products {
    margin-top: 0 !important;
    border-top: none !important;
    padding-top: 0 !important;
}

/* ... */

/* ... rest stays similar ... */
.qfp-btn-remove {
    background: #ef4444;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

/* Fixes for Step 1 Image and Add Button */
.qfp-step1-image-col img {
    max-width: 100%;
    max-height: 350px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.qfp-product-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.qfp-btn-add-product {
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #4A90E2;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.qfp-btn-add-product:hover {
    background: #357ABD;
}

/* Force hide category count as requested */
.qfp-category-count {
    display: none !important;
}

/* Ensure add button is always visible and functional */
.qfp-product-item .qfp-btn-add-product {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    background: #4A90E2 !important;
    color: white !important;
    position: relative !important;
    pointer-events: auto !important;
    align-items: center;
    justify-content: center;
}

.qfp-btn-add-product.qfp-added-success {
    background-color: #22c55e !important;
    transform: scale(1.1);
}

.qfp-btn-add-product.qfp-added-success::after {
    content: "✓" !important;
}

/* Progress Bar Styles - Header Integration */

/* Header Cart Icon */
.qfp-header-cart {
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 5px;
    /* Separation from close button */
    color: #333;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
}

.qfp-header-cart:hover {
    background: #f3f4f6;
}

.qfp-header-cart .qfp-cart-count {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #e11d48;
    color: white;
    border-radius: 50%;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    border: 1px solid white;
}

.qfp-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    /* Reduced gap */
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.qfp-popup-title {
    margin: 0;
    font-size: 18px;
    /* Slightly smaller title */
    flex-shrink: 0;
}

.qfp-progress-container {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin: 0 40px;
    /* Space from title and close button */
    flex: 1;
    max-width: 100%;
    /* Allow full stretch */
}

/* Line thinner and positioned for smaller circles */
.qfp-progress-line-bg,
.qfp-progress-line-fill {
    position: absolute;
    top: 10px;
    left: 0;
    height: 2px;
    width: 100%;
    background: #e5e7eb;
    z-index: 1;
    transform: translateY(-50%);
    border-radius: 2px;
}

/* Dark Blue Color from Button */
.qfp-progress-line-fill {
    background: #113559;
    width: 0%;
    transition: width 0.3s ease;
}

.qfp-progress-step-item {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 60px;
    /* Smaller touch target width */
}

/* Smaller Circles */
.qfp-step-circle {
    width: 20px;
    height: 20px;
    background: #fff;
    border: 1px solid #e5e7eb;
    /* Thinner border */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #9ca3af;
    font-size: 10px;
    transition: all 0.3s;
}

/* Smaller Labels */
.qfp-step-label {
    font-size: 9px;
    color: #9ca3af;
    font-weight: 500;
    transition: all 0.3s;
    white-space: nowrap;
}

.qfp-popup-close {
    flex-shrink: 0;
    margin-left: 10px;
}

/* Active State - Dark Blue */
.qfp-progress-step-item.qfp-active .qfp-step-circle {
    border-color: #113559;
    background: #113559;
    color: white;
}

.qfp-progress-step-item.qfp-active .qfp-step-label {
    color: #113559;
    font-weight: 700;
}

/* Completed State - Dark Blue */
.qfp-progress-step-item.qfp-completed .qfp-step-circle {
    border-color: #113559;
    background: #113559;
    color: white;
}

.qfp-progress-step-item.qfp-completed .qfp-step-circle::after {
    content: "✓";
    font-size: 10px;
}

.qfp-progress-step-item.qfp-completed .qfp-step-circle {
    font-size: 0;
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    .qfp-popup-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .qfp-popup-title {
        text-align: center;
    }

    .qfp-progress-container {
        max-width: 100%;
        width: 100%;
    }

    .qfp-popup-close {
        position: absolute;
        top: 10px;
        right: 10px;
    }
}

/* Fix: Remove shadow from Step 1 Image as requested */
.qfp-step1-image-col img {
    box-shadow: none !important;
    border: none !important;
}

/* Font Family Update (Global) */
.qfp-popup,
.qfp-popup * {
    font-family: 'Poppins', sans-serif !important;
}

/* Ensure Submit Button matches Next Button exactly */
.qfp-btn-primary.qfp-btn-submit {
    background-color: #113559;
    color: white;
    border: none;
}

.qfp-btn-primary.qfp-btn-submit:hover {
    background-color: #0d2a46;
}

/* Tooltip & Info Icon Styles */
.qfp-category-card,
.qfp-product-item {
    position: relative;
    /* Anchor for absolute elements */
}

/* Trigger Container */
.qfp-tooltip-trigger {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

/* Info Icon (i) */
.qfp-info-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
    color: #666;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    font-family: serif;
    /* Classic 'i' look */
    cursor: help;
    transition: all 0.2s;
    backdrop-filter: blur(2px);
}

.qfp-category-card:hover .qfp-info-icon,
.qfp-product-item:hover .qfp-info-icon {
    background: #113559;
    color: white;
}

/* Internal Tooltip Box - HIDE COMPLETELY (Moved to body via JS) */
.qfp-tooltip-box {
    display: none !important;
}

/* Global Tooltip (Appended to Body) */
#qfp-global-tooltip {
    position: fixed;
    width: 220px;
    background: #fdfdfd;
    color: #333;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
    border: 1px solid #ccc;
    z-index: 99999999;
    pointer-events: auto;
    display: none;
}

#qfp-global-tooltip p {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: #555;
}

#qfp-global-tooltip .qfp-tooltip-btn {
    display: inline-block;
    padding: 6px 12px;
    background: #4A90E2;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

#qfp-global-tooltip .qfp-tooltip-btn:hover {
    background: #357abd;
}

/* Specific Trigger Position for Products to avoid scrollbar/overflow */
/* Specific Trigger Position for Products - Moved to Top Left over Image to avoid overlap */
.qfp-product-item .qfp-tooltip-trigger {
    top: 4px;
    left: 4px;
    right: auto;
    transform: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 20;
}

/* Ensure controls are visible */
.qfp-qty-plus {
    display: flex !important;
    visibility: visible !important;
}

/* Tooltip Button */
.qfp-tooltip-btn {
    display: inline-block;
    padding: 6px 12px;
    background: #4A90E2;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    transition: background 0.2s;
}

.qfp-tooltip-btn:hover {
    background: #357abd;
    color: white;
}

/* Mobile Adjustment: On mobile, maybe hide it or make clickable? */
@media (max-width: 768px) {
    .qfp-tooltip-box {
        right: -50px;
        /* Shift left slightly on small screens */
        width: 180px;
    }
}

/* Step 3 Layout Actions */
.qfp-step3-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* Changed from flex-end to allow margin-auto to work */
    margin-top: 30px;
    gap: 15px;
    width: 100%;
}

.qfp-step3-image-col {
    flex: 0 0 40%;
    max-width: 400px;
}

.qfp-step3-image-col img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
}

.qfp-step3-form-col {
    flex: 1;
}

.qfp-btn-skip {
    background: none;
    border: none;
    color: #666;
    text-decoration: underline;
    cursor: pointer;
    font-size: 14px;
    padding: 10px;
    margin-left: auto;
    /* Pushes this button and subsequent ones to the right */
}

.qfp-step3-actions .qfp-btn-next {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.qfp-btn-back-inline {
    background: white;
    border: 1px solid #ddd;
    color: #666;
    border-radius: 6px;
    padding: 10px 20px;
    cursor: pointer;
}

.qfp-step3-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

@media (max-width: 768px) {
    .qfp-step3-layout {
        flex-direction: column;
    }

    .qfp-step3-actions {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .qfp-btn-primary.qfp-btn-submit {
        width: 100%;
    }
}

/* Upload UI */
.qfp-upload-wrapper {
    margin-top: 5px;
}

.qfp-upload-trigger {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    background: #f9f9f9;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #666;
}

.qfp-upload-trigger:hover {
    border-color: #113559;
    background: #f0f4f8;
    color: #113559;
}

.qfp-upload-icon {
    font-size: 24px;
}

.qfp-upload-hint {
    font-size: 11px;
    color: #999;
}

.qfp-file-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.qfp-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid #eee;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.qfp-file-name {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #333;
    max-width: 250px;
}

.qfp-file-remove {
    cursor: pointer;
    color: #ff4d4f;
    font-weight: bold;
    padding: 4px;
    line-height: 1;
}

.qfp-upload-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    display: block;
}

/* --- Mobile Optimization Fixes --- */
@media (max-width: 768px) {

    /* 1. Hide Sidebar Images on Steps 1 & 3 */
    .qfp-step1-image-col,
    .qfp-step3-image-col {
        display: none !important;
    }

    /* 2. Header Layout Fixes */
    .qfp-popup-header {
        flex-direction: column !important;
        align-items: center !important;
        position: relative;
        padding-top: 10px;
        gap: 15px;
    }

    .qfp-popup-title {
        text-align: center;
        width: 100%;
        padding-right: 40px;
        /* Space for Close Button */
        padding-left: 10px;
        font-size: 18px;
        /* Ensure readable size */
    }

    .qfp-popup-close {
        position: absolute !important;
        top: 0;
        right: 0;
        margin: 0 !important;
        /* Ensure clickability */
        padding: 5px;
    }

    /* 3. Progress Bar Centering */
    .qfp-progress-container {
        margin: 0 auto !important;
        width: 100% !important;
        max-width: 320px !important;
        /* Limit width */
        padding: 0 10px;
        justify-content: space-between !important;
    }

    /* Ensure connecting line stays aligned */
    .qfp-progress-line-bg,
    .qfp-progress-line-fill {
        left: 10px;
        width: calc(100% - 20px);
    }

    /* 4. Fix Inputs Width (Full Width) */
    .qfp-step1-form,
    .qfp-field-group,
    .qfp-field-input {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 5. Fix Product List -> 2 Column Grid for Mobile */
    /* 5. Fix Product List -> 2 Column Grid for Mobile */
    /* 5. Fix Product List -> 2 Column Grid for Mobile */
    div.qfp-products-list {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        padding-bottom: 10px;
    }

    div.qfp-product-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 5px !important;
        height: 100% !important;
        padding: 10px !important;
        background: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    }

    /* Product Image (Correct Class: .qfp-product-item-image) */
    .qfp-product-item-image {
        width: 85px !important;
        height: 85px !important;
        margin: 0 auto 8px auto !important;
        overflow: hidden;
        flex-shrink: 0;
    }

    .qfp-product-item-image img {
        object-fit: contain;
        width: 100%;
        height: 100%;
    }

    .qfp-product-placeholder {
        font-size: 30px;
        line-height: 85px;
    }

    /* Info Container */
    .qfp-product-item-info {
        width: 100% !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start;
        align-items: center;
        flex-grow: 1;
    }

    div.qfp-product-item-name {
        font-size: 13px !important;
        margin-bottom: 8px !important;
        line-height: 1.3;
        font-weight: 600;
        min-height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        width: 100%;
    }

    .qfp-product-desc {
        display: none !important;
    }

    /* Actions: Qty + Button (Correct Class: .qfp-product-item-actions) */
    div.qfp-product-item-actions {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        /* Forces Vertical Stack */
        gap: 8px !important;
        margin-top: auto !important;
        align-items: center !important;
    }

    /* Quantity Wrapper */
    .qfp-qty-wrapper {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        margin: 0 !important;
    }

    .qfp-qty-label {
        display: none !important;
    }

    .qfp-qty-controls {
        display: flex !important;
        width: 100% !important;
        justify-content: center !important;
        gap: 0 !important;
    }

    .qfp-qty-btn {
        width: 32px !important;
        height: 32px !important;
        border-radius: 4px 0 0 4px;
    }

    .qfp-qty-btn.qfp-qty-plus {
        border-radius: 0 4px 4px 0;
    }

    .qfp-product-qty {
        width: 40px !important;
        height: 32px !important;
        text-align: center;
        margin: 0 !important;
    }

    /* Add Button */
    .qfp-btn-add-product {
        width: 100% !important;
        margin: 0 !important;
        justify-content: center !important;
        height: 36px !important;
        border-radius: 4px !important;
    }

    .qfp-qty-btn {
        width: 32px !important;
        height: 32px !important;
    }

    .qfp-product-qty {
        width: 40px !important;
        height: 32px !important;
    }

    /* Add Button - Stacked Below Qty */
    button.qfp-btn-add-product {
        width: 100% !important;
        margin: 0 !important;
        justify-content: center !important;
        height: 36px !important;
    }

    /* Prevent overflow on main container */
    .qfp-popup-body,
    .qfp-step-content {
        overflow-x: hidden !important;
    }

    /* 6. Remove Sticky Buttons (Static Flow) */
    .qfp-popup-footer {
        position: static !important;
        background: transparent !important;
        box-shadow: none !important;
        margin-top: 20px !important;
        padding: 0 !important;
        width: 100% !important;
    }

    /* Ensure padding at bottom of scrollable area */
    .qfp-popup-body {
        padding-bottom: 30px !important;
    }
}