/* === Reset & Base Styles === */
*,
*:before,
*:after {
    box-sizing: border-box;
}

html,
body {
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Segoe UI', Arial, sans-serif;
}

#main-content {
    display: flex;
}

/* Make the visible-columns dropdown menu tall enough to show all options */
#table-column-selector .Select-menu {
    max-height: 420px !important;
}

#table-column-selector .Select-menu-outer {
    max-height: 420px !important;
}

#table-column-selector .react-select__menu {
    max-height: 420px !important;
}

#table-column-selector .react-select__menu-list {
    max-height: 420px !important;
}

/* === Simple Tab Pane Show/Hide === */
.view-pane {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.view-pane--active {
    display: flex;
}

/* === Tab Bar === */
#view-tab-bar {
    display: flex;
    align-items: center;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 10px;
    flex-shrink: 0;
    position: relative;
}

.view-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 6px 18px;
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 0.95em;
    color: #666;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.view-tab-btn:hover {
    color: #333;
}

.view-tab-btn--active {
    color: #2a3f5f;
    border-bottom-color: #2a3f5f;
    font-weight: 600;
}

/* === HORIZONTAL LAYOUT (Main Panels) === */
#scatter-audio-container {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 2px 0 8px #eee;
    position: relative;
    padding: 1rem;
    height: 100vh;
    overflow: hidden;
}

#filter-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f9f9f9;
    box-shadow: -2px 0 8px #eee;
    flex-shrink: 0;
    transition: all 0.3s ease-in-out;
}

.filters-expanded {
    min-width: 320px;
    width: 380px;
    padding: 0 1rem;
}

.filters-collapsed {
    min-width: 0;
    width: 0;
    padding: 0;
    overflow: hidden;
}

/* === VERTICAL LAYOUT (Inside Panels) === */

/* --- Left Panel Content --- */
#scatter {
    flex: 1;
    min-height: 0;
    width: 100% !important;
    height: 100% !important;
}

.info-autoplay-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1rem 0;
    flex-shrink: 0;
}

#audio-spectrogram-container {
    flex-shrink: 0;
    height: 300px;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
}

/* --- Right Panel Content --- */
#filter-panel-container {
    overflow-y: auto;
    padding: 1rem;
    flex: 1;
}

#histogram-container {
    flex-shrink: 0;
    height: 300px;
    padding: 1rem;
    border-top: 1px solid #ddd;
}

/* === General Component Styling === */
#info {
    font-size: 1.1em;
    color: #2a3f5f;
}

#spectrogram-plot-container,
#spectrogram-plot,
#audio-player {
    width: 100% !important;
}

#spectrogram-plot-container {
    flex: 1;
    min-height: 0;
}

.panel-toggle-button {
    position: absolute;
    top: 3rem;
    right: 1rem;
    z-index: 100;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #ccc;
    background-color: white;
    font-size: 1.2em;
    font-weight: bold;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.panel-toggle-button:hover {
    background-color: #f0f0f0;
}

#filter-title,
#model-filter-title,
#sampling-title,
#merging-title,
.section-title {
    color: #2a3f5f;
    font-weight: 700;
    margin-top: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #ddd;
}

#filter-title {
    margin-top: 0;
}

.section-title {
    cursor: pointer;
}

.histogram-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

#histogram-title {
    margin: 0;
    color: #2a3f5f;
    font-size: 1.1em;
}

/* === Buttons & Inputs === */
.input-field {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.app-button {
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: #f0f0f0;
    cursor: pointer;
}

.app-button:hover {
    background-color: #e0e0e0;
}

.app-button.autoplay-on {
    background-color: #BADCBD;
}

.app-button.autoplay-on:hover {
    background-color: #a9cba1;
}

.spectrogram-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.spectrogram-row>*:nth-child(2) {
    flex: 1;
    margin: 0 10px;
}

/* === Scrollbars === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-thumb {
    background: #c5c5c5;
    border-radius: 4px;
}

/* === Tooltips === */
.label-with-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tooltip-container {
    position: relative;
    display: inline-block;
}

.info-icon {
    cursor: help;
}

.tooltip-text {
    visibility: hidden;
    width: 220px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 1;
    top: 50%;
    right: 125%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 100%;
    margin-top: -5px;
    border: 5px solid transparent;
    border-left-color: #333;
}

/* === Cluster & Label List Fixes === */
#cluster-list-container .dash-checklist label,
#cluster-list-container .dash-checklist .dash-checkbox,
#label-list-container .dash-checklist label,
#label-list-container .dash-checklist .dash-checkbox {
    padding: 0 !important;
    margin: 0 !important;
}

#cluster-list-container input[type="color"],
#label-list-container input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px;
    padding: 0 !important;
    border: 1px solid #bbb !important;
    border-radius: 3px;
    cursor: pointer;
    background: none;
    flex-shrink: 0;
}

#cluster-list-container input[type="color"]::-webkit-color-swatch-wrapper,
#label-list-container input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

#cluster-list-container input[type="color"]::-webkit-color-swatch,
#label-list-container input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.guide-div {
    display: flex;
    width: 100%;
}

.guide-title {
    font-weight: 700;
    text-decoration: none;
    margin-left: auto;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
}

/* === Main View Tabs (Scatter / Table) === */
.main-view-tabs {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.main-view-tabs .tab-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.main-view-tab {
    font-family: 'Segoe UI', Arial, sans-serif;
    font-size: 0.95em;
    padding: 6px 18px !important;
    color: #555 !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    background: transparent !important;
    cursor: pointer;
}

.main-view-tab--selected {
    color: var(--color-accent, #4b8af2) !important;
    border-bottom: 2px solid var(--color-accent, #4b8af2) !important;
    font-weight: 600 !important;
    background: transparent !important;
}

/* === Table View Container === */
#table-view-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: #fff;
    box-shadow: 2px 0 8px #eee;
    padding: 1rem;
    overflow: hidden;
}

/* === Cluster Table === */
.cluster-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.88em;
    min-width: 400px;
}

.cluster-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f5f6fa;
}

.cluster-table th {
    padding: 8px 12px;
    border: 1px solid #d0d4e0;
    text-align: left;
    font-weight: 700;
    color: #2a3f5f;
    white-space: nowrap;
}

.cluster-table td {
    padding: 5px 12px;
    border: 1px solid #e4e7ef;
    text-align: left;
    white-space: nowrap;
    color: #1a1a2e;
}

.cluster-table tbody tr:hover td {
    filter: brightness(0.88);
}

.table-row-clickable:active td {
    filter: brightness(0.75);
}

.cluster-table th:hover {
    background: #e8ecf5;
}