/* Multivariable Comparison Layout CSS */
/* This file handles the layout and responsive drawer functionality */

/* Base layout for larger screens */
.multivar-comp-content {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: 1fr;
    grid-gap: 1rem;
    height: calc(100vh - 150px);
    max-height: calc(100vh - 150px);
}

.info-column {
    grid-column: 1 / 5;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.chart-column {
    grid-column: 5 / 13;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.map-container {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

    .map-container #viewDiv {
        flex: 1;
        min-height: 300px;
    }

.info-cards {
    flex: 0 0 auto;
    overflow: visible;
}

#timeSeriesContainer {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
}

/* Hide drawer elements on large screens */
#drawer-toggle-btn,
#controls-drawer {
    display: none;
}

/* Responsive layout for small screens (≤1500px) */
@media (max-width: 1500px) {
    /* Change to two-column layout: map on left, chart on right - same proportions as large screen */
    .multivar-comp-content {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        grid-template-rows: 1fr;
        grid-gap: 0.75rem;
        height: calc(100vh - 140px);
        max-height: calc(100vh - 140px);
    }

    /* Info column shows only the map - same 4 columns as large screen */
    .info-column {
        grid-column: 1 / 5;
        grid-row: 1;
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    /* Chart column - same 8 columns as large screen */
    .chart-column {
        grid-column: 5 / 13;
        grid-row: 1;
    }

    /* Hide the info cards section on small screens (goes in drawer) */
    .info-cards {
        display: none !important;
    }

    /* Map container takes full height */
    .map-container {
        height: 100%;
        margin-bottom: 0;
    }

        .map-container #viewDiv {
            height: 100%;
            min-height: 100%;
        }

    /* Show the drawer toggle button */
    #drawer-toggle-btn {
        display: flex;
        position: fixed;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1000;
        background-color: var(--falcon-primary, #0d6efd);
        color: white;
        border: none;
        border-radius: 0 0.5rem 0.5rem 0;
        padding: 1rem 0.5rem;
        cursor: pointer;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
        transition: all 0.3s ease;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
    }

        #drawer-toggle-btn:hover {
            padding-right: 0.75rem;
            background-color: var(--falcon-primary-dark, #0b5ed7);
            box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25);
        }

        #drawer-toggle-btn i {
            transition: transform 0.3s ease;
        }

        #drawer-toggle-btn:hover i {
            transform: translateX(3px);
        }

        /* Animate button when drawer opens */
        #drawer-toggle-btn.drawer-open {
            left: 400px;
        }

            #drawer-toggle-btn.drawer-open i {
                transform: rotate(180deg);
            }

    /* Drawer panel styles */
    #controls-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: -400px;
        top: 60px;
        width: 400px;
        height: calc(100vh - 60px);
        background-color: var(--falcon-body-bg, #f9fafd);
        box-shadow: none;
        border-right: 1px solid var(--falcon-border-color, #dee2e6);
        border-radius: 0;
        z-index: 999;
        transition: left 0.3s ease;
        overflow: hidden;
        padding: 0.5rem 1rem 1rem 1rem;
    }

        #controls-drawer.open {
            left: 0;
        }

    /* Drawer header */
    .drawer-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--falcon-border-color, #dee2e6);
        flex-shrink: 0;
        min-height: 50px;
    }

    /* Drawer tabs - only 2 tabs: Controls and Info */
    .drawer-tabs {
        display: flex;
        gap: 0;
        margin: 0;
    }

    .drawer-tab {
        background: none;
        border: none;
        border-bottom: 3px solid transparent;
        padding: 0.75rem 1rem;
        font-size: 1rem;
        font-weight: 500;
        color: var(--falcon-body-color);
        cursor: pointer;
        transition: all 0.2s ease;
        opacity: 0.6;
    }

        .drawer-tab:hover {
            opacity: 1;
            background-color: var(--falcon-bg-subtle, rgba(0, 0, 0, 0.05));
        }

        .drawer-tab.active {
            opacity: 1;
            color: var(--falcon-primary, #0d6efd);
            border-bottom-color: var(--falcon-primary, #0d6efd);
        }

    /* Drawer close button */
    .drawer-close {
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--falcon-body-color);
        padding: 0;
        line-height: 1;
    }

        .drawer-close:hover {
            color: var(--falcon-danger, #dc3545);
        }

    /* Drawer body */
    .drawer-body {
        position: relative;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    /* Drawer tab content */
    .drawer-tab-content {
        display: none;
        height: 100%;
        overflow-y: auto;
        padding: 1rem 0;
    }

        .drawer-tab-content.active {
            display: block;
        }

    /* Style elements inside drawer */
    #controls-drawer .info-cards {
        background: transparent;
        border: none;
        box-shadow: none;
    }

    #controls-drawer .card {
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }

    /* Style the controls tab content */
    #controls-drawer #drawer-tab-controls {
        padding: 1rem 0;
    }

    /* Wrap the dropDownContainer in a visual card */
    #controls-drawer #dropDownContainer {
        background-color: var(--falcon-card-bg, #fff);
        border-radius: 0.375rem;
        padding: 1rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

        /* Style individual dropdown controls in drawer */
        #controls-drawer #dropDownContainer > * {
            width: 100%;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        /* Ensure dropdowns take full width */
        #controls-drawer #dropDownContainer .choices,
        #controls-drawer #dropDownContainer select {
            width: 100% !important;
        }

        /* Add some spacing and styling to dropdown labels if they exist */
        #controls-drawer #dropDownContainer label {
            font-weight: 700;
            font-size: 0.875rem;
            color: var(--falcon-700, #495057);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: 0.5rem;
        }

    /* Style the Data tab content */
    #controls-drawer #drawer-tab-data {
        padding: 1rem 0;
    }

        #controls-drawer #drawer-tab-data .card {
            background-color: var(--falcon-card-bg, #fff);
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }

            /* Improve AppTitleCard layout ONLY in drawer */
            #controls-drawer #drawer-tab-data .card .row {
                display: flex;
                align-items: center;
                gap: 0.5rem;
            }

                /* Make icon column more compact in drawer */
                #controls-drawer #drawer-tab-data .card .row .col-auto:first-child {
                    flex: 0 0 auto;
                    width: auto;
                    padding-right: 0;
                }

                    /* Icon should be smaller in drawer */
                    #controls-drawer #drawer-tab-data .card .row .col-auto:first-child .fs-3 {
                        font-size: 1.5rem !important;
                    }

                /* Text column should expand to fill available space in drawer */
                #controls-drawer #drawer-tab-data .card .row .col:not(.col-auto) {
                    flex: 1 1 auto;
                    min-width: 0;
                }

                /* Question button column should be compact and aligned to the right in drawer */
                #controls-drawer #drawer-tab-data .card .row .col-auto:last-child {
                    flex: 0 0 auto;
                    width: auto;
                    padding-left: 0;
                }

                    /* Make question button smaller in drawer */
                    #controls-drawer #drawer-tab-data .card .row .col-auto:last-child .btn {
                        padding: 0.25rem;
                        font-size: 1rem;
                    }

            /* Ensure title text wraps properly in drawer */
            #controls-drawer #drawer-tab-data .card h5 {
                font-size: 1.125rem;
                line-height: 1.3;
                font-weight: 600;
            }

            /* Description text should be readable in drawer */
            #controls-drawer #drawer-tab-data .card .fs--1 {
                font-size: 0.9375rem !important;
                line-height: 1.5;
            }

    /* Adjust chart header for small screens */
    #timeSeriesContainer .card-header {
        padding: 0.5rem 0.75rem;
    }

        #timeSeriesContainer .card-header .row {
            flex-wrap: wrap;
            gap: 0.5rem;
        }
}

/* Very large screens (≥1800px) - give more space to chart */
@media (min-width: 1800px) {
    .multivar-comp-content {
        grid-template-columns: 1fr 3fr;
    }
}

/* Ensure chart fills available space properly */
#chart-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#chart-canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Modal z-index fixes */
.modal-backdrop {
    z-index: 1040 !important;
}

.modal {
    z-index: 1050 !important;
}
