:root {
    --bg-color: #fcfbf9; /* Warm paper white */
    --text-color: #333;
    --accent-color: #d35400; /* Burnt orange */
    --secondary-color: #7f8c8d;
    --font-serif: "Merriweather", "Georgia", serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --keyword-color: #2980b9; /* Blue for logic operators */
}
body {
    font-family: var(--font-serif);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 2rem;
    padding-bottom: 200px; /* Space for fixed dock */
}

header {
    margin-bottom: 3rem;
    border-bottom: 2px solid var(--text-color);
    padding-bottom: 1rem;
}
header h1 {
    font-size: 2.5rem;
    margin: 0;
    font-weight: 900;
}
header .meta {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
}

/* Thread */
#thread {
    min-height: 300px;
}

.block {
    margin-bottom: 2rem;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.block.user {
    font-family: var(--font-sans);
    font-weight: bold;
    color: var(--accent-color);
    border-left: 3px solid var(--accent-color);
    padding-left: 1rem;
    margin-top: 3rem;
}

.block.bot {
    font-size: 1.1rem;
}

/* Visualizations */
.viz-container {
    margin: 2rem 0;
    padding: 1.5rem;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border: 1px solid #eee;
}
.viz-title {
    font-family: var(--font-sans);
    font-weight: bold;
    margin-bottom: 1rem;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    color: var(--secondary-color);
}

.query-keyword {
    color: var(--keyword-color);
    font-weight: bold;
}

/* Custom Viz for this view */
.big-stat-row {
    display: flex;
    justify-content: space-around;
    margin-bottom: 2rem;
    margin-top: 1rem;
}
.big-stat {
    text-align: center;
}
.big-number {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-color);
}
.big-label {
    color: #6b7280;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Table Style */
table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-sans);
    font-size: 0.9rem;
}
th {
    border-bottom: 2px solid #333;
    text-align: left;
    padding: 0.5rem;
}
td {
    border-bottom: 1px solid #eee;
    padding: 0.5rem;
}

/* Search Concepts Details */
details {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.5rem;
    margin: 1rem 0;
    font-family: var(--font-sans);
}
summary {
    cursor: pointer;
    font-weight: bold;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-count {
    font-family: monospace;
    background: #eee;
    color: var(--text-color);
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 2.5em;
    text-align: center;
    font-size: 0.9em;
}

/* Input Dock Container */
#input-dock-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 100;
}

/* Status Indicator */
#status-indicator {
    height: 1.5rem;
    line-height: 1.5rem;
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
    background: rgba(255,255,255,0.8);
    backdrop-filter: blur(5px);
    border-radius: 10px;
    align-self: flex-start;
    margin-left: 1rem;
}

#status-indicator.active {
    opacity: 1;
    transition: opacity 0s;
}

#status-indicator.active::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-color);
    margin-right: 8px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Input Bar */
.input-bar {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 1rem;
    border-radius: 50px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.05);
    display: flex;
    gap: 1rem;
}

input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    outline: none;
    font-family: var(--font-serif);
}
button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--text-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
button:hover {
    background: var(--accent-color);
}

/* Info Footer */
.info-footer {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: #777;
    text-align: center;
    background: rgba(255,255,255,0.8);
    padding: 0.5rem;
    border-radius: 10px;
}
.info-footer a { color: var(--accent-color); text-decoration: none; }

/* Privacy Protected Results */
.privacy-protected {
    background-color: #f0f2f5 !important;
    border: 1px solid #d1d5db;
    position: relative;
}
.privacy-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    background: #95a5a6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: bold;
    font-style: italic;
    cursor: help;
    z-index: 10;
}
.privacy-icon:hover::after {
    content: "To preserve privacy, this result is not visible to QueryAgent";
    position: absolute;
    top: -35px;
    right: 0;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    font-style: normal;
}

.privacy-url {
    display: inline-block;
    margin-left: 1rem;
    text-align: left;
    font-family: monospace;
    font-size: 0.75rem;
    color: #7f8c8d;
    cursor: help;
    position: relative;
    width: fit-content;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    text-transform: none;
    letter-spacing: normal;
    font-weight: normal;
}
.privacy-url:hover::after {
    content: "Real system embeds this data in the link. Shown in-place for demo.";
    position: absolute;
    bottom: 100%;
    right: 0;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 10;
}

