html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}


/* Scrollable main application area */
.app-scroll {
    height: calc(100vh - 45px); /* reserve footer height */
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 50px;
}


/* Fixed footer */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;

    background: white;
    color: #6c757d;

    font-size: 0.9rem;
    border-top: 1px solid #dee2e6;

    padding: 8px 15px;

    z-index: 9999;
}

.navbar-title {
    font-size: 20px;
    font-weight: bold;
}

.navbar-logo-link {
    display: flex;
    align-items: center;
    height: 45px;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 0;
}

.navbar-logo {
    height: 45px;
    width: auto;
    display: block;
    object-fit: contain;
    margin: 0;
    padding: 0;
}

.navbar .nav-item {
    display: flex;
    align-items: center;
}

/* Full application container */
.app-wrapper {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;  
}

.footer-left {
    margin: 0;
    text-align: left;
    font-weight: 1000;
    flex: 1;
}

.footer-right {
    margin: 0;
    text-align: right;
    white-space: nowrap;       /* Prevent wrapping */
}

.footer-right a {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
}

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

#app-container {
    /* height: 90vh; */
    display: flex;
    overflow: hidden;
}

/* ==========================
   LEFT PANEL
   ========================== */

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 5px;
    min-height: 0;
}

.left-panel .card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ==========================
   Plot PANEL
   ========================== */

.plot-panel {
    flex: 3;
    display: flex;
    flex-direction: column;
    padding: 5px;
    min-height: 0;
}

.plot-panel .card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ==========================
   RIGHT PANEL
   ========================== */

.stats-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 5px;
    min-height: 0;
    height: 80vh;   /* fill viewport height */
    gap: 10px;
}

/* Each info panel gets half the available height */
.stats-panel > .card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.card-fill {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 10px;
}


/* Input row layout */
.input-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    padding: 10px;
}

/* Make inputs take equal width */
.input-row > div {
    flex: 1;
}

.stats-panel > .display-card {
    flex: 0.5 !important;
    height: auto;
}

.plot-box {
    flex: 1;
    min-height: 0;
    display: flex;
}

.plot-box > div,
.plot-box iframe {
    width: 100% !important;
    height: 100% !important;
}

/* ==========================
   RIGHT PANEL
   ========================== */

.right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 5px;
    min-height: 0;
}

/* ---------- Legend layout ---------- */

.legend-container {
    flex: 1;
    display: flex;
    align-items: stretch;
    min-height: 0;
}

.legend-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    align-items: center;   /* center children horizontally */
}

.legend-img {
    flex: 1;
    display: flex;
   
    overflow: hidden;
}

/* Shiny output wrapper */
.legend-img > div {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;  /* horizontal centering */
    align-items: center;      /* vertical centering */
}

/* Actual image */
.legend-img img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ==========================
   EMBEDDING SELECTOR
   ========================== */

.embedding-selector {
    padding-left: 5px;
    padding-top: 5px;
    margin: 0;
}

.embedding-selector .form-group,
.embedding-selector .shiny-input-radiogroup {
    margin-bottom: 0;
}

.embedding-selector .radio,
.embedding-selector .form-check {
    margin-bottom: 0;
}

/* Remove Bootstrap spacing */
.navbar {
    margin-bottom: 0;
}

.tab-content {
    padding-top: 0;
    height: 100%;
    overflow: visible;
}

.card-body {
    padding: 0;
}

.card {
    margin-top: 0;
    margin-bottom: 0;
}

.card > .bslib-gap-spacing {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    gap: 0 !important;
}