/* VF Calc Tab Styles */
.calc-wrapper {
    display: flex;
    flex-wrap: nowrap;
    gap: 20px;
    min-height: 600px;
    position: relative;
    z-index: 1;
    align-items: flex-start;
}

.input-panel {
    flex: 0 0 420px;
    /* Fixed width */
    width: 420px;
    min-width: 420px;
    background: #f9f9f9;
    padding: 12px;
    /* Compacted from 15px */
    border-radius: 0;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.visualization-panel {
    flex: 1 1 auto;
    width: 0;
    /* Force flex child to shrink if needed */
    min-width: 0;
    background: #f9f9f9;
    padding: 12px;
    /* Compacted from 15px */
    border-radius: 0;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 100px;
    /* Accounts for navbar */
    max-height: calc(100vh - 120px);
    height: calc(100vh - 120px);
    /* Fill available height */
    overflow-y: hidden;
    /* Force fit, no scroll bars on desktop */
    display: flex;
    flex-direction: column;
}

/* Custom scrollbar for sticky panel */
.visualization-panel::-webkit-scrollbar {
    width: 6px;
}

.visualization-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.visualization-panel::-webkit-scrollbar-thumb {
    background: #ccc;
}

.visualization-panel::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.input-panel h2,
.visualization-panel h2 {
    color: #1a1a1a;
    margin-bottom: 15px;
    font-size: 1.5em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    position: relative;
    z-index: 1;
}

.units-selector {
    margin-bottom: 15px;
    /* Compacted from 25px */
    padding: 10px;
    /* Compacted from 15px */
    background: #ffffff;
    border-radius: 0;
    border: 1px solid #e0e0e0;
    position: relative;
}

.units-selector label {
    margin-right: 15px;
    font-weight: 600;
    color: #1a1a1a;
    font-size: 1.1em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.units-selector select {
    padding: 5px 10px;
    /* Compacted */
    border: 1px solid #e0e0e0;
    border-radius: 0;
    font-size: 1em;
    cursor: pointer;
    background: #ffffff;
    color: #333333;

    font-weight: 500;
    transition: all 0.3s;
}

.units-selector select:hover {
    border-color: #cccccc;
}

.units-selector select:focus {
    outline: none;
    border-color: #1a1a1a;
}

.opening-item {
    background: #ffffff;
    padding: 8px;
    /* Compacted from 10px */
    margin-bottom: 8px;
    /* Compacted from 10px */
    border-radius: 0;
    border: 1px solid #e0e0e0;
    border-left: 3px solid #1a1a1a;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.opening-item:hover {
    border-color: #cccccc;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateX(3px);
}

.opening-item h3 {

    color: #1a1a1a;
    margin-bottom: 15px;
    font-size: 1.3em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.opening-item .remove-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #666666;
    color: white;
    border: 1px solid #666666;
    padding: 6px 14px;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s;
}

.opening-item .remove-btn:hover {
    background: #1a1a1a;
    border-color: #1a1a1a;
}

.opening-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.opening-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.category-section {
    margin-bottom: 20px;
}

/* Form Styles for Inputs */
.form-group {
    margin-bottom: 8px;
}

.form-group label {
    display: block;
    margin-bottom: 3px;
    font-size: 0.8em;
    font-weight: 600;
    color: #555;
}

.opening-input {
    width: 100%;
    padding: 4px 6px;
    /* Compact padding */
    border: 1px solid #ccc;
    border-radius: 0;
    box-sizing: border-box;
    font-size: 0.9em;
    background: #fcfcfc;
    transition: border 0.3s;
}

.opening-input:focus {
    border-color: #1a1a1a;
    background: #fff;
    outline: none;
}

.btn-calculate,
.btn-log,
.btn-reset {
    flex: 1;
    padding: 10px 5px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 0;
    font-size: 0.75em;
    letter-spacing: 0.5px;
    border: none;
}

.btn-calculate {
    background: #1a1a1a;
    color: white;
}

.btn-log {
    background: #0099cc;
    color: white;
}

.btn-reset {
    background: #ff4444;
    color: white;
}

.btn-calculate:hover {
    background: #333;
}

.btn-log:hover {
    background: #007ead;
}

.btn-reset:hover {
    background: #e0e0e0;
    color: #333;
}

/* VF Intro Section */
.vf-intro-section {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.vf-intro-section>h2 {

    color: #1a1a1a;
    font-size: 2.2em;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-align: center;
}

.visualisation-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.canvas-section {
    margin-bottom: 10px;
    /* Shrunken from 25px */
    min-width: 0;
    /* Prevent overflow in grid */
}

.canvas-section:last-child {
    margin-bottom: 0;
}

/* Ensure the 3D section (direct child of panel) grows */
.visualization-panel>.canvas-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 300px;
    /* Minimum guaranteed height */
}

.canvas-section h3 {
    color: #1a1a1a;
    margin-bottom: 2px;
    /* Minimized margin */
    font-size: 1.0em;
    /* Slightly smaller header */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.canvas-container {
    display: block;
    background: #ffffff;
    border-radius: 0;
    border: 1px solid #e0e0e0;
    padding: 8px;
    min-height: 0;
    /* Removed default valid min-height to allow flexibility */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
}

#canvas-2d,
#canvas-3d,
#canvas-2d-plan {
    width: 100%;
    height: 100%;
    /* Ensure canvas fills container */
    border-radius: 0;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    position: relative;
    z-index: 1;
    display: block;
}

/* Square containers for 2D views - Modified to Fixed Relative Height */
#canvas-2d-container,
#canvas-2d-plan-container {
    /* aspect-ratio: 1 / 1; REMOVED to allow fitting */
    height: 28vh;
    /* Fixed height reduced to allow more space for 3D */
    width: 100%;
    /* responsive sizing to fit screen height */
    max-width: none;
    /* Remove max-width constraint to stretch */
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* 3D view container */
#canvas-3d-container {
    height: auto;
    flex: 1;
    /* Grow to fill parent */
    min-height: 25vh;
    /* Safety minimum */
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: none;
    background: transparent;
    box-shadow: none;
    display: block;
}

#canvas-3d {
    width: 100% !important;
    height: 100% !important;
    display: block;
}



