/* Frontend styles for Table Custom Popup */

/* Root design variables to harmonize with product page */
.pcp-wrapper {
    --text: #3f3d3b;
    --muted: #8d8b89;
    --border: #e8e8e8;
    --surface: #fff;
    --pill: #f6f6f6;
    font-family: inherit;
    color: var(--text);
}

/* Customize button appearance matching product page design */
.pcp-wrapper .pcp-customize-button {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    text-align: center;
    font-weight: 700;
    /* Force theme‑neutral colours for the customize button. */
    background-color: #f5f5f5 !important;
    color: #2f2d2b !important;
    border: 1px solid #e8e8e8 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.03) !important;
    transition: none !important;
}
.pcp-wrapper .pcp-customize-button:hover {
    background-color: #f5f5f5 !important;
    border-color: #e8e8e8 !important;
    color: #2f2d2b !important;
}

/* Overlay */
.pcp-form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    z-index: 999999;
    overflow-y: auto;
    padding: 20px;
}

/* Modal container */
/*
 * Modal container styling. Use !important to enforce width and paddings. The
 * container maintains a generous width (up to 900px or 95% of the viewport)
 * with soft shadows and rounded corners.
 */
.pcp-form-container {
    background: var(--surface) !important;
    border-radius: 14px !important;
    border: 1px solid #e8e8e8 !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12) !important;
    /* Increase the modal width to better accommodate the extended form. */
    max-width: 1100px !important;
    width: 95% !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 32px !important;
    position: relative !important;
    color: #3f3d3b !important;
    box-sizing: border-box !important;
}

/* Close button */
/*
 * Close button styling. Use the neutral palette consistent with the rest of
 * the UI. The hover state does not change colours to avoid distracting
 * animations. Force colours with !important to override theme styles.
 */
.pcp-close {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    /* Remove background and border on the close icon. It inherits the
     * theme’s text colour and displays as plain text without a button
     * container. */
    background: transparent !important;
    border: none !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 24px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    color: #2f2d2b !important;
    box-shadow: none !important;
}
.pcp-close:hover {
    /* Keep the close icon plain on hover */
    background: transparent !important;
    border-color: transparent !important;
}

/* Card grid using CSS Grid for consistent columns */
/* Force exactly four cards per row on large screens with tighter gaps to ensure they fit comfortably within the modal */
/*
 * Use flexbox instead of CSS grid to ensure exactly four cards per row on
 * larger screens. Each card has a fixed width of 25% minus gaps. On
 * smaller screens the cards automatically wrap to two per row and then
 * full width. The !important declarations override previously defined
 * grid properties.
 */
/* Card grid: use CSS grid to enforce exactly four cards per row on desktops,
 * two on tablets and one on mobile. The !important declarations ensure
 * these values override any theme styles. */
.pcp-card-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin-bottom: 20px !important;
}
.pcp-card-grid .pcp-card {
    width: 100% !important;
    box-sizing: border-box !important;
}
@media (max-width: 1024px) {
    .pcp-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
@media (max-width: 768px) {
    /* Image grids (materials, leg models) become horizontal carousels */
    .pcp-card-grid:not(.pcp-leg-category-grid):not(.pcp-leg-subcategory-grid) {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 10px !important;
        padding-bottom: 8px !important;
        padding-right: 28px !important;
        scrollbar-width: none !important;
    }
    .pcp-card-grid:not(.pcp-leg-category-grid):not(.pcp-leg-subcategory-grid)::-webkit-scrollbar {
        display: none !important;
    }
    .pcp-card-grid:not(.pcp-leg-category-grid):not(.pcp-leg-subcategory-grid) .pcp-card {
        flex: 0 0 72% !important;
        width: 72% !important;
        min-width: 0 !important;
        scroll-snap-align: start !important;
    }

    /* Category/subcategory text buttons stay as a 2-column grid */
    .pcp-leg-category-grid,
    .pcp-leg-subcategory-grid {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        overflow-x: visible !important;
    }
}

/* Card styling */
.pcp-card-grid .pcp-card {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    padding: 10px !important;
    text-align: center !important;
    cursor: pointer !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    /* Width is set via responsive rules below to control the number of cards per row. */
    box-sizing: border-box !important;
    position: relative !important;
    box-shadow: 0 1px 4px rgba(0,0,0,.03) !important;
}

.pcp-card-grid .pcp-card:hover {
    border-color: #d7d7d7;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.pcp-card img {
    /* Constrain the height of material images so the grid remains tidy. The
     * object-fit rule ensures that the images cover the area without
     * distortion. Smaller height to accommodate more cards */
    max-width: 100% !important;
    height: 100px !important;
    object-fit: cover !important;
    border-radius: 4px !important;
    margin-bottom: 6px !important;
}

/*
 * Add breathing space around the leg category and model sections.
 * These wrappers sit between the specification fields and the following
 * sections, so a top margin separates them from the previous content.
 */
.pcp-leg-category-grid,
.pcp-leg-model-wrap {
    margin-top: 16px !important;
    margin-bottom: 16px !important;
}

/* Add spacing for the subcategory wrapper */
.pcp-leg-subcategory-wrap {
    margin-top: 16px !important;
    margin-bottom: 16px !important;
}
.pcp-card input[type="radio"] {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    pointer-events: none;
}
.pcp-card input[type="radio"]:checked + .pcp-card-title::after {
    content: '\2714';
    color: #1e87f0;
    font-size: 1.2em;
    margin-left: 4px;
}
.pcp-card-title {
    display: block;
    font-weight: 600;
    margin-top: 4px;
}

/* Selected card state */
.pcp-card.selected {
    border-color: #1e87f0;
    box-shadow: 0 0 0 2px rgba(30, 135, 240, 0.3);
}
.pcp-card.selected .pcp-card-title::after {
    content: '\2714';
    color: #1e87f0;
    font-size: 1.2em;
    margin-left: 4px;
}

/* Field rows */
/*
 * Field rows: spread inputs evenly with generous gaps. Labels use a slightly
 * larger font and ample bottom margin to separate them from the inputs.
 */
.pcp-field-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 16px !important;
    margin-bottom: 18px !important;
}
/* Each label occupies half of the available row minus the gap. */
.pcp-field-row label {
    flex: 1 1 calc(50% - 8px) !important;
    display: flex !important;
    flex-direction: column !important;
    font-size: 1rem !important;
    color: #3f3d3b !important;
    margin-bottom: 8px !important;
}

