/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    font-family: "Montserrat", sans-serif;
    box-sizing: border-box;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== HEADER ===== */
header {
    height: 100px;
    width: 100%;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid black;
}

header .header-container {
    width: min(1100px, 70%);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header img {
    width: 100px;
    height: auto;
}

header .header-right {
    display: flex;
    gap: 20px;
}

header .header-right a {
    text-decoration: none;
    color: black;
    font-size: 18px;
}

header .header-right a:hover {
    text-decoration: underline;
}

/* ===== MAIN CONTENT ===== */
main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 16px 60px;
    gap: 18px;
}

.main-header {
    margin-top: 10px;
    width: min(700px, 92%);
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgb(0, 161, 161);
    border-radius: 50px;
    color: white;
    padding: 18px 20px;
    text-align: center;
}

.main-header h1 {
    font-size: 42px;
    line-height: 1.1;
}

.main-header h3 {
    margin-top: 8px;
    font-weight: 400;
    opacity: 0.95;
}

/* ===== CONTROLS ===== */
.controls {
    width: 70%;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: flex-end;
    padding: 14px 16px;
    border: 1px solid #e6e6e6;
    border-radius: 18px;
    background: #fafafa;
}

.controls label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: #111;
    min-width: 160px;
}

.controls select {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #d6d6d6;
    background: white;
    font-size: 14px;
}

/* ===== OUTPUT AREA ===== */
.output {
    width: 70%;
    padding: 16px;
    border: 1px solid #e6e6e6;
    border-radius: 18px;
    background: white;
}

.status {
    font-size: 14px;
    color: #555;
    margin-bottom: 12px;
}

/* ===== HEATMAP ===== */
.heatmap {
    width: 100%;
    border-radius: 18px;
    border: 1px solid #eee;
}

/* ===== FREQUENCY VIEW ===== */
.freq-layout {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

.freq-layout>* {
    min-width: 0;
    /* Allow flex children to shrink */
}

/* Map (left side) */
.map {
    width: 100%;
    height: 500px;
    border-radius: 18px;
    border: 1px solid #eee;
    overflow: hidden;
    max-width: 100%;
}

.freq-layout .map {
    flex: 1.2;
    height: 700px;
    min-height: 320px;
    margin-bottom: 0;
}

/* Right side (note + table) */
.freq-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 340px;
}

.note {
    font-size: 13px;
    color: #555;
    margin-bottom: 10px;
}

/* Table */
.freq-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 14px;
    overflow: hidden;
}

.freq-table th,
.freq-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    text-align: left;
    font-size: 14px;
}

.freq-table th {
    position: sticky;
    top: 0;
    background: #f5f5f5;
    z-index: 1;
}

.freq-table tr:hover td {
    background: #fafafa;
}

.table-scroll {
    height: 700px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 14px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .freq-layout {
        flex-direction: column;
    }

    .freq-layout .map {
        height: 500px;
        margin-bottom: 16px;
    }

    .freq-right {
        min-width: unset;
    }
}

@media (max-width: 700px) {
    header .header-container {
        width: 92%;
    }

    header .header-right {
        gap: 12px;
    }

    .main-header h1 {
        font-size: 32px;
    }

    .controls,
    .output {
        width: 92%;
    }

    .controls label {
        min-width: 140px;
    }
}

@media (max-width: 550px) {

    .freq-table th,
    .freq-table td {
        font-size: 12px;
    }
}

/* ===== LEGEND (SIDEBAR) ===== */
.heatmap-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    /* Prevent stretching issues */
}

.heatmap-layout .map {
    flex: 1;
    min-width: 0;
    /* Critical for flex resizing */
    height: 700px;
    margin-bottom: 0;
}

.heatmap-legend-side {
    width: 120px;
    height: 700px;
    /* Match map height to ensure bar expands */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    padding: 20px 10px;
    text-align: center;
}

.heatmap-legend-side h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #444;
}

.legend-gradient-bar {
    width: 36px;
    flex: 1;
    background: linear-gradient(to top, #00BFFF, #00FF00, #FFFF00, #FF4500, #FF0000);
    border-radius: 12px;
    margin-top: 15px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    min-height: 550px;
    /* Fallback visibility */
}

.legend-labels-vertical {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    padding: 10px 0;
}