/**
 * Copyright 2025 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* Basic Reset & Body Style */
html {
    height: 100%;
    --image-fixed-width: 280px;
}

body {
    font-family: sans-serif;
    line-height: 1.6;
    background-color: #f4f4f4;
    color: #333;
    margin: 0;
    display: flex;
    flex-direction: column;
    user-select: none;
}

.main {
    display: none;  /*display: grid;*/
    grid-template-columns: 1fr minmax(500px, 800px) minmax(300px, 1fr);
    grid-template-rows: auto;
    column-gap: 20px;
    row-gap: 10px;
    padding: 30px;
}

h1,
h2 {
    color: #333;
}

.page-header h1 {
    margin: 0;
}

.container {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    padding: 20px;
    flex-grow: 1;
    justify-content: center;
}

/* Top Navigation Styles */
.top-navigation {
    display: flex;
    align-items: center;
    padding-top: 30px;
    gap: 15px; /* Space between back button and case tabs */
    border-bottom: 1px solid #E0E0E0; /* Optional: a subtle separator */
    margin-bottom: 10px;
    align-items: flex-start;
    justify-content: center;
}

.nav-button {
    display: inline-flex; /* Changed from inline-flex on parent to allow direct styling */
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.nav-button-inner {
    overflow: hidden;
    border-radius: 100px; /* Very rounded corners */
    outline: 1px solid #C4C7C5; /* Outline color */
    outline-offset: -1px; /* Outline inside */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 12px;
    gap: 8px; /* Increased gap slightly for better visual separation */
    transition: background-color 0.2s ease;
}

.nav-button-icon {
    font-size: 20px; /* Icon size */
    color: #444746; /* Icon color */
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-button-text {
    color: #444746; /* Text color */
    font-size: 14px;
    font-family: 'Google Sans Text', sans-serif;
    font-weight: 500;
    line-height: 20px;
    white-space: nowrap;
}

.nav-button-case.active .nav-button-inner,
.nav-button:hover .nav-button-inner {
    background-color: rgba(68, 71, 70, 0.10); /* Focused/hover background */
}

.nav-button-info {
    color: #004A77;
    margin: 0 20px;
}


/* Column Styles */
.report-section,
.image-section,
.explanation-section {
    position: relative;
    float: right;
}

.image-section {
    justify-content: center;
    display: flex;
    flex-direction: column;
    justify-self: end;
}

.report-section {
    flex: 1;
    max-width: 800px;
}

.image-header {
    text-align: center;
    color: black;
    font-size: 22px;
    font-family: Google Sans;
    font-weight: 400;
    line-height: 28px;
    word-wrap: break-word;
    margin: 5px;
}

.case-selector-tabs-container {
    display: grid;
    justify-content: center;
    align-items: center;
    grid-template-columns: min-content auto;
    column-gap: 20px;
    row-gap: 10px;
    padding-left: 20px;
    white-space: nowrap;
}

.case-selector-tabs-modality-container {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: flex-start;
}

.case-selector-tabs {
    display: flex;
    flex-wrap: wrap;
}

/* Report Text & Sentences */
.report-text-area {
    padding: 30px;
    overflow-y: auto;
    background-color: #fdfdfd;
    border-radius: 28px;
    border: 2px solid #E9E9E9;
}

/* Styles for clickable sentences within the report text area */
.report-sentence {
    cursor: pointer;
    padding: 2px 0;
    transition: background-color 0.2s ease;
    border-radius: 14.272px;
    border: 1.359px solid #F1E161;
}

.report-sentence:hover {
    background: #F1E161;
    mix-blend-mode: multiply;
}

.report-sentence.selected-sentence {
    background: #F1E161;
    mix-blend-mode: multiply;
}

/* Image Section */
.image-container {
    position: relative;
    border: 1px solid #ccc;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    background-color: #f0f0f0;
    margin: 0 auto; /* Keep auto margin for centering if desired */
    width: var(--image-fixed-width);
}

.image-container img {
    display: block;
    max-width: 100%;
    height: auto;
}

#report-image {
    width: var(--image-fixed-width);
    min-width: var(--image-fixed-width); /* Ensure min-width also uses the variable if it's meant to be the same */
}

#image-loading {
    width: var(--image-fixed-width);
}

/* Note specific to CT images, displayed under the image */
#ct-image-note {
    display: none; /* Initially hidden, controlled by JavaScript */
    text-align: center;
    margin-top: 10px;
    font-size: 0.9em;
    color: #555;
    padding: 0 10px; /* Add some padding so text doesn't touch edges if it wraps */
    word-wrap: break-word; /* Ensures text wraps to prevent overflow */
    width: var(--image-fixed-width); /* Same width as the image */
}

.marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    display: none;
    transition: top 0.3s ease-in-out, left 0.3s ease-in-out;
    width: max-content;
}

/* Explanation Section */
.explanation-box {
    border: 1px solid #eee;
    min-height: 50px;
    background-color: #F1E161;
    box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.25);
    position: absolute;
    left: -20px;
    top: 0px;
    width: 300px;
    transition: top 0.3s ease-in-out, background-color 0.3s ease, height 0.3s ease;
}

.explanation-header {
    font-size: 22px;
    font-style: normal;
    font-weight: 400;
    padding: 10px 10px 0;
}

.loading .explanation-header {
    display: none;
}