/* Special row for three inputs (e.g., Breite 1‑3). */
.pcp-row-3 {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 16px !important;
    margin-bottom: 18px !important;
}
.pcp-row-3 label {
    flex: 1 1 calc(33.333% - 10.66px) !important;
    display: flex !important;
    flex-direction: column !important;
    font-size: 1rem !important;
    color: #3f3d3b !important;
    margin-bottom: 8px !important;
}

/* Row for single input spanning full width (e.g., surface treatment). */
.pcp-row-single {
    display: flex !important;
    flex-wrap: wrap !important;
    margin-bottom: 18px !important;
}
.pcp-row-single label {
    flex: 1 1 100% !important;
    display: flex !important;
    flex-direction: column !important;
    font-size: 1rem !important;
    color: #3f3d3b !important;
    margin-bottom: 8px !important;
}

/* Inputs, textarea and select styles */
.pcp-field-row input,
.pcp-field-row textarea,
.pcp-field-row select {
    margin-top: 6px !important;
    padding: 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-size: 1rem !important;
    color: var(--text) !important;
    background: #f9f9f9 !important;
}
.pcp-field-row textarea {
    resize: vertical;
}

/* Button row */
.pcp-button-row {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}
/*
 * Button styling. The primary (submit) and cancel buttons share the same
 * neutral design as the customize button. Colours are forced with
 * !important to override any theme styles. The hover state maintains
 * identical colours for a consistent minimalist look.
 */
.pcp-button-row .pcp-submit,
.pcp-button-row .pcp-cancel {
    padding: 10px 16px !important;
    border-radius: 10px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    background: #f5f5f5 !important;
    color: #2f2d2b !important;
    border: 1px solid #e8e8e8 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,.03) !important;
    cursor: pointer !important;
    transition: none !important;
}
.pcp-button-row .pcp-submit:hover,
.pcp-button-row .pcp-cancel:hover {
    background: #f5f5f5 !important;
    border-color: #e8e8e8 !important;
}

/* Form headings */
.pcp-form-container h3 {
    margin-top: 24px !important;
    margin-bottom: 12px !important;
    font-size: 1.3rem !important;
    font-weight: 600 !important;
}
.pcp-form-container h4 {
    margin-top: 20px !important;
    margin-bottom: 10px !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
}

/* Divider */
.pcp-form-container hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 20px 0;
}

/* Extras container */
/* Extras container redesigned as buttons */
/*
 * Extras list styling. Present extras as pill-like buttons arranged in up to
 * three columns on desktop. Each option spans the full width on small
 * screens. The flex layout combined with explicit widths creates a clean
 * grid while keeping labels aligned on the left. Use !important on key
 * properties to override theme styles.
 */