.query-announcement {
    font-family: monospace;
    background: #fcfcfc;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    overflow: auto;
    white-space: pre-wrap;
    font-size: 0.85rem;
    color: #444;
    margin-bottom: 0.5rem;
}

/* Split View Layout */
#layout {
    display: grid;
    grid-template-columns: 250px 1fr 250px; /* Spacer | Chat | Sidebar */
    max-width: 1600px;
    margin: 0 auto;
    gap: 2rem;
    align-items: flex-start;
    position: relative;
}

.side-spacer {
    width: 250px;
}

#main-view {
    min-width: 0;
    display: flex;
    justify-content: center;
}

/* Inner container to center chat like before */
.chat-container {
    width: 100%;
    max-width: 740px;
}

#side-view, #examples-view {
    width: 250px;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    position: sticky;
    top: 2rem;
    max-height: 80vh;
    overflow-y: auto;
}

#side-view {
    transition: transform 0.3s ease;
}

#examples-view {
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

#side-view h2, #examples-view h2 {
    font-size: 1.2rem;
    margin-top: 0;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.4rem;
}

.info-item {
    margin-bottom: 1.5rem;
}
.info-item h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--accent-color);
    font-family: var(--font-sans);
}
.info-item p {
    font-size: 0.9rem;
    color: #555;
    font-family: var(--font-sans);
    margin: 0;
    line-height: 1.5;
}

/* Mobile Sidebar Toggle */
#info-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    border: none;
    font-weight: bold;
    font-family: serif;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    align-items: center;
    justify-content: center;
}

/* Example Categories */
.example-category {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
    margin: 0;
    font-family: var(--font-sans);
    font-weight: 600;
    line-height: 1;
    padding: 0;
}

/* Examples Sidebar */
.example-item {
    display: flex;
    align-items: center;
    height: auto; /* Allow growth */
    min-height: 40px;
    justify-content: start;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #eee;
    border-left: 3px solid var(--accent-color);
    transition: all 0.2s;
    font-size: 0.9rem;
    color: #333;
    text-align: left;
    width: 100%;
    font-family: var(--font-sans);
    word-break: break-word; /* Ensure long words break */
    white-space: normal; /* Force text wrap */
    overflow: hidden; /* contain content */
}
.example-item:hover {
    background: #fff;
    border-color: #d1d5db;
    border-left-color: var(--accent-color);
    box-shadow: 0 2px 5px rgba(211, 84, 0, 0.1);
}
.example-item.visited {
    background: #f0f0f0;
    color: #888;
    border: 1px solid #ddd;
    font-style: italic;
}
.example-item.visited::after {
    content: '✓';
    margin-left: auto; /* Push to right */
    font-weight: bold;
    color: #27ae60;
    padding-left: 0.5rem;
}

.example-item.disabled {
    text-decoration: line-through;
    color: #999;
    cursor: not-allowed;
    border-left-color: #ccc;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-color);
}

input:checked + .slider:before {
    -webkit-transform: translateX(16px);
    -ms-transform: translateX(16px);
    transform: translateX(16px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Welcome Overlay */
#welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s ease;
}

#welcome-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    background: var(--bg-color);
    padding: 2.5rem;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    text-align: center;
    font-family: var(--font-sans);
}

.overlay-title {
    font-family: var(--font-serif);
    font-size: 2rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
    font-weight: 900;
}

.overlay-text {
    font-size: 1rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 2rem;
    text-align: left;
}

