/**
 * Frontend Calculator Styles
 */

.fap-calculator-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
}

/* Form Sections */
.fap-form-section {
    margin-bottom: 30px;
}

.fap-form-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.fap-form-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.fap-form-section select,
.fap-form-section input[type="number"],
.fap-form-section input[type="text"] {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.fap-form-section select:focus,
.fap-form-section input:focus {
    outline: none;
    border-color: #007cba;
}

.fap-description {
    font-size: 13px;
    color: #666;
    margin-top: 5px;
    margin-bottom: 10px;
}

/* Radio & Checkbox Groups */
.fap-radio-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.fap-radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    transition: all 0.3s;
}

.fap-radio-label:hover {
    border-color: #007cba;
    background: #f7f7f7;
}

.fap-radio-label input[type="radio"] {
    margin-right: 8px;
}

.fap-radio-label input[type="radio"]:checked + span,
.fap-radio-label:has(input[type="radio"]:checked) {
    font-weight: 600;
}

.fap-radio-label:has(input[type="radio"]:checked) {
    border-color: #007cba;
    background: #e7f5fe;
}

/* Dimension Fields */
.fap-dimension-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .fap-dimension-group {
        grid-template-columns: 1fr;
    }
}

/* Toggle Switch */
.fap-toggle-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.fap-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.fap-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.fap-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 28px;
}

.fap-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

.fap-toggle-switch input:checked + .fap-toggle-slider {
    background-color: #007cba;
}

.fap-toggle-switch input:checked + .fap-toggle-slider:before {
    transform: translateX(22px);
}

.fap-toggle-content {
    padding-left: 65px;
}

@media (max-width: 600px) {
    .fap-toggle-content {
        padding-left: 0;
        margin-top: 15px;
    }
}

/* Warning and Info Boxes */
.fap-warning-box {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 15px;
    margin: 15px 0;
    color: #856404;
}

.fap-warning-box strong {
    display: block;
    margin-bottom: 5px;
}

.fap-info-box {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    padding: 15px;
    margin: 15px 0;
    color: #0c5460;
}

/* File Upload */
.fap-upload-section {
    margin-top: 20px;
}

.fap-upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.fap-upload-area:hover,
.fap-upload-area.fap-drag-over {
    border-color: #007cba;
    background: #f7fcff;
}

.fap-upload-placeholder .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #007cba;
}

.fap-upload-placeholder p {
    margin: 10px 0 5px;
    font-size: 16px;
    color: #333;
}

.fap-upload-info {
    font-size: 13px;
    color: #666;
}

.fap-file-list {
    margin-top: 20px;
}

.fap-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
}

.fap-file-item.fap-file-uploading {
    background: #f8f9fa;
    opacity: 0.7;
}

.fap-file-item.fap-file-success {
    background: #d4edda;
    border-color: #c3e6cb;
}

.fap-file-item.fap-file-error {
    background: #f8d7da;
    border-color: #f5c6cb;
}

.fap-file-name {
    flex: 1;
    font-size: 14px;
    color: #333;
}

.fap-file-status {
    font-weight: 600;
    font-size: 16px;
}

.fap-file-success .fap-file-status {
    color: #28a745;
}

.fap-file-error .fap-file-status {
    color: #dc3545;
}

/* Price Display */
.fap-price-section {
    background: #f8f9fa;
    border: 2px solid #007cba;
    border-radius: 8px;
    padding: 20px;
    margin: 30px 0;
}

.fap-price-breakdown {
    margin-bottom: 15px;
}

.fap-price-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #dee2e6;
}

.fap-price-item:last-child {
    border-bottom: none;
}

.fap-price-label {
    color: #555;
    font-size: 14px;
}

.fap-price-value {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.fap-total-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 2px solid #007cba;
}

.fap-total-label {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.fap-total-amount {
    font-size: 24px;
    font-weight: 700;
    color: #007cba;
}

/* Separator */
.fap-separator {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 30px 0;
}

/* Form Actions */
.fap-form-actions {
    text-align: center;
    margin-top: 30px;
}

.fap-add-to-cart-btn {
    padding: 15px 40px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
    min-width: 250px;
}

/* Product page integration */
.fap-price-notice {
    font-size: 14px;
    color: #666;
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .fap-calculator-wrapper {
        padding: 15px;
    }

    .fap-form-section h3 {
        font-size: 16px;
    }

    .fap-total-label {
        font-size: 16px;
    }

    .fap-total-amount {
        font-size: 20px;
    }

    .fap-add-to-cart-btn {
        min-width: 100%;
        padding: 12px 20px !important;
    }
}

/* Loading state */
.fap-calculating {
    opacity: 0.6;
    pointer-events: none;
}

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

.fap-toggle-content {
    animation: fadeIn 0.3s ease-in-out;
}

/* ===== V2 Layout - Two Column Grid ===== */

.fap-calculator-wrapper-v2 {
    max-width: 100%;
    width: 100%;
    margin: 40px 0;
    padding: 30px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    overflow: visible; /* Ensure sticky works */
}

.fap-calculator-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 40px;
    align-items: start;
    min-height: 100vh; /* Ensure enough height for sticky to work */
}

