/**
 * @file finalAssemblyModal.css
 * @description Styles for the Final Assembly Modal - Professional two-stage checkout
 */

/* Final Assembly Modal Base Styles */
.final-assembly-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 1200px;
    height: 80vh;
    max-height: 80vh; /* FORCE height constraint */
    min-height: 700px;
    background: rgba(249, 250, 251, 0.95);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent outer scrollbar, inner content will handle scrolling */
}

.final-assembly-modal .modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex: 0 0 auto; /* Don't grow; keeps header fixed at top when inner content scrolls */
}

.aoi-summary-section {
    margin-bottom: 24px;
    flex: 0 0 auto; /* Don't grow or shrink, fixed size */
}

/* Stage 1: Two-Column Layout */
.final-assembly-modal.stage-1 .two-column-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 40px;
    flex: 1; /* Make this container take up the remaining vertical space */
    min-height: 0; /* CRITICAL: Allows the container to shrink and the overflow to activate */
    overflow-y: auto; /* Creates the single, correct scrollbar on the right */
}

/* Left Column: Assembly Options */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Right Column: Live Order Manifest */
.right-column {
    /* position: sticky; REMOVED to allow this column to scroll with the content */
    top: 24px;
    height: fit-content;
}

.final-assembly-modal .right-pane {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px;
}

.final-assembly-modal .payment-error-message {
    min-height: 18px;
    color: #d64545;
    font-size: 14px;
}

.final-assembly-modal .pay-button {
    align-self: stretch;
}

/* Checkout Order Summary */
.order-summary-section.single-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 16px; /* Reduced padding */
    display: flex;
    flex-direction: column;
    gap: 8px; /* Reduced gap */
}

.summary-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 20px;
}

.order-summary-section.single-card h3 {
    font-size: 15px; /* Slightly smaller */
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0; /* Reduced margin */
    padding-bottom: 6px; /* Reduced padding */
    border-bottom: 1px solid #f97316;
}

.order-summary-section.single-card .section-header {
    margin-top: 12px; /* Space between sections */
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0; /* Reduced padding */
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.summary-item .label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.summary-item .value {
    font-size: 13px;
    color: #1f2937;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.delivery-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.delivery-list li {
    font-size: 13px;
    color: #6b7280;
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
}

.delivery-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #10b981;
    font-weight: 600;
}

/* Texture Source Separator */
.texture-source-separator {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 16px 0 8px 0;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 6px;
    border-left: 3px solid #f97316;
}

.aoi-summary-card {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.aoi-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.aoi-summary-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.aoi-size-badge {
    background: #D97706;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(217, 119, 6, 0.2);
}

.aoi-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    /* Allow long coordinate strings to wrap safely */
    word-break: break-word;
    overflow-wrap: anywhere;
}