/* Responsive adjustment for the row */
@media (max-width: 1300px) {
    .visualisation-row {
        grid-template-columns: 1fr;
        /* Stack vertically on narrower screens */
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .calc-wrapper {
        flex-direction: column;
    }

    .input-panel {
        width: 100%;
        min-width: 100%;
        flex: none;
    }

    .visualization-panel {
        width: 100%;
        position: relative;
        top: 0;
        max-height: none;
        height: auto;
        /* Reset fixed height on mobile */
        margin-top: 20px;
        overflow-y: visible;
        /* Allow scrolling on mobile */
        display: block;
        /* Remove flex column constraint on mobile if complicates things */
    }

    #canvas-3d-container {
        height: 400px !important;
        /* Fixed height for mobile */
        flex: none;
    }

    #canvas-2d-container,
    #canvas-2d-plan-container {
        height: 300px;
        /* Fixed height for mobile 2D views */
    }
}

@media (max-width: 768px) {

    .input-panel h2,
    .visualization-panel h2 {
        font-size: 1.5em;
    }
}

/* Results Table */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9em;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.results-table th,
.results-table td {
    border: 1px solid #eee;
    padding: 10px;
    text-align: center;
}

.results-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 0.5px;
}

.results-table tr:hover {
    background-color: #f9f9f9;
}

/* Loading Indicator Styles */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    animation: fadeIn 0.2s ease-in forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

.loading-content {
    background: white;
    padding: 30px 40px;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 250px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1a1a1a;
    border-radius: 50%;
    margin: 0 auto 15px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 1.1em;
    font-weight: 600;
    color: #1a1a1a;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.loading-subtext {
    font-size: 0.85em;
    color: #666;
    margin-top: 8px;
}

/* Inline spinner for buttons */
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    margin-right: 8px;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

/* Range Slider Styles */
#slider-min,
#slider-max {
    -webkit-appearance: none;
    appearance: none;
    height: 30px;
    background: transparent;
    outline: none;
    margin: 0;
    padding: 0;
    /* Make the entire input non-interactive by default */
    pointer-events: none;
}

/* Webkit (Chrome, Safari, Edge) - Slider Track */
#slider-min::-webkit-slider-track,
#slider-max::-webkit-slider-track {
    height: 30px;
    background: transparent;
    border: none;
    /* Ensure track doesn't capture events */
    pointer-events: none;
}

/* Webkit - Slider Thumb - ONLY the thumb should be interactive */
#slider-min::-webkit-slider-thumb,
#slider-max::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 30px;
    background: #0099cc;
    cursor: grab;
    border-radius: 4px;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    /* CRITICAL: Only the thumb should capture pointer events */
    pointer-events: auto;
}

#slider-min::-webkit-slider-thumb:hover,
#slider-max::-webkit-slider-thumb:hover {
    background: #007aa3;
    transform: scale(1.1);
    cursor: grab;
}

#slider-min::-webkit-slider-thumb:active,
#slider-max::-webkit-slider-thumb:active {
    background: #005f7f;
    transform: scale(0.95);
    cursor: grabbing;
}

/* Firefox - Slider Track */
#slider-min::-moz-range-track,
#slider-max::-moz-range-track {
    height: 30px;
    background: transparent;
    border: none;
    /* Ensure track doesn't capture events */
    pointer-events: none;
}

/* Firefox - Slider Thumb - ONLY the thumb should be interactive */
#slider-min::-moz-range-thumb,
#slider-max::-moz-range-thumb {
    width: 20px;
    height: 30px;
    background: #0099cc;
    cursor: grab;
    border-radius: 4px;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    /* CRITICAL: Only the thumb should capture pointer events */
    pointer-events: auto;
}

#slider-min::-moz-range-thumb:hover,
#slider-max::-moz-range-thumb:hover {
    background: #007aa3;
    transform: scale(1.1);
    cursor: grab;
}

#slider-min::-moz-range-thumb:active,
#slider-max::-moz-range-thumb:active {
    background: #005f7f;
    transform: scale(0.95);
    cursor: grabbing;
}