.pcp-extras {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
}
.pcp-extra-option {
    position: relative;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 10px 14px !important;
    border: 1px solid #e8e8e8 !important;
    border-radius: 8px !important;
    background: #f5f5f5 !important;
    color: #2f2d2b !important;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    user-select: none !important;
    width: calc(33.333% - 6px) !important;
    box-sizing: border-box !important;
    transition: background-color 0.2s ease, border-color 0.2s ease !important;
}
/* On medium screens reduce to two columns */
@media (max-width: 768px) {
    .pcp-extra-option {
        width: calc(50% - 6px) !important;
    }
}
/* On small screens each option spans the full width */
@media (max-width: 480px) {
    .pcp-extra-option {
        width: 100% !important;
    }
}
.pcp-extra-option input[type="checkbox"] {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
.pcp-extra-option.selected {
    background: #e6f0fc !important;
    border-color: #1e87f0 !important;
    color: #1e87f0 !important;
    font-weight: 600 !important;
}

/* Product preview inside modal */

/* ===========================
   Additional Services Popup
   =========================== */
.pcp-services-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.pcp-services-modal {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: pcp-modal-in 0.3s ease;
}

@keyframes pcp-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.pcp-services-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f3f4f6;
    color: #6b7280;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.pcp-services-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.pcp-services-header {
    padding: 24px 24px 16px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

.pcp-services-header h3 {
    margin: 0 0 8px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
}

.pcp-services-header p {
    margin: 0;
    color: #6b7280;
    font-size: 0.95rem;
}

.pcp-services-content {
    padding: 16px 24px;
}

.pcp-service-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    margin-bottom: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.pcp-service-option:last-child {
    margin-bottom: 0;
}

.pcp-service-option:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.pcp-service-option.selected {
    border-color: #2563eb;
    background: #eff6ff;
}

.pcp-service-radio {
    position: relative;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.pcp-service-radio input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.pcp-radio-checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 22px;
    height: 22px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    background: #fff;
    transition: all 0.2s ease;
}

.pcp-service-option:hover .pcp-radio-checkmark {
    border-color: #9ca3af;
}

.pcp-service-option.selected .pcp-radio-checkmark {
    border-color: #2563eb;
    background: #2563eb;
}

.pcp-service-option.selected .pcp-radio-checkmark::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: #fff;
    border-radius: 50%;
}

.pcp-service-info {
    flex: 1;
    min-width: 0;
}

.pcp-service-name {
    display: block;
    font-weight: 600;
    color: #111827;
    font-size: 1rem;
    margin-bottom: 2px;
}

.pcp-service-description {
    display: block;
    color: #6b7280;
    font-size: 0.85rem;
    line-height: 1.4;
}

.pcp-service-price {
    font-weight: 700;
    font-size: 1.1rem;
    color: #059669;
    white-space: nowrap;
}

.pcp-service-price.pcp-price-free {
    color: #2563eb;
    font-weight: 600;
}

.pcp-services-footer {
    padding: 16px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid #e5e7eb;
}

.pcp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-align: center;
}

.pcp-btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.pcp-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.pcp-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.pcp-btn-secondary:hover {
    background: #e5e7eb;
    color: #111827;
}

/* Mobile adjustments for services popup */
@media (max-width: 480px) {
    .pcp-services-modal {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 85vh;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        animation: pcp-modal-slide-up 0.3s ease;
    }

    @keyframes pcp-modal-slide-up {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }

    .pcp-services-header {
        padding: 20px 20px 14px;
    }

    .pcp-services-header h3 {
        font-size: 1.3rem;
    }

    .pcp-services-content {
        padding: 14px 20px;
    }

    .pcp-service-option {
        padding: 14px;
    }

    .pcp-services-footer {
        padding: 14px 20px 20px;
    }
}

/* ===========================================
   Additional Services Checkboxes (Product Page)
   Matches warm brown / wood-inspired design
   =========================================== */
.pcp-services-checkboxes {
    margin: 16px 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.pcp-services-checkboxes .pcp-services-title {
    margin: 0 0 10px 0;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    color: #6b6966;
    letter-spacing: .02em;
}

.pcp-service-checkbox-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 6px;
    background: #faf9f7;
    border: 1px solid #ddd8d3;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.2s ease;
    position: relative;
}

.pcp-service-checkbox-option:last-child {
    margin-bottom: 0;
}

.pcp-service-checkbox-option:hover {
    border-color: #c9b49a;
}

.pcp-service-checkbox-option:has(input:checked) {
    border-color: #AD9271;
    background: #faf9f7;
}

/* Hide default checkbox */
.pcp-service-checkbox-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Custom checkbox */
.pcp-checkbox-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    background: #fff;
    border: 2px solid #ddd8d3;
    border-radius: 3px;
    transition: all 0.15s ease;
}

.pcp-checkbox-mark::after {
    content: '';
    display: none;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-top: -2px;
}

.pcp-service-checkbox-option:has(input:checked) .pcp-checkbox-mark {
    background: #AD9271;
    border-color: #AD9271;
}

.pcp-service-checkbox-option:has(input:checked) .pcp-checkbox-mark::after {
    display: block;
}

/* Service label and description */
.pcp-service-label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.pcp-service-checkbox-option .pcp-service-name {
    font-weight: 600;
    font-size: 14px;
    color: #2c2a28;
}

.pcp-service-checkbox-option .pcp-service-desc {
    font-size: 12px;
    color: #6b6966;
}

/* Service price */
.pcp-service-checkbox-option .pcp-service-price {
    font-weight: 600;
    font-size: 14px;
    color: #8a745a;
    white-space: nowrap;
}

.pcp-service-checkbox-option .pcp-service-price.pcp-price-free {
    color: #6b6966;
    font-weight: 500;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .pcp-services-checkboxes {
        margin: 12px 0;
    }

    .pcp-service-checkbox-option {
        padding: 9px 12px;
        gap: 10px;
    }
}