.aoi-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.aoi-detail-item label {
    font-size: 12px;
    font-weight: 500;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.aoi-value {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    font-family: 'Courier New', monospace;
}

.aoi-error {
    margin: 0;
    font-size: 14px;
    color: #EF4444;
    font-style: italic;
}

.final-assembly-modal .modal-title h2 {
    margin: 0 0 4px 0;
    font-size: 24px;
    font-weight: 600;
    color: #111827;
}

.final-assembly-modal .modal-title p {
    margin: 0;
    font-size: 14px;
    color: #6B7280;
}

.assembly-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.option-section {
    padding: 18px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.live-order-manifest {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Total Price Display */
.total-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 20px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.price-label {
    font-size: 18px;
    font-weight: 500;
    color: #374151;
}

.price-amount {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
}

/* Manifest Breakdown */
.manifest-breakdown {
    margin-bottom: 24px;
}

.manifest-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    gap: 12px;
}

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

.item-name {
    font-size: 14px;
    color: #374151;
    /* Prevent flex child from forcing overflow */
    min-width: 0;
    overflow-wrap: anywhere;
}

.item-price {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    /* Prevent flex child from forcing overflow */
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Proceed Button */
.proceed-btn {
    width: 100%;
    padding: 16px 24px;
    background: #D97706;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.3);
}

.proceed-btn:hover {
    background: #B45309;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
}

/* New Stage 2 Layout: Two Panes */
.final-assembly-modal.stage-2.new-layout {
    display: grid;
    grid-template-columns: 3fr 2fr; /* 60/40 split */
    padding: 0; /* Remove main padding, panes will handle it */
}

.left-pane {
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* This pane will scroll */
    padding: 24px;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

 .summary-content-wrapper {
    padding-top: 24px;
 }

/* Deprecate old grid system for Stage 2 */
.final-assembly-modal.stage-2 .checkout-grid-stage2 {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 40px;
    padding-top: 24px;
    height: 100%;
    overflow: hidden;
}

.final-assembly-modal.stage-2 .summary-column-stage2 {
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    padding-right: 16px;
}

.final-assembly-modal.stage-2 .payment-column-stage2 {
    position: sticky;
    top: 24px; /* Stick to the top, with some padding */
}

.iframe-loader {
    position: absolute;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #f97316; /* TerraTopic Orange */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    transition: opacity 0.3s ease;
    display: none; /* Hidden by default */
}

/*
    The original single-column layout styles for Stage 2 (.checkout-content, .payment-method, .final-summary, .final-commitment) have been removed as they are now obsolete.
    The new two-column layout is defined by .checkout-grid-stage2.
*/

.pay-and-build-btn {
    padding: 20px 40px;
    background: #059669;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.3);
    min-width: 300px;
}

.pay-and-build-btn:hover {
    background: #047857;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.4);
}

/* Back Button Styling */
.final-assembly-modal .back-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #374151;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.final-assembly-modal .back-btn:hover {
    background: white;
    border-color: rgba(0, 0, 0, 0.1);
    color: #111827;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .final-assembly-modal.stage-1 .two-column-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .right-column {
        position: static;
    }
}

/* Configuration Control Styles */
.option-section h4 {
    margin: 0 0 6px 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.option-section p {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #6B7280;
    line-height: 1.4;
}

.format-option,
.resolution-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    /* Allow text within to shrink/wrap instead of overflowing */
    min-width: 0;
}

.format-option:hover,
.resolution-option:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.format-option input[type="radio"],
.resolution-option input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #D97706;
}

.format-option span,
.resolution-option span {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.format-option small,
.resolution-option small {
    font-size: 11px;
    color: #6B7280;
    font-style: italic;
    line-height: 1.3;
    /* Ensure helper text wraps on small widths */
    min-width: 0;
    overflow-wrap: anywhere;
}

.format-option:has(input:checked),
.resolution-option:has(input:checked) {
    background: rgba(217, 119, 6, 0.1);
    border-color: #D97706;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.15);
}

/* Resolution warning tooltip */
.warning-tooltip {
    font-size: 12px;
    margin-left: 4px;
    cursor: help;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.warning-tooltip:hover {
    opacity: 1;
}

/* Format Info (for single-format modals) */
.format-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(217, 119, 6, 0.1);
    border: 1px solid #D97706;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.15);
    /* Prevent badge + text from overflowing container */
    min-width: 0;
}

.format-badge {
    background: #D97706;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(217, 119, 6, 0.2);
}

.format-info small {
    font-size: 11px;
    color: #6B7280;
    font-style: italic;
    flex: 1;
    line-height: 1.3;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Animation Classes for Stage Transitions */
.stage-transition-enter {
    opacity: 0;
    transform: translateX(20px);
}

.stage-transition-enter-active {
    opacity: 1;
    transform: translateX(0);
    transition: all 0.3s ease;
}

.stage-transition-exit {
    opacity: 1;
    transform: translateX(0);
}

.stage-transition-exit-active {
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.3s ease;
}