.overlay-text ul {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.overlay-text li {
    margin-bottom: 0.5rem;
}

.overlay-btn {
    background-color: var(--accent-color);
    color: #ffffff;
    border: none;
    padding: 1.2rem 3rem;
    font-size: 1.1rem;
    font-family: var(--font-sans);
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 2rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    height: auto;
    width: auto;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    min-width: 220px;
}

.overlay-btn:hover {
    background-color: #e67e22;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(211, 84, 0, 0.4);
}

.overlay-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.suggestions-box {
    margin-top: 0.75rem;
    background: #f0f2f5;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    color: #555;
}
.suggestions-box h3 {
    margin-top: 0;
    font-size: 0.8rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}
.suggestions-box p {
    margin: 0 0 0.25rem 0;
    font-style: italic;
}
.suggestions-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.suggestions-box li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
    border-bottom: 1px solid #e5e7eb;
}
.suggestions-box li:last-child {
    border-bottom: none;
}
.concept-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 10px;
    flex: 1;
    min-width: 0;
}
.concept-count {
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    color: #333;
    flex-shrink: 0;
}

@media (max-width: 1024px) {
    #layout {
        grid-template-columns: 1fr;
        display: block;
    }
    .side-spacer, #examples-view {
        display: none; /* Hide left sidebar on small screens */
    }
    /* ... (rest of media query remains the same) */
    #main-view {
        width: 100%;
    }
    #side-view {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        max-height: 100vh;
        z-index: 999;
        transform: translateX(100%); /* Hidden by default */
        border-radius: 0;
        box-shadow: -5px 0 20px rgba(0,0,0,0.1);
    }
    #side-view.active {
        transform: translateX(0);
    }
    #info-toggle {
        display: flex;
    }
}

@media (max-height: 700px) {
    #welcome-overlay {
        align-items: flex-start;
        overflow-y: auto;
    }

    .overlay-content {
        margin: 2rem auto;
        padding: 1.5rem;
        max-height: none;
    }

    .overlay-title {
        font-size: 1.5rem;
    }

    .overlay-text {
        font-size: 0.9rem;
    }

    .overlay-btn {
        padding: 1rem 2rem;
        font-size: 1rem;
        margin-top: 1rem;
        min-width: 180px;
    }
}

/* Video Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
}
.modal-content {
    background-color: #fcfbf9;
    margin: 2% auto; /* Less vertical margin */
    padding: 2rem;
    border: 1px solid #888;
    width: 95%; /* Wider */
    max-width: 1400px; /* Much wider max-width */
    border-radius: 12px;
    position: relative;
    font-family: var(--font-sans);
    height: 90vh; /* Fixed height */
    display: flex;
    flex-direction: column;
}
.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    align-self: flex-end;
}
.close-modal:hover,
.close-modal:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}
.video-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Force 3 columns */
    gap: 2rem;
    margin-top: 2rem;
    flex: 1; /* Take remaining space */
    overflow-y: auto; /* Scroll internally if needed */
}
.video-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.video-item iframe {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 8px;
    border: none;
    background: #000;
}
.video-title {
    font-weight: bold;
    color: var(--text-color);
    font-size: 1.1rem;
}

/* Patient Detail Modal */
#patient-detail-modal .modal-content {
    max-width: 900px;
    height: 80vh;
}
.patient-header {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ddd;
}
.patient-header .patient-stat {
    font-family: var(--font-sans);
}
.patient-header .patient-stat .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
}
.patient-header .patient-stat .value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-color);
}
.patient-history-table {
    flex: 1;
    overflow-y: auto;
}
.patient-history-table table {
    width: 100%;
}
.domain-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
}
.domain-badge.condition { background: #3498db; }
.domain-badge.drug { background: #27ae60; }
.domain-badge.procedure { background: #e67e22; }
.domain-badge.observation { background: #95a5a6; }

.register-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}
.register-table tbody tr:hover {
    background: rgba(211, 84, 0, 0.12);
    box-shadow: inset 3px 0 0 var(--accent-color);
}

/* Demo Button Pulse - Subtle */
@keyframes subtle-pulse {
    0% { transform: scale(1); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
    50% { transform: scale(1.02); box-shadow: 0 6px 15px rgba(211, 84, 0, 0.3); }
    100% { transform: scale(1); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
}
.demo-btn-highlight {
    animation: subtle-pulse 3s infinite; /* Slower, smoother */
    border: 2px solid var(--accent-color) !important; /* Just a border, no bg change */
    background-color: transparent !important;
    color: var(--accent-color) !important;
}