@media (max-width: 1024px) {
    .fap-calculator-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
}

/* Left Column - Form Options */
.fap-calculator-options {
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 800px; /* Ensure left column is tall enough for sticky to work */
}

/* Main Work Type Dropdown */
.fap-work-type-section {
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 2px solid #e0e0e0;
}

.fap-work-type-section h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 15px;
    color: #222;
}

.fap-main-select {
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 500;
    border: 2px solid #007cba;
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
}

.fap-main-select:hover {
    border-color: #005a87;
    background: #f7fcff;
}

.fap-main-select:focus {
    outline: none;
    border-color: #005a87;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

/* Conditional Sections */
.fap-panel-section,
.fap-passepartout-section,
.fap-frame-section {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid #e0e0e0;
}

/* Right Column - Summary & Preview */
.fap-calculator-summary {
    position: relative;
    align-self: start;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    z-index: 10;
    transition: all 0.3s ease;
    scroll-behavior: smooth;
}

/* When sticky is active via JavaScript */
.fap-calculator-summary.is-fixed {
    position: fixed;
    top: 30px;
    /* Width e right vengono impostati via JavaScript */
}

.admin-bar .fap-calculator-summary.is-fixed {
    top: calc(32px + 30px);
}

@media screen and (max-width: 782px) {
    .admin-bar .fap-calculator-summary.is-fixed {
        top: calc(46px + 20px);
    }
}

/* Scrollbar styling per il riepilogo */
.fap-calculator-summary::-webkit-scrollbar {
    width: 6px;
}

.fap-calculator-summary::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.fap-calculator-summary::-webkit-scrollbar-thumb {
    background: #007cba;
    border-radius: 3px;
}

.fap-calculator-summary::-webkit-scrollbar-thumb:hover {
    background: #005a87;
}

@media (max-width: 1024px) {
    .fap-calculator-summary {
        position: static !important;
        max-height: none;
    }

    .fap-calculator-summary.is-fixed {
        position: static !important;
        width: auto !important;
    }
}

/* Preview Box */
.fap-preview-box {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#fap_preview_canvas {
    width: 100%;
    text-align: center;
}

.fap-preview-placeholder {
    color: #6c757d;
    font-style: italic;
    font-size: 14px;
}

/* Price Summary Box */
.fap-price-summary-box {
    background: #fff;
    border: 2px solid #007cba;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.15);
    transition: all 0.3s ease;
}

/* Effetto visivo quando il box è fisso */
@media (min-width: 1025px) {
    .fap-calculator-summary.is-fixed .fap-price-summary-box {
        box-shadow: 0 8px 24px rgba(0, 124, 186, 0.25);
        border-color: #005a87;
    }
}

.fap-price-summary-box h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 700;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

/* Total Dimensions */
.fap-total-dimensions {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
}

.fap-dimensions-label {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.fap-dimensions-values {
    font-size: 24px;
    font-weight: 700;
    color: #007cba;
    margin-bottom: 5px;
}

.fap-dimensions-note {
    font-size: 12px;
    color: #999;
    margin: 0;
    font-style: italic;
}

.fap-price-summary-box .fap-price-breakdown {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.fap-price-summary-box .fap-total-price {
    display: block;
    text-align: center;
    padding: 20px 0 25px;
    border-top: none;
}

.fap-price-summary-box .fap-total-price span {
    font-size: 32px;
    font-weight: 700;
    color: #007cba;
}

.fap-price-summary-box .fap-add-to-cart-btn {
    width: 100%;
    padding: 16px 30px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    border-radius: 6px !important;
    background: #007cba !important;
    color: #fff !important;
    border: none !important;
    cursor: pointer;
    transition: all 0.3s;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.fap-price-summary-box .fap-add-to-cart-btn:hover {
    background: #005a87 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3);
}

.fap-price-summary-box .fap-add-to-cart-btn:active {
    transform: translateY(0);
}

/* Responsive adjustments for V2 */
@media (max-width: 768px) {
    .fap-calculator-wrapper-v2 {
        padding: 15px;
    }

    .fap-calculator-options {
        padding: 20px;
    }

    .fap-price-summary-box {
        padding: 20px;
    }

    .fap-price-summary-box .fap-total-price span {
        font-size: 26px;
    }
}

/* Additional Services Section */
.fap-service-item {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 4px;
    border-left: 3px solid #007cba;
}

.fap-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 600;
    color: #333;
}

.fap-checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.fap-checkbox-label span {
    font-size: 16px;
}

.fap-certificate-details {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.fap-certificate-details label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.fap-certificate-details textarea {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.3s;
}

.fap-certificate-details textarea:focus {
    outline: none;
    border-color: #007cba;
}

.fap-certificate-details textarea::placeholder {
    color: #999;
    font-style: italic;
}