/* New style for the content wrapper inside explanation-box */
#explanation-content {
    padding: 10px;
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
}

/* Style for when the box is loading */
.explanation-box.loading {
    background-color: #cfcfcf;
}

/* Adjust #explanation-loading (the div element) to be an overlay */
#explanation-loading {
    display: none;
    font-style: italic;
    color: #777;
    text-align: center;
    padding: 10px;
}

/* Show #explanation-loading when its parent #explanation-output (which is .explanation-box) has class 'loading' */
#explanation-output.loading > #explanation-loading {
    display: flex;
}

/* Utility Classes */
.error-message {
    color: #d9534f;
    background-color: #f2dede;
    border: 1px solid #ebccd1;
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    text-align: center;
}

/* Responsive Adjustments (Optional) */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
}

/* Info Page Styles */
.info {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.info-page-container {
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 40px;
    background-color: #fff;
    max-width: 1200px;
    margin: 20px auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.info-content {
    flex: 1;
    min-width: 350px;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    font-size: 18px;
}

.info-header {
    margin-bottom: 10px;
}

.info-title-med,
.info-title-demo {
    font-family: 'Google Sans', sans-serif;
    font-size: 48px;
    font-weight: 400;
}

#info-button .nav-button-inner{
    background-color: #C2E7FF;
}

.info-title-demo {
    color: #969696;
    margin-left: 10px;
}

.info-subtitle-demo {
    color: #969696;
    font-size: 28px;
}

.info-text {
    font-family: 'Google Sans', sans-serif;
    line-height: 1.6;
    color: #333;
}

.info-button {
    font-family: 'Google Sans Text', sans-serif;
    background-color: #0B57D0;
    color: white;
    font-size: 14px;
    font-weight: 500;
    padding: 12px 24px;
    border: none;
    border-radius: 100px;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.3s ease;
    align-self: flex-start;
}

/* Hover state for the button */
.info-button:hover {
    background-color: #0a4db8;
    /* Darker blue on hover */
}

.info-disclaimer-box {
    border: 1px solid #CDCDCD;
    border-radius: 15px;
    padding: 15px 20px;
    margin-top: 20px;
}

.info-disclaimer-text {
    font-family: 'Google Sans', sans-serif;
    color: #333;
    line-height: 1.5;
    margin: 0;
    font-size: 14px;
}

.info-disclaimer-title {
    border-radius: 14.272px;
    border: 1.359px solid #F1E161;
    background: #F1E161;
    mix-blend-mode: multiply;
}

.info-disclaimer-link {
    color: #0B57D0;
    font-weight: 500;
    text-decoration: none;
}

.info-disclaimer-link:hover {
    text-decoration: underline;
}

.info-image-container {
    flex: 1;
    min-width: 300px;
    max-width: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.info-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Responsive adjustments for info page */
@media (max-width: 768px) {
    .info-page-container {
        flex-direction: column;
        padding: 20px;
        margin: 10px;
    }

    .info-content {
        max-width: 100%;
        align-items: center;
        text-align: center;
    }

    .info-button {
        align-self: center;
    }

    .info-header {
        text-align: center;
    }

    .info-title-med,
    .info-title-demo {
        font-size: 36px;
    }

    .info-text {
        font-size: 16px;
    }
}


/* --- Immersive Info Dialog Styles --- */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent backdrop */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Ensure it's on top */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.dialog-box {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    width: 85%;
    max-width: 800px; /* Adjust for desired largeness */
    max-height: 85vh; /* Ensure it fits vertically and allows scrolling */
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Important for border-radius with scrollable content */
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.dialog-overlay.active .dialog-box {
    transform: scale(1);
}

.dialog-title-text {
    padding: 24px 24px 16px 24px;
    margin: 0;
    font-size: 1.6rem; /* Adjust as needed */
    font-weight: 500; /* Using Google Sans weight */
    color: #202124; /* Dark grey text color */
    border-bottom: 1px solid #e0e0e0; /* Subtle separator */
    flex-shrink: 0; /* Prevent title from shrinking */
}

.dialog-body-scrollable {
    padding: 16px 24px 24px 24px;
    overflow-y: auto; /* Enable scrolling for TBD content */
    flex-grow: 1; /* Allow body to take available space */
    color: #3c4043; /* Standard body text color */
    line-height: 1.6;
}

.dialog-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px; /* Increase clickable area */
    line-height: 0; /* Helps align icon if it's just an icon */
    border-radius: 50%;
    transition: background-color 0.2s ease-in-out;
    z-index: 10; /* Ensure close button is above title/body */
}

.dialog-close-btn:hover {
    background-color: rgba(0,0,0,0.08);
}

.dialog-close-btn .material-symbols-outlined {
    font-size: 24px; /* Standard Material Icon size */
    color: #5f6368; /* Standard icon color */
    display: block; /* Better for layout */
}

.hf-logo {
    vertical-align: middle;
    width: 30px;
}

.floating-disclaimer {
    padding: 5px 10px;
    margin-top: 10px;
    color: #333;
    display: flex;
    align-items: center;
    font-size: 12px;
    background-color: lightcyan;
    text-align: justify;
}

.disclaimer-icon {
    vertical-align: middle;
    margin-right: 10px;
    font-weight: 300 !important;
}

.nav-button-back {
    /*justify-self: start;
    margin-left: 30px;*/
}