html {
    height: 100%;
}

* {
    box-sizing: border-box;
}

:root {
    --primary-color: #0056b3;
    --danger-color: #c0392b;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --body-bg: #f0f2f5;
    --panel-bg: #ffffff;
    --border-color: #d1d9e0;
}
/* --- NEW: Pin Board Variables --- */
:root {
    --board-bg-color: rgba(255, 255, 255, 0.65);
    --board-border-color: rgba(255, 255, 255, 0.8);
    --dot-color: rgba(0, 0, 0, 0.1);
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(255, 255, 255, 0.95);
}

/* --- NEW: PBL Roundtable Visualization Styles (from pbl_table_sample.html) --- */
@keyframes dot-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* --- Authentication Overlay Styles --- */
#app-container {
    visibility: hidden; /* Hidden by default, made visible by JS after auth check */
}

#auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(240, 242, 245, 0.9); /* Use body background color with opacity */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1100;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.auth-box {
    background: #ffffff;
    padding: 40px;
    border-radius: 12px;
    border: 1px solid #d1d9e0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 420px;
}

.auth-box .header-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.auth-box h1 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.auth-box p {
    margin: 0 0 24px 0;
    color: #6c757d;
}

#google-sign-in-btn {
    background-color: #4285F4;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-family: var(--font-family);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
}

#google-sign-in-btn:hover {
    background-color: #357ae8;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #6c757d;
    font-size: 12px;
    width: 100%;
    margin: 16px 0;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #d1d9e0;
}
.divider:not(:empty)::before { margin-right: .5em; }
.divider:not(:empty)::after { margin-left: .5em; }

#email-auth-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 12px;
}

.input-group {
    width: 100%;
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #95a5a6;
    pointer-events: none;
}

#email-input, #password-input {
    width: 100%;
    padding: 12px 16px 12px 45px;
    font-family: var(--font-family);
    font-size: 15px;
    border: 1px solid #ccc;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#email-input:focus, #password-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.25);
}

#email-auth-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-family: var(--font-family);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#email-auth-btn:hover:not(:disabled) {
    background-color: #004494;
    transform: translateY(-2px);
}

#email-auth-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.auth-error {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 10px;
}

.auth-switch {
    margin-top: 16px;
    font-size: 14px;
    color: #6c757d;
}

.link-button {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    font-family: var(--font-family);
}

.link-button:hover {
    text-decoration: underline;
}

/* --- User Profile in Header --- */
.app-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.contact-admin {
    font-size: 0.875rem;
    color: #6c757d;
    font-weight: 400;
}

#user-profile {
    display: none; /* Hidden until user logs in */
    align-items: center;
    gap: 12px;
}

#user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

#user-display-name {
    font-weight: 500;
    color: var(--primary-color);
}

#sign-out-btn {
    background: none;
    border: 1px solid #d1d5da;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}
#sign-out-btn:hover {
    background-color: #f3f4f6;
}

/* --- PBL Avatar Colors --- */
/* Color palette with high contrast and accessibility */
/* Added more variables from sample for roundtable */
:root {
    --avatar-facilitator: #28a745; /* Green - from index.html */
    --avatar-student-1: #007bff;   /* Blue - from index.html */
    --avatar-student-2: #dc3545;   /* Red - from index.html */
    --avatar-student-3: #fd7e14;   /* Orange - from index.html */
    --avatar-student-4: #6f42c1;   /* Purple - from index.html */
    --avatar-student-5: #9b59b6;   /* Light Purple */
    --avatar-student-6: #6610f2;   /* Indigo */
    --avatar-student-7: #16a085;   /* Teal */
    --avatar-student-8: #d35400;   /* Dark Orange */
    --avatar-student-9: #2c3e50;   /* Navy */
    --avatar-student-10: #8e44ad;  /* Purple variant */
    --avatar-student-11: #c0392b;  /* Dark Red */
    --avatar-student-12: #f1c40f;  /* Yellow */
    --table-color: #eef3f1;
    --icon-color: #5a716a;
    --text-color: #2f3e3a;
    --glow-color: #30d5c8;
    --speech-bubble-bg: #f3f6f5; 
    --speech-bubble-text: #2f3e3a;
}

/* Base style for SVG icons in avatars, moved from index.html */
.avatar svg {
    width: 20px;
    height: 20px;
    color: #333; /* Default dark color, good for patient avatar */
}

/* White icon for user avatar, moved from index.html */
.user-row .avatar svg {
    color: white;
}

/* White icon for all PBL participants */
.avatar.facilitator svg,
.avatar[class*="student_"] svg {
    color: white;
}

.avatar.facilitator {
    background-color: var(--avatar-facilitator);
    color: white;
}

.avatar.student_a { background-color: var(--avatar-student-1); color: white; }
.avatar.student_b { background-color: var(--avatar-student-2); color: white; }
.avatar.student_c { background-color: var(--avatar-student-3); color: white; }
.avatar.student_d { background-color: var(--avatar-student-4); color: white; }
.avatar.student_e { background-color: var(--avatar-student-5); color: white; }
.avatar.student_f { background-color: var(--avatar-student-6); color: white; }
.avatar.student_g { background-color: var(--avatar-student-7); color: white; }
.avatar.student_h { background-color: var(--avatar-student-8); color: white; }
.avatar.student_i { background-color: var(--avatar-student-9); color: white; }
.avatar.student_j { background-color: var(--avatar-student-10); color: white; }
.avatar.student_k { background-color: var(--avatar-student-11); color: white; }
.avatar.student_l { background-color: var(--avatar-student-12); color: white; }

/* Fallback for any additional students beyond predefined colors */
.avatar[class*="student_"]:not(.student_a):not(.student_b):not(.student_c):not(.student_d):not(.student_e):not(.student_f):not(.student_g):not(.student_h):not(.student_i):not(.student_j):not(.student_k):not(.student_l) {
    background-color: #95a5a6; /* Gray fallback */
    color: white;
}

/* Mention Tag style inside the contenteditable input */
.mention-tag {
    background-color: #e0eaff; /* A light blue */
    color: #0056b3; /* A darker blue for text */
    padding: 2px 6px;
    border-radius: 12px; /* Pill shape */
    font-weight: 500;
    font-size: 0.95em;
    display: inline-block; /* Allows padding and border-radius */
    margin: 0 1px;
}

/* Container for the roundtable visualization */
#pbl-roundtable-container {
    position: relative;
    overflow: hidden;
    padding-top: 5rem;
    background-color: #f8f9f8; /* Match sample bg */
    /* Add container query support for speech bubbles */
    container-type: inline-size;
    container-name: roundtable;
    height: 100%; /* Fill the tab content area */
    width: 100%;
}

.pbl-environment {
    width: 100%;
    height: 100%; /* Fill the container */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.virtual-table {
    /* Make the table responsive to the container size */
    width: 40vmin;
    height: 40vmin;
    min-width: 300px;
    min-height: 300px;
    max-width: 550px;
    max-height: 550px;
    background: var(--table-color);
    border-radius: 50%;
    box-shadow: 0 5px 25px rgba(0,0,0,0.05), inset 0 0 10px rgba(0,0,0,0.05);
    position: relative;
}

.character-rig {
    position: absolute;
    /* Give the rig a fixed size so that its children (speech bubble) can overflow
       without affecting the rig's own dimensions and position. */
    width: 120px;
    height: 120px;
    transform: translate(-50%, -50%); /* Center the rig on its coordinates */
    /* top and left will be set by JS */
    pointer-events: none; /* Allow clicks to pass through the rig's empty space */
    /* Ensure speech bubbles don't interfere with other elements */
    z-index: 1;
}

.character {
    width: 100%; /* Ensure the grid container fills the rig for proper centering */
    position: relative;
    display: grid; /* Use grid for simpler vertical stacking and centering */
    justify-items: center; /* Horizontally center all items in the grid */
    gap: 4px; /* Space between icon and name */
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease;    
    opacity: 0.2; /* Make inactive speakers even more subtle */
    pointer-events: auto; /* Re-enable pointer events for the character content */
}

.character.active {
    transform: scale(1.1) translateY(-10px);
    opacity: 1;
    z-index: 100;
}

.icon-wrapper {
    /* Make icons responsive */
    width: 5.5vmin;
    height: 5.5vmin;
    min-width: 40px;
    min-height: 40px;
    max-width: 60px;
    max-height: 60px;
    transition: filter 0.4s ease, width 0.4s ease, height 0.4s ease;
}

.person-icon {
    width: 100%;
    height: 100%;
    fill: var(--icon-color);
    transition: fill 0.4s ease;
    filter: grayscale(0.3) brightness(0.8); /* Subtle muting for inactive icons */
}

.character.active .person-icon { 
    fill: var(--glow-color); 
    filter: none; /* Remove muting filter when active */
}
.character.active .icon-wrapper { filter: drop-shadow(0 0 12px var(--glow-color)); }
.character.active .character-name { 
    font-weight: 600; /* Bold when active */
    font-size: 0.9em; /* Normal size when active */
    opacity: 1; /* Full opacity when active */
}

.character-name {
    color: var(--text-color);
    font-weight: 500; /* Lighter font weight for inactive state */
    font-size: 0.9em; /* Slightly smaller text */
    transition: font-weight 0.4s ease, font-size 0.4s ease;
    opacity: 0.7; /* Additional opacity reduction for names */
    text-align: center; /* Ensure text is centered, especially for multi-line names */
}

/* Special styling for facilitator */
#rig-facilitator .icon-wrapper {
    width: 6.5vmin;
    height: 6.5vmin;
    min-width: 50px;
    min-height: 50px;
    max-width: 70px;
    max-height: 70px;
}
#rig-facilitator .character-name { /* margin-top is now handled by the parent's 'gap' property */ }

/* Style to distinguish the user's character on the roundtable */
.character.user-character .person-icon {
    fill: var(--primary-color);
}
.character.user-character .character-name {
    color: var(--primary-color);
}

/* Make user's speech bubble font and typing indicator blue */
.character.user-character .speech-bubble {
    background-color: var(--speech-bubble-bg); /* Revert to default bubble color */
    color: #004085; /* A clearer, less dark navy blue */
    border: none; /* Remove border for consistency with other bubbles */
}

.character.user-character .speech-bubble::after {
    border-top-color: var(--speech-bubble-bg); /* Match the new bubble's background */
}
.character.user-character .typing-indicator span {
    background-color: var(--primary-color);
}

.character-rig.user-typing {
    z-index: 100; /* Bring user to front when typing or using STT */
}

.speech-bubble {
    position: absolute;
    /* Position above the character icon dynamically */
    bottom: 100%;
    margin-bottom: 5px;
    transform-origin: bottom center; /* Make it scale from the center */
    /* Responsive width that adapts to roundtable container size - wider to reduce line wrapping */
    min-width: 80px;
    max-width: min(400px, 35vw, 50vmin);
    background: var(--speech-bubble-bg);
    color: var(--speech-bubble-text);
    border: 1px solid var(--table-color);
    padding: 2px 12px; /* Reduced top/bottom padding */
    border-radius: 12px;
    font-size: 0.95em;
    line-height: 1.5;
    opacity: 0;
    visibility: hidden;
    transform: translateY(5px) scale(1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), 
                box-shadow 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
                opacity 0.4s ease, 
                visibility 0.4s,
                max-width 0.3s ease;
    /* Use max-content to force the bubble to be as wide as its text, up to max-width. */
    width: max-content;
    z-index: 10; /* Ensure bubble is above the icon wrapper */
    text-align: left; /* Ensure text inside is left-aligned */
    /* Ensure content wraps properly and doesn't break layout */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.speech-bubble.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.speech-bubble::after {
    content: '';
    position: absolute;
    /* Position the tail at the bottom-center */
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: var(--speech-bubble-bg) transparent transparent transparent;
}

/* Special positioning for facilitator's bubble */
#rig-facilitator .speech-bubble {
    bottom: auto;
    top: 0;
    left: 100%;
    margin-left: 10px; /* Space from icon */
    transform-origin: left center;
    /* Facilitator needs wider bubbles but still constrained to container */
    max-width: min(480px, 40vw, 60vmin);
    /* The transform itself is handled by JS to combine centering and overflow prevention */
}
#rig-facilitator .speech-bubble::after {
    top: 50%;
    left: -10px; /* Position on the left edge of the bubble, pointing left */
    bottom: auto;
    transform: translateY(-50%);
    border-width: 10px 10px 10px 0;
    border-style: solid;
    border-color: transparent var(--speech-bubble-bg) transparent transparent;
}

.typing-indicator {
    position: absolute;
    /* Position above the character icon dynamically */
    bottom: 100%;
    margin-bottom: 5px;
    display: flex;
    gap: 5px;
    align-items: center;
    background: var(--table-color);
    padding: 10px 15px;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.typing-indicator.visible { opacity: 1; visibility: visible; }
.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: var(--icon-color);
    border-radius: 50%;
}
.typing-indicator span:nth-child(1) { animation: dot-bounce 1.2s infinite ease-in-out; }
.typing-indicator span:nth-child(2) { animation: dot-bounce 1.2s infinite ease-in-out 0.2s; }
.typing-indicator span:nth-child(3) { animation: dot-bounce 1.2s infinite ease-in-out 0.4s; }

body {
    font-family: var(--font-family);
    background-color: var(--body-bg);
    margin: 0;
    color: #333;
    height: 100%; /* Ensure body takes full height of html */
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100%; /* Changed from 100vh for better compatibility */
}

.main-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    /* Default layout for Patient Consultation Mode. Rows for tools, resizer, and notes. */
    grid-template-rows: 1fr 5px 300px;
    grid-template-areas:
        "tools chat"
        "resizer-y chat"
        "notes chat";
    gap: 0 1rem; /* Only column gap */
    flex-grow: 1;
    padding: 1rem; /* Add padding here instead of body */
    overflow: hidden; /* Prevent the grid from overflowing the page */
}

/* NEW: Collapsed state for notes panel in patient consultation mode */
.main-container.notes-collapsed {
    /* Shrink the resizer and notes rows */
    grid-template-rows: 1fr 0px 55px; /* 50px to accommodate header padding and border */
    transition: grid-template-rows 0.3s ease-in-out;
}

/* When collapsed, hide the content area of the notes panel completely */
.main-container.notes-collapsed #notes-panel .panel-content-collapsible {
    display: none;
}

    /* PBL-specific override for the collapsed state */
    .main-container.pbl-mode-active.pbl-session-active.notes-collapsed {
        /* This rule has higher specificity to override the expanded state. */
        /* It resets the container's height management to allow it to shrink. */
        grid-template-rows: 1fr 0px 55px;
        min-height: 0; /* Remove the large min-height from the expanded state */
        height: 100%; /* Make the container fill its parent's height (the viewport) */
        overflow: hidden; /* Restore overflow containment */
    }

    /* In PBL mode, also hide the pin board content when collapsed */
    .main-container.pbl-session-active.notes-collapsed #pin-board-panel .evidence-panel-content {
        display: none;
    }

/* Layout override for PBL Mode (BEFORE session starts) */
.main-container.pbl-mode-active:not(.pbl-session-active) {
    grid-template-rows: 1fr; /* Full height for top panels */
    grid-template-areas:
        "tools chat";
    /* resizer, notes, and pin-board are hidden via JS, so they are not in the grid */
    overflow: visible; /* Override default 'hidden' to allow panels to fill height correctly. */
}

/* Layout override for PBL Session Active (after clicking Start) */
.main-container.pbl-mode-active.pbl-session-active {
    /* MODIFICATION: Set a total height larger than the viewport. */
    /* This allows the JS resizer to work correctly without being constrained to viewport height. */
    /* Using min-height is more robust in a flex context. It ensures the container */
    /* is at least this tall, allowing the resizer JS to calculate against this larger value. */
    min-height: calc(70vh + 50vh + 5px);
    grid-template-rows: 70vh 5px 50vh; /* Set initial sizes */
    grid-template-areas:
        "tools pbl-content"
        "resizer-y resizer-y"
        "notes pin-board";
    overflow: visible; /* Let the content overflow and be scrolled by the body. */
}
.dashboard-panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    overflow: auto; /* Allow individual panels to scroll if content overflows */
}

/* Resizer Styles */
.resizer {
    background: #d1d9e0; /* A visible default color (same as --border-color) */
    z-index: 10;
    /* Prevent content selection while dragging */
    -moz-user-select: none;
    -webkit-user-select: none;
    user-select: none;
    transition: background-color 0.2s ease;
}

.resizer:hover {
    background: var(--primary-color); /* A more prominent color on hover */
}

.resizer-y {
    cursor: ns-resize;
    grid-area: resizer-y;
}

body.resizing-ns {
    cursor: ns-resize !important;
}
#tools-panel { grid-area: tools; }
#notes-panel { grid-area: notes; }
#pin-board-panel { grid-area: pin-board; }
#chat-panel {
    grid-area: chat;
    overflow: hidden; /* Contain content by default */
    display: flex; /* Ensure flexbox layout for children */
    flex-direction: column;
}

/* PBL Content Area with Tabs */
#chat-panel.pbl-layout-active {
    grid-area: pbl-content;
    overflow: visible; /* Allow tabs to be visible */
}

/* PBL Tab Navigation */
.pbl-tab-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    padding-right: 1rem;
}

.pbl-tab-buttons {
    display: flex;
}

.pbl-tab-button {
    /* flex: 1; */
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.pbl-tab-button:hover {
    background-color: var(--table-color);
}

.pbl-tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: white;
}

/* PBL Tab Content */
.pbl-tab-content {
    flex-grow: 1; /* Let the content area fill remaining space */
    overflow: hidden; /* Keep this to contain the scrolling panes */
    /* The height is now managed by flexbox, so the explicit height is removed. */
    /* This also requires the parent (#chat-panel) to have a defined height or be a flex item that can grow, which it is. */
}

.pbl-tab-pane {
    height: 100%;
    display: none;
}

.pbl-tab-pane.active {
    display: flex;
    flex-direction: column;
}

/* Chat content within PBL tab */
.pbl-tab-pane .chat-messages {
    flex-grow: 1;
    overflow-y: auto;
}


/* Chat styles */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8f9fa;
}

/* Responsive Chat Title */
#chat-title .mobile-title {
    display: none;
}

.chat-header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-messages {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.message-row {
    display: flex;
    align-items: flex-end;
    margin-bottom: 1rem;
    gap: 0.75rem;
}
/* The user-row alignment is handled by the ::before pseudo-element */
.user-row::before {
    content: '';
    flex-grow: 1;
}
.patient-row {
    justify-content: flex-start;
}
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-color: #e9ecef;
    border: 1px solid var(--border-color);
}
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* This crops the image to fit, rather than stretching it */
    border-radius: 50%; /* Ensures the image itself is round */
}
.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    line-height: 1.4;
    overflow-wrap: break-word; /* Modern property for word-wrap */
    position: relative; /* For pin button positioning */
    display: inline-block; /* This makes the bubble only as wide as its content, up to max-width */
}
.message .rendered-markdown {
    white-space: normal;
    line-height: 1.6;
}
.message .rendered-markdown > *:first-child {
    margin-top: 0;
}
.message .rendered-markdown > *:last-child {
    margin-bottom: 0;
}
.review-data-container.rendered-markdown > *:first-child {
    margin-top: 0;
}
.review-data-container.rendered-markdown > *:last-child {
    margin-bottom: 0;
}
.speaker-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 0.25rem;
}
.message .blinking-cursor {
    display: inline-block;
    background-color: #333;
    width: 8px;
    height: 1em;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}
.evaluation-message {
    background-color: #f0f8ff; /* A light alice blue */
    border: 1px solid #cce5ff;
    color: #004085;
}

.patient-message {
    background-color: #e9ecef;
    border-bottom-left-radius: 5px;
}
.user-message {
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 5px;
}
.user-row .avatar {
    background-color: var(--primary-color);
}

/* TTS Button Styles */
.tts-button {
    background: transparent;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    opacity: 0; /* Hidden by default */
    transition: all 0.2s ease;
    padding: 0;
    margin-bottom: 4px; /* Align with bottom of message bubble */
    flex-shrink: 0;
}

.patient-row:hover .tts-button {
    opacity: 0.7; /* Show on hover of the whole row */
}

.tts-button:hover {
    opacity: 1;
    background-color: #e9ecef;
}

.tts-button.playing {
    opacity: 1;
    color: var(--primary-color);
    animation: pulse 1.5s infinite;
}

.tts-button:disabled {
    cursor: not-allowed;
}

.tts-button svg {
    width: 18px;
    height: 18px;
}

/* This must come AFTER the main .tts-button rule to override opacity */
.roundtable-tts-button {
    position: absolute;
    bottom: 8px;
    right: 8px; /* Position to the left of pin button */
    transform: none;
    margin-left: 0;
    width: 24px;
    height: 24px;
    background: var(--speech-bubble-bg);
    border: 1px solid var(--table-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--icon-color);
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
    opacity: 1;
    margin-bottom: 0;
    z-index: 15;
}

.roundtable-tts-button svg {
    width: 14px;
    height: 14px;
}

.roundtable-tts-button:hover {
    background-color: var(--table-color);
}

.chat-input-form {
    display: flex;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background-color: #f8f9fa;
    align-items: center;
}

/* Reorder chat panel elements for PBL mode */
#chat-panel.pbl-layout-active > .chat-input-form {
    order: 3;
}
#chat-panel.pbl-layout-active > .chat-messages {
    order: 4;
    height: 100vh; /* Make chat message area tall only in PBL mode */
}
#chat-panel.pbl-layout-active {
    overflow: visible; /* Allow page to scroll only in PBL mode */
}

.input-container {
    position: relative;
    flex-grow: 1;
    margin-right: 0.5rem;
}
.chat-input {
    width: 100%; /* This is already here */
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    box-sizing: border-box; /* This is already here */
    font-family: var(--font-family); /* Inherit font for consistency */
    resize: none; /* Disable manual resizing by user */
    line-height: 1.5; /* Improve readability for multiline text */
    max-height: 150px; /* Limit growth to prevent breaking layout */
    overflow-y: auto; /* Add scrollbar when max-height is reached */
    padding-top: 10px; /* Adjust padding for better vertical alignment */
    padding-bottom: 10px;
    /* --- Custom Scrollbar (Firefox) --- */
    scrollbar-width: thin;
    scrollbar-color: #a8a8a8 transparent;
    background-color: #fff; /* Make input box white */
    min-height: 44px; /* Match button height */
}

/* Placeholder for contenteditable div */
.chat-input:empty:before {
    content: attr(data-placeholder);
    color: #999;
    pointer-events: none;
    display: block; /* For the placeholder to show */
    height: 0; /* So it doesn't take up space when there's content */
}
.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.2);
}

/* --- Custom Scrollbar for Chat Input (WebKit browsers like Chrome, Safari) --- */
.chat-input::-webkit-scrollbar {
    width: 8px; /* Width of the entire scrollbar */
}

.chat-input::-webkit-scrollbar-track {
    background: transparent; /* Make the track invisible */
}

.chat-input::-webkit-scrollbar-thumb {
    background-color: #c1c1c1; /* A subtle grey color for the scrollbar thumb */
    border-radius: 10px; /* Fully rounded corners for the thumb */
}
.chat-input::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8; /* A slightly darker grey on hover */
}

/* Mention Dropdown Styles */
.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 8px;
}
.mention-dropdown-header {
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    font-weight: 600;
    color: #6c757d;
    border-radius: 8px 8px 0 0;
}
.mention-dropdown-list {
    padding: 0.5rem 0;
}
.mention-dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background-color 0.2s ease;
}
.mention-dropdown-item:hover,
.mention-dropdown-item.active {
    background-color: #f0f8ff;
}
.mention-dropdown-item .participant-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}
.mention-dropdown-item .participant-avatar svg {
    width: 16px;
    height: 16px;
    color: white;
}
.mention-dropdown-item .participant-info {
    flex-grow: 1;
}
.mention-dropdown-item .participant-name {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}
.mention-dropdown-item .participant-role {
    font-size: 0.8rem;
    color: #6c757d;
}
.send-button {
    border: none;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0; /* Prevent button from shrinking */
    transition: all 0.2s ease;
}

.send-button:hover:not(:disabled) {
    background-color: #004494;
    transform: scale(1.1);
}
.send-button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

/* STT Button Styles */
.stt-button {
    border: none;
    background-color: #f0f2f5;
    color: #6c757d;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    margin-right: 0.5rem;
    transition: all 0.2s ease;
}

.stt-button:hover:not(:disabled) {
    background-color: #e9ecef;
}

.stt-button.listening {
    background-color: #e74c3c; /* A clear red for recording */
    color: white;
    animation: pulse-stt 1.5s infinite;
}

.stt-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.stt-button svg {
    width: 20px;
    height: 20px;
}

/* PBL Mode Controls Layout */
#pbl-mode-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* NEW: Style for the stop generation button state */
.send-button.stop-generation-btn {
    background-color: var(--danger-color);
}

/* NEW: The white square icon for the stop button */
.send-button.stop-generation-btn .stop-icon-square {
    width: 14px;
    height: 14px;
    background-color: white;
    border-radius: 2px; /* A subtle rounding for the square */
}

.send-button.stop-generation-btn:hover {
    background-color: #a51824; /* Darker red */
    transform: scale(1.1);
}

#pass-turn-btn, #facilitator-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease-in-out;
}

#facilitator-btn {
    background-color: #28a745; /* Green color to distinguish facilitator button */
}

#pass-turn-btn:hover, #facilitator-btn:hover {
    transform: translateY(-1px);
}

#pass-turn-btn:hover {
    background-color: #5a6268;
}

#facilitator-btn:hover {
    background-color: #218838;
}

#pass-turn-btn:active, #facilitator-btn:active {
    transform: translateY(0);
}

/* NEW: Style for disabled Pass/Facilitator buttons */
#pass-turn-btn:disabled, #facilitator-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Tabbed Tools Panel */
.tab-nav { display: flex; border-bottom: 1px solid var(--border-color); }
.tab-button {
    flex-grow: 1;
    padding: 1rem 0.5rem;
    background: #f8f9fa;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.tab-button.active, .tab-button:hover {
    background: var(--panel-bg);
    color: var(--primary-color);
}
.tab-button.active { border-bottom-color: var(--primary-color); }
.tab-content { display: none; padding: 1rem; overflow-y: auto; flex-grow: 1; }
.tab-content.active {
    display: flex; /* Use flex to ensure consistent layout behavior */
    flex-direction: column; /* Stack content vertically */
    /* This ensures the tab content area reliably fills the space given by flex-grow, preventing layout shifts when tab content changes. */
}
.tab-content h4 { margin-top: 0; }
.tab-content dl { margin: 0; }
.tab-content dt { font-weight: bold; color: #555; }
.tab-content dd { margin-left: 0; margin-bottom: 1rem; }

/* Lab-specific styles */
.lab-reference { font-size: 0.85em; color: #6c757d; margin-bottom: 0.5rem !important; }
.lab-notes { 
    background-color: #f8f9fa; 
    border-left: 4px solid var(--primary-color); 
    padding: 0.75rem; 
    margin-top: 1rem; 
    font-size: 0.9rem; 
    border-radius: 0 4px 4px 0;
}
.no-lab-results {
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
    font-style: italic;
}
.no-lab-results p {
    margin: 0;
    font-size: 1rem;
}

/* NEW: Table for lab results */
.lab-results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.lab-results-table th,
.lab-results-table td {
    border: 1px solid #e9ecef;
    padding: 0.6rem 0.8rem;
    text-align: left;
    vertical-align: middle;
}

.lab-results-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

.lab-results-table tbody tr:nth-child(odd) {
    background-color: #fdfdfe;
}

.lab-results-table tbody tr:hover {
    background-color: #f1f3f5;
}

/* Lab Test Panel in main UI */
.lab-test-panel {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: #f8f9fa;
}
.lab-test-panel:last-child {
    margin-bottom: 0;
}
.lab-test-panel h5 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}
.lab-test-date {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 0;
    margin-bottom: 1rem;
}

/* Background-specific styles */
.background-section {
    margin-bottom: 1.5rem;
}
.background-section h5 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}
.background-section p {
    margin: 0 0 1rem 0;
    line-height: 1.5;
    color: #555;
}
.background-section p:last-child {
    margin-bottom: 0;
}
.no-background-info {
    text-align: center;
    padding: 2rem 1rem;
    color: #6c757d;
    font-style: italic;
}
.no-background-info p {
    margin: 0;
    font-size: 1rem;
}

.instructions-title {
    font-size: 1rem;
    font-weight: 600;
    color: #333; /* black as requested */
    margin-top: 0;
    margin-bottom: 0.75rem;
}
.instructions-body {
    font-size: 0.9rem;
    color: #6c757d; /* light grey as requested */
    line-height: 1.5;
    margin: 0;
}
.action-button {
    display: block; width: 100%; padding: 0.85rem; margin-bottom: 0.5rem;
    background-color: #fafbfc; border: 1px solid #d1d5da; border-radius: 6px;
    text-align: left; cursor: pointer; font-size: 1rem;
}
.action-button:hover { background-color: #f3f4f6; border-color: #a9b4be; }
.action-button.destructive {
    color: #cb2431; /* A common destructive action red */
}
.action-button.disabled-feature {
    background-color: #f8f9fa;
    color: #6c757d;
    border-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.6;
}
.action-button.disabled-feature:hover {
    background-color: #f8f9fa;
    border-color: #e9ecef;
}
.coming-soon-notice {
    text-align: center;
    padding: 1rem;
    margin-top: 1rem;
    border-top: 1px solid #e9ecef;
}
.coming-soon-notice p {
    margin: 0;
    color: #6c757d;
    font-style: italic;
    font-size: 0.9rem;
}
.action-button.destructive:hover {
    color: #cb2431;
    background-color: #fff5f5;
    border-color: #d73a49;
}

/* Notes Panel */
#notes-panel .panel-content {
    padding: 0; /* Remove padding to allow textarea to fill space */
    flex-grow: 1;
    display: flex; /* Use flexbox to control the textarea size */
}
.notes-textarea {
    width: 100%;
    /* height is now controlled by flex-grow */
    box-sizing: border-box;
    border: none;
    border-radius: 0 0 8px 8px; /* Match panel radius */
    padding: 1rem;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    flex-grow: 1; /* Make the textarea fill the available space */
}
.notes-textarea:focus { outline: none; }

/* NEW STYLES FOR PATIENT PROFILE */
.patient-profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.patient-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}
.patient-avatar svg {
    width: 32px;
    height: 32px;
    color: #333;
}
.patient-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.patient-name {
    font-size: 1.2rem;
    font-weight: 600;
}
/* Profile Picture Upload in Admin Modal */
.profile-picture-preview-container {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px dashed #ccc;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #f8f9fa;
}

.profile-picture-preview-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-picture-preview-container p {
    font-size: 0.8rem;
    color: #6c757d;
    text-align: center;
    padding: 0.5rem;
    margin: 0;
}

/* Profile picture in Background Tab */
.background-profile-picture {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 1.5rem auto; /* Center it and add margin below */
    border: 3px solid #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    /* Ensure this flex item doesn't collapse or get overlapped by the heading */
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
}
.background-profile-picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}


#upload-picture-btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #f0f2f5;
    color: #333;
    margin-top: 0.5rem;
    align-self: flex-start;
}

#upload-picture-btn:hover:not(:disabled) {
    background-color: #e1e8ed;
}

.profile-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1rem 0;
}

.panel-section {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8f9fa;
}
#case-selection-container label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
/* NEW: Add spacing between mode and case selectors when they are in the same panel */
#case-selection-container {
    margin-top: 0.75rem;
}

#case-selector {
    width: 100%;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 1rem;
}

/* Enhanced Mode Selector Styling */
#mode-selector {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    font-size: 1rem;
    font-weight: 500;
    background-color: white;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5rem;
    padding-right: 3rem;
    appearance: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

#mode-selector:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

#mode-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.2);
}

#mode-selector option {
    padding: 0.5rem;
    font-weight: 500;
}

.panel-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #374151;
}

.panel-footer-action {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: #f8f9fa;
}
.panel-footer-action .action-button {
    margin-bottom: 0;
}

/* Custom Confirmation Modal */
.confirmation-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure dynamically created modals appear on top of other modals */
.confirmation-modal-backdrop.dynamic-modal {
    z-index: 1050;
}
.confirmation-modal {
    background-color: var(--panel-bg);
    padding: 1.5rem 2rem;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 400px;
    text-align: center;
}
.confirmation-modal p {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.5;
}
.confirmation-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}
.confirmation-modal-buttons button {
    padding: 0.75rem 1.5rem;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.confirmation-modal-buttons .confirm-btn {
    background-color: #cb2431; /* Use the destructive red */
    color: white;
    border-color: #cb2431;
}
.confirmation-modal-buttons .confirm-btn:hover {
    background-color: #a51824;
    border-color: #a51824;
}
.confirmation-modal-buttons .cancel-btn {
    background-color: #f0f2f5;
    color: #333;
    border-color: #d1d9e0;
}
.confirmation-modal-buttons .cancel-btn:hover {
    background-color: #e1e4e8;
}

.confirmation-modal.loading-modal {
    flex-direction: row;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
}

.confirmation-modal.loading-modal p {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
}

.modal-textarea {
    width: 100%;
    min-height: 150px;
    padding: 0.75rem 1rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.2);
}
/* User Management Modal */
#user-management-modal .modal-body {
    padding: 0; /* Remove padding to allow full-width table */
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-search-container {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.user-search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
}

.user-role-filter {
    min-width: 140px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    background-color: white;
    cursor: pointer;
}

#user-list-container {
    overflow: auto; /* Use 'auto' to get both vertical and horizontal scrollbars if needed */
    flex-grow: 1;
}

/* Pagination Styles */
#pagination-container {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background-color: var(--bg-primary);
}

.pagination-info {
    text-align: center;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 40px;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--bg-secondary);
    border-color: var(--primary-color);
}

.pagination-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--text-secondary);
}

.pagination-ellipsis {
    padding: 0.5rem 0.25rem;
    color: var(--text-secondary);
}

.user-management-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.user-management-table th,
.user-management-table td {
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem;
    text-align: left;
    vertical-align: middle;
}

.user-management-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.user-management-table th.checkbox-column {
    width: 5%;
    text-align: center;
}

.user-management-table select,
.user-management-table .update-user-btn,
.user-management-table .delete-user-btn {
    font-size: 0.9rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid #ccc;
}

.user-action-buttons {
    display: flex;
    gap: 0.5rem;
}

.user-management-table .delete-user-btn {
    background-color: transparent;
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.user-management-table .update-user-btn {
    background-color: #28a745;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-management-table .update-user-btn:hover:not(:disabled) {
    background-color: #218838;
}

.user-management-table .delete-user-btn:hover:not(:disabled) {
    background-color: #fff5f5;
    color: #a51824;
}

/* Make both manage attempts and delete buttons smaller */
.user-management-table .manage-attempts-btn,
.user-management-table .delete-user-btn {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    font-weight: 500;
}

.user-management-table .update-user-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

/* Modal Structure */
.confirmation-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}
.confirmation-modal .modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}
.confirmation-modal .modal-body {
    flex-grow: 1;
    overflow-y: auto;
}
.confirmation-modal .modal-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-footer-actions-right {
    display: flex;
    gap: 0.75rem;
}

.modal-footer-btn {
    padding: 0.6rem 1.2rem;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #f0f2f5;
    color: #333;
}

.modal-footer-btn:hover {
    background-color: #e1e8ed;
}

.modal-footer-btn.primary {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.modal-footer-btn.primary:hover {
    background-color: #004494;
    border-color: #004494;
}

.modal-footer-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.modal-footer-btn:disabled:hover {
    background-color: #f0f2f5;
}

.modal-footer-btn.primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.modal-footer-btn.primary:disabled:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.modal-footer-btn.destructive {
    color: var(--danger-color);
    border-color: var(--danger-color);
    background-color: transparent;
}

.modal-footer-btn.destructive:hover {
    background-color: #fff5f5;
}
#timer-display {
    font-weight: 600;
    font-size: 1.1rem;
    background-color: #ffcdd2; /* A darker, low-saturation red */
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    color: #333;
    transition: all 0.3s ease;
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace; /* Monospaced for stable width */
}
#timer-display.warning {
    background-color: #fff5f5;
    color: #cb2431;
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

/* Language Selector */
#language-selection-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
#language-selection-container label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    margin: 0;
}
#language-selector {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease;
}
#language-selector:hover {
    border-color: var(--primary-color);
}
#language-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.2);
}

/* PBL Difficulty Dropdown */
#pbl-difficulty-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
#pbl-difficulty-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    margin: 0;
}
#pbl-difficulty-dropdown {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s ease;
}
#pbl-difficulty-dropdown:hover {
    border-color: var(--primary-color);
}
#pbl-difficulty-dropdown:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.2);
}

#bot-selector {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
}

@keyframes blink {
    from, to { background-color: transparent }
    50% { background-color: #333; }
}

/* Styles for code blocks */
.message .rendered-markdown pre {
    background-color: #282c34;
    color: #abb2bf;
    padding: 1em;
    border-radius: 8px;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 1em 0;
}

@keyframes pulse-stt {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Styles for Admin Case Review Data */
.review-data-container {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
}
.review-data-list {
    padding-left: 1rem;
    margin: 0;
}
.review-data-list dt {
    font-weight: 600;
    color: #343a40;
    margin-top: 0.75rem;
}
.review-data-list dd {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}
.review-data-value {
    color: #495057;
    white-space: pre-wrap; /* Wrap long lines */
    word-break: break-word;
}
.review-data-value-pre {
    background-color: #f8f9fa; /* A slightly different background for pre blocks */
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.9em;
    max-height: 200px; /* Prevent super long prompts from taking over */
    overflow-y: auto;
}
.review-data-array {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin: 0;
}
.review-data-array li {
    margin-bottom: 0.5rem;
}

/* Admin Modal Editor Table Styles */
.json-editor-container {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
}

.key-value-pair {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.key-value-pair:last-child {
    margin-bottom: 0;
}

.key-value-pair label {
    font-weight: 500;
    text-align: right;
    color: #495057;
}

.editor-section {
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    background-color: #fff;
}

.editor-section:last-child {
    margin-bottom: 0;
}

.editor-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

.editor-section-header span {
    font-weight: 600;
    color: var(--primary-color);
}

.editor-section label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #343a40;
    display: block;
}

.editor-section input[type="text"],
.editor-section textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 1rem;
}

.editor-section input[type="text"]:focus,
.editor-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.2);
}

.editor-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.editor-table th,
.editor-table td {
    border: 1px solid #d1d9e0;
    padding: 0.5rem;
    text-align: left;
    vertical-align: top;
}

.editor-table th {
    background-color: #f1f3f5;
    font-weight: 600;
}

.editor-table input[type="text"] {
    width: 100%;
    border: 1px solid transparent;
    padding: 0.25rem;
    border-radius: 4px;
    background-color: transparent;
}

.editor-table input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.2);
}

.add-row-btn {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    border: 1px dashed #28a745;
    background-color: #f0fff4;
    color: #28a745;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    width: 100%;
    text-align: center;
}

.add-row-btn:hover {
    background-color: #28a745;
    color: white;
    border-style: solid;
}

.delete-row-btn {
    background-color: transparent;
    color: #6c757d;
    border: 1px solid transparent;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 1.2rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
}

.delete-row-btn:hover {
    background-color: #f8d7da;
    color: var(--danger-color);
    border-color: var(--danger-color);
}

/* Styles for range slider in admin modal */
.range-slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.range-slider-container input[type="range"] {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 5px;
    outline: none;
    opacity: 0.8;
    transition: opacity .2s;
}

.range-slider-container input[type="range"]:hover {
    opacity: 1;
}

.range-slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
}

.range-slider-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

.range-slider-value {
    font-weight: 600;
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    min-width: 3em; /* Reserve space for "1.50" */
    text-align: left;
    color: #495057;
}

/* Lab Test Editor Section in Admin Modal */
.lab-test-editor-section .add-lab-result-btn {
    width: auto; /* Don't make it full width */
    display: inline-block;
}
.lab-test-editor-section .lab-test-notes {
    min-height: 80px;
}
#add-lab-test-btn {
    margin-top: 1rem;
}

/* Admin Modal Editor Form Styles */
.case-editor-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-field {
    display: flex;
    flex-direction: column;
}

.max-attempts-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.max-attempts-container input {
    flex: 1;
    min-width: 0;
}

.reset-all-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--danger-color);
    background-color: transparent;
    color: var(--danger-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    height: fit-content;
}

.reset-all-btn:hover:not(:disabled) {
    background-color: #fff5f5;
    border-color: #b91c1c;
    color: #b91c1c;
}

.reset-all-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: #9ca3af;
    border-color: #9ca3af;
}

.reset-all-btn:disabled:hover {
    background-color: transparent;
    border-color: #9ca3af;
    color: #9ca3af;
}

.form-field label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #343a40;
}

.voice-list-link {
    font-weight: 400;
    font-size: 0.8rem;
    margin-left: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
}

.voice-list-link:hover {
    text-decoration: underline;
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-field input[type="text"]:focus,
.form-field input[type="number"]:focus,
.form-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.2);
}

.form-field textarea {
    min-height: 120px;
    resize: vertical;
}

/* Specific textarea height adjustments */
#case-initial-message-textarea {
    min-height: 60px; /* Smaller height for this specific field */
}

#case-profile-prompt-textarea,
#case-evaluation-prompt-textarea,
#case-description-textarea,
#case-learning-objectives-textarea,
.form-field .background-content {
    min-height: 600px; /* Taller height for markdown/content fields */
}

/* --- Mobile Accordion Styles --- */
.panel-header-mobile {
    display: none; /* Hidden on desktop */
}

/* Show the headers for the Notes and Pin Board panels on desktop, as they are collapsible. */
#notes-panel .panel-header-mobile,
#pin-board-panel .panel-header-mobile {
    display: flex;
    cursor: pointer; /* Allow collapsing on desktop */
}
/* Ensure the toggle icon is also visible for these desktop headers. */
#notes-panel .panel-toggle-icon,
#pin-board-panel .panel-toggle-icon {
    display: inline-block; /* Show toggle on desktop */
}

/* NEW: Ensure collapsible content fills the panel on desktop */
.panel-content-collapsible {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    /* This allows the .tab-content child with flex-grow: 1 to expand correctly. */
    /* On mobile, this is overridden by max-height for the accordion effect. */
    overflow: hidden; /* Contain scrolling children like tab content */
}

@media (max-width: 900px) {
    html {
        font-size: 15px; /* Use a slightly smaller base font for mobile */
    }

    /* Hide the "Language:" label on mobile to save space */
    #language-selection-container label {
        display: none;
    }

    .app-header {
        padding: 0.5rem 1rem; /* Reduce vertical padding from 1rem to 0.5rem */
    }

    .app-header h1 {
        font-size: 1rem;
        /* Truncate long text on small screens */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 60vw; /* Adjust as needed */
    }

    .contact-admin {
        display: none;
    }

    .chat-header {
        padding: 0.5rem 1rem; /* Reduce vertical padding from 1rem to 0.5rem */
    }

    #user-avatar {
        width: 28px; /* Reduce from 36px to 28px */
        height: 28px;
    }

    /* --- NEW: Responsive Chat Title --- */
    #chat-title .desktop-title {
        display: none;
    }
    #chat-title .mobile-title {
        display: inline;
    }

    #user-display-name,
    #sign-out-btn {
        display: none;
    }

    /* Responsive changes for the roundtable */
    #pbl-roundtable-container {
        height: auto; /* Let it grow with content */
        max-height: 40vh; /* But not too much */
        overflow-y: auto;
    }
    .virtual-table { display: none; }
    .pbl-environment {
        flex-direction: column;
        justify-content: flex-start; /* Align to top */
        gap: 10px;
        padding: 10px 0;
        height: auto; /* Let it grow */
    }
    .character-rig {
        position: relative !important; /* Use important to override inline styles */
        transform: none !important;
        top: auto !important;
        left: auto !important;
        margin-bottom: 10px;
    }
    .main-container {
        display: flex;
        flex-direction: column;
        overflow-y: auto; /* Allow the main area to scroll if content overflows */
        height: 100%; /* Use full height of parent */
        padding: 0.5rem;
        gap: 0.5rem;
        /* Remove grid properties that are no longer needed */
        grid-template-columns: 1fr;
        grid-template-areas:
            "chat"
            "tools"
            "notes";
    }

    #vertical-resizer { display: none; }

    .dashboard-panel {
        flex-shrink: 0; /* Prevent panels from shrinking */
    }

    /* Re-order panels for mobile and guarantee chat window is always visible */
    #chat-panel {
        order: 1; /* 1. Place chat panel at the top */
        flex-grow: 1; /* 2. Allow it to take available space */
        min-height: 60vh; /* 3. Ensure it's always at least 60% of the screen height */
    }

    #tools-panel {
        order: 2; /* Place tools panel below chat */
    }

    #notes-panel {
        order: 3; /* Place notes panel at the bottom */
    }

    .panel-header-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 1rem;
        font-weight: 600;
        cursor: pointer;
        user-select: none;
        background-color: #f8f9fa;
        font-size: 0.9rem;
    }
    /* Ensure the notes panel header is clickable on mobile for the accordion */
    /* Reset flex properties for mobile accordion to work correctly */
    .panel-content-collapsible {
        display: block;
        flex-grow: 0;
    }
    #notes-panel .panel-header-mobile {
        cursor: pointer;
    }

    .panel-toggle-icon {
        font-size: 1.5rem;
        font-weight: 600; /* Bolder to look more like a button */
        line-height: 1; /* Better vertical alignment */
        /* Ensure toggle icon is visible on mobile, overriding the desktop hide rule */
        display: inline-block;
    }

    .panel-content-collapsible {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease-out;
    }

    .dashboard-panel.active .panel-content-collapsible {
        max-height: 100vh; /* A large enough value to show all content */
        overflow-y: auto;
    }

    /* --- MODIFICATION START --- */
    .chat-input-form {
        flex-wrap: wrap;
        row-gap: 0.5rem; /* Add space between input and button rows */
    }

    .input-container {
        margin-right: 0; /* Remove margin, let gap handle spacing */
    }

    #pbl-mode-controls {
        flex-basis: 100%; /* Force this container to a new line */
        justify-content: flex-end; /* Push buttons to the right */
    }
    /* --- MODIFICATION END --- */

    /* --- Mobile Button Size Adjustments --- */
    .stt-button,
    .send-button {
        width: 36px;
        height: 36px;
    }
    .stt-button {
        margin-right: 0.25rem; /* Reduce margin for smaller button */
    }
    .send-button {
        font-size: 1.2rem; /* Reduce icon size */
    }
    .stt-button svg {
        width: 18px; /* Reduce icon size */
        height: 18px;
    }

    #tools-panel .panel-content-collapsible {
        overflow-y: auto; /* Ensure tools panel content can scroll if it's long */
    }

    .speech-bubble { 
        width: 75vw; 
        bottom: 100px; 
    }

    /* --- Mobile Modal Improvements --- */
    #user-management-modal,
    #course-management-modal,
    #review-case-modal {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    /* User Management: Make table horizontally scrollable */
    #user-list-container {
        overflow-x: auto;
    }
    .user-management-table {
        min-width: 750px; /* Force horizontal scroll on small screens */
    }

    /* --- Course Management Mobile Improvements --- */
    .modal-back-btn {
        display: none; /* Hidden by default, shown by JS on mobile */
        background: none;
        border: none;
        font-size: 1rem;
        font-weight: 600;
        color: var(--primary-color);
        cursor: pointer;
        padding: 0;
        line-height: 1;
    }

    #course-management-modal .modal-header {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        width: 100%;
        gap: 0.5rem;
    }
    #course-management-modal #cm-back-to-list-btn { grid-column: 1; }
    #course-management-modal #cm-modal-title {
        grid-column: 2;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    #course-management-modal #course-management-modal-close-btn { grid-column: 3; }
    
    #course-management-modal.details-visible #cm-modal-title {
        text-align: left;
    }

    #course-management-modal .modal-body {
        flex-direction: column;
        overflow-y: auto;
    }

    /* On mobile, the nav pane takes full height of the body */
    .course-management-nav-pane {
        width: 100%;
        height: 100%;
        border-right: none;
        border-bottom: none;
    }

    /* Initially hide details, show list */
    #course-management-modal .course-management-main-content {
        display: none;
    }

    /* When details are visible, hide list and show details */
    #course-management-modal.details-visible .course-management-nav-pane { display: none; }
    #course-management-modal.details-visible .course-management-main-content { display: flex; flex-direction: column; flex-grow: 1; }

    .enrollment-columns {
        grid-template-columns: 1fr; /* Stack columns */
    }
    .typing-indicator { 
        bottom: 110px; 
    }
}

/* --- Markdown Editor Styles --- */
.markdown-editor-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.markdown-editor-toolbar {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 8px 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.markdown-toggle-btn, .markdown-ai-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.markdown-toggle-btn:hover, .markdown-ai-btn:hover {
    background: #0056b3;
}

.markdown-ai-btn {
    background: #6f42c1;
}

.markdown-ai-btn:hover {
    background: #5a37a0;
}

.markdown-view-container {
    padding: 16px;
    min-height: 100px;
}

.markdown-edit-container {
    padding: 0;
}

.markdown-edit-container textarea {
    width: 100%;
    min-height: 150px;
    border: none;
    padding: 16px;
    resize: vertical;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.markdown-edit-container textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px #007bff;
}

.markdown-rendered-content {
    min-height: 60px;
    line-height: 1.6;
}

/* Custom File Upload Input in AI Build Modal */
.file-upload-input {
    display: none; /* Hide the default input */
}

.file-upload-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background-color: #f0f2f5;
    border: 2px dashed #d1d9e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    justify-content: center;
    margin-top: 1rem;
}

.file-upload-label:hover {
    background-color: #e9ecef;
    border-color: var(--primary-color);
}

.file-upload-label svg {
    width: 24px;
    height: 24px;
    color: #6c757d;
    transition: color 0.2s ease;
}

.file-upload-label:hover svg {
    color: var(--primary-color);
}

.file-upload-label span {
    font-weight: 600;
    color: #333;
}

#file-upload-filename {
    display: block;
    margin-top: 10px;
    font-style: italic;
    color: #6c757d;
    text-align: center;
    font-size: 0.9rem;
}

/* Spinner for AI Generation */
#ai-build-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 32px; /* Reserve space to prevent layout shifts */
}

.status-text {
    margin: 0;
    font-weight: 500;
}

.spinner {
    border: 4px solid #f3f3f3; /* Light grey */
    border-top: 4px solid var(--primary-color); /* Blue */
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

/* Batch Add Users Modal Styles */
#batch-add-users-modal-backdrop {
    z-index: 1003;
}

#batch-add-users-modal {
    max-width: 600px;
    width: 90%;
}

#batch-emails-textarea {
    min-height: 150px;
    resize: vertical;
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
}

#batch-default-password {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#batch-default-password:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.2);
}

/* Add spacing between form fields in batch modal */
#batch-add-users-modal .form-field {
    margin-bottom: 1.25rem;
}

#batch-add-users-modal .form-field:last-child {
    margin-bottom: 0;
}

#batch-creation-progress .spinner {
    width: 20px;
    height: 20px;
    border-width: 3px;
}

#batch-results-container {
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.batch-result-item {
    padding: 0.25rem 0;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.batch-result-item:last-child {
    border-bottom: none;
}

.batch-result-status {
    font-weight: 600;
    min-width: 70px;
}

.batch-result-status.success {
    color: #28a745;
}

.batch-result-status.error {
    color: var(--danger-color);
}

.batch-result-email {
    flex-grow: 1;
    color: #495057;
}

.batch-result-message {
    font-size: 0.8rem;
    color: #6c757d;
    font-style: italic;
}

#batch-creation-stats {
    display: flex;
    gap: 1rem;
}

.batch-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.batch-stat-success {
    color: #28a745;
    font-weight: 600;
}

.batch-stat-error {
    color: var(--danger-color);
    font-weight: 600;
}

.batch-stat-total {
    color: #6c757d;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Asset Download Links in AI Build Modal */
.asset-downloads {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.asset-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: #fff;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.asset-link:hover {
    background-color: #f0f8ff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.asset-link svg {
    color: var(--primary-color);
}


.markdown-rendered-content:empty:before {
    content: "No content to display";
    color: #6c757d;
    font-style: italic;
}

/* Background content wrapper specific styles */
.background-content-wrapper {
    margin-top: 8px;
}

.background-content-wrapper .markdown-editor-container {
    margin-top: 4px;
}

/* Ensure markdown editors in forms align with other form elements */
.form-field .markdown-editor-container {
    margin-top: 4px;
}

#start-pbl-container {
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

#start-pbl-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#start-pbl-btn:hover {
    background-color: #004494;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* --- Pin Board Styles (from sample) --- */

/* --- STYLISH THUMBTACK PIN BUTTON --- */
.pin-button {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
    z-index: 10;
}

/* Always show pin button when in PBL mode */
#chat-panel.pbl-layout-active .message-row .pin-button {
    opacity: 1;
    transform: scale(1);
}

/* Always show pin button on visible speech bubbles */
.speech-bubble.visible .pin-button {
    opacity: 1;
    transform: scale(1);
}

/* Enhanced hover effects for pin buttons */
#chat-panel.pbl-layout-active .message-row:hover .pin-button,
.speech-bubble.visible:hover .pin-button {
    opacity: 1;
    transform: scale(1.1);
}

/* The thumbtack icon created with pseudo-elements */
.pin-button::before { /* The head */
    content: '';
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background-color: #a0a0a0;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.pin-button::after { /* The pin */
    content: '';
    position: absolute;
    top: 70%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 9px;
    background-color: #a0a0a0;
    border-radius: 1px;
    transition: all 0.2s ease;
}

.pin-button:hover::before,
.pin-button:hover::after {
    background-color: var(--primary-color);
}
.pin-button:hover {
    transform: scale(1.1);
}

/* --- Board Styling --- */
.evidence-panel-content {
    flex-grow: 1;
    position: relative;
    padding: 1rem;
}

.glass-board {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 12px;
    border: 1px solid var(--board-border-color);
    background-color: var(--board-bg-color);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.07);
}

.board-content {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    overflow: auto;
    background-image: radial-gradient(var(--dot-color) 0.5px, transparent 0.5px);
    background-size: 20px 20px;
}

/* Mounting hardware effect */
.glass-board::before, .glass-board::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #d1d5db;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    z-index: 1;
}
.glass-board::before { top: 15px; left: 15px; }
.glass-board::after { top: 15px; right: 15px; }

.evidence-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    width: 260px;
    position: absolute;
    cursor: grab;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 0 0 1px transparent, 0 5px 15px rgba(0,0,0,0.07);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--card-border);
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    gap: 8px;
}

.card-header .avatar {
    width: 24px;
    height: 24px;
}
.card-header .avatar svg {
    width: 14px;
    height: 14px;
}

.card-content {
    padding: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: #1a1a1a;
    flex-grow: 1;
}

.unpin-button {
    position: absolute;
    top: 6px;
    right: 6px;
    background: transparent;
    border: none;
    width: 28px;
    height: 28px;
    color: #999;
    cursor: pointer;
    font-size: 20px;
    opacity: 0.5;
    transition: all 0.2s ease;
    z-index: 5;
}

.evidence-card:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 0 0 1px var(--primary-color), 0 8px 25px rgba(0,0,0,0.1);
}

.evidence-card:hover .unpin-button {
    opacity: 1;
    color: var(--primary-color);
}

.evidence-card:active {
    cursor: grabbing;
    z-index: 1000;
}

/* Fallback responsive design for browsers without container query support */
@supports not (container-type: inline-size) {
    @media (max-width: 800px) {
        .speech-bubble {
            max-width: min(320px, 30vw, 45vmin);
            font-size: 0.95em;
            padding: 14px;
        }
        #rig-facilitator .speech-bubble {
            max-width: min(380px, 35vw, 50vmin);
        }
    }
    
    @media (max-width: 600px) {
        .speech-bubble {
            max-width: min(280px, 28vw, 40vmin);
            font-size: 0.9em;
            padding: 12px;
            line-height: 1.4;
        }
        #rig-facilitator .speech-bubble {
            max-width: min(320px, 32vw, 45vmin);
        }
    }
    
    @media (max-width: 400px) {
        .speech-bubble {
            max-width: min(240px, 25vw, 35vmin);
            font-size: 0.85em;
            padding: 10px;
        }
        #rig-facilitator .speech-bubble {
            max-width: min(280px, 30vw, 40vmin);
        }
    }
}

/* Container queries for better responsive speech bubble sizing */
@container roundtable (max-width: 800px) {
    .speech-bubble {
        max-width: min(320px, 30vw, 45vmin);
        font-size: 0.95em;
        padding: 14px;
    }
    
    #rig-facilitator .speech-bubble {
        max-width: min(380px, 35vw, 50vmin);
    }
}

@container roundtable (max-width: 600px) {
    .speech-bubble {
        max-width: min(280px, 28vw, 40vmin);
        font-size: 0.9em;
        padding: 12px;
        line-height: 1.4;
    }
    
    #rig-facilitator .speech-bubble {
        max-width: min(320px, 32vw, 45vmin);
    }
}

@container roundtable (max-width: 400px) {
    .speech-bubble {
        max-width: min(240px, 25vw, 35vmin);
        font-size: 0.85em;
        padding: 10px;
    }
    
    #rig-facilitator .speech-bubble {
        max-width: min(280px, 30vw, 40vmin);
    }
    
}

.speech-bubble .pin-button {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 15;
    /* Add thumbtack icon styles here if needed */
}

.speech-bubble-content {
    padding-right: 12px; /* Minimal right padding */
}

/* --- Course Code Pill Input --- */
.course-code-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.course-code-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
}

.course-code-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 500;
}

.remove-pill-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    transition: background-color 0.2s ease;
}

.remove-pill-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.course-code-add-new {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* The border was removed to simplify the input appearance. */
    /* The input field itself will now have the border. */
}

.course-code-add-new:focus-within {
    /* The focus ring is now on the input element directly. */
}

div.course-code-add-new input.new-course-code-input {
    flex-grow: 1;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: #fff;
    padding: 0.25rem 0.5rem; /* Reduced padding to make it shorter */
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.course-code-add-new input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.2);
}

.add-course-code-btn {
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px; /* Made button smaller */
    height: 24px; /* Made button smaller */
    font-size: 1.2rem; /* Adjusted font size for smaller button */
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 2px; /* Optical alignment for '+' */
    transition: background-color 0.2s ease;
}

.add-course-code-btn:hover {
    background-color: #218838;
}

/* --- Course Management Modal --- */

.course-management-nav-pane,
.course-management-main-content {
    height: 100%; /* Ensure panes can fill the modal body height */
}

#course-management-modal .modal-body {
    padding: 0;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}

.course-management-nav-pane {
    width: 250px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
}

.nav-pane-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    background-color: #f8f9fa;
    flex-shrink: 0;
}

.course-management-nav-pane .user-search-input {
    margin: 1rem;
    width: calc(100% - 2rem);
}

#cm-course-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

#cm-course-list li {
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    cursor: pointer;
    border-bottom: 1px solid #e9ecef;
    transition: background-color 0.2s ease;
}

.course-list-item-main {
    font-weight: 500;
}

.course-list-item-sub {
    font-size: 0.8rem;
    color: #6c757d;
}

.course-list-item-sub code {
    background-color: #e9ecef;
    padding: 2px 5px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    color: #333;
    font-weight: 600;
    word-break: break-all; /* Prevent long codes from breaking layout */
}

#cm-course-list li:hover {
    background-color: #e9ecef;
}

#cm-course-list li.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

#cm-course-list li.active .course-list-item-sub {
    color: rgba(255, 255, 255, 0.85);
}

.course-management-main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Styles for "Manage by Course" Tab */

.cm-enrollment-view-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    font-size: 1.2rem;
    text-align: center;
}

#cm-enrollment-header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    grid-template-areas:
        "title actions"
        "details actions";
    align-items: center;
    padding: 1.5rem;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
    gap: 0.25rem 1.5rem; /* row-gap column-gap */
}

.cm-enrollment-header-title {
    grid-area: title;
    min-width: 0;
}

.cm-header-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cm-header-course-code {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: #333;
    line-height: 1.2;
}

.cm-enrollment-header-details {
    grid-area: details;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.cm-detail-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cm-detail-label {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 500;
}

.cm-detail-value {
    background-color: #e9ecef;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    color: #333;
    font-weight: 600;
    word-break: break-all; /* Prevent long codes from breaking layout */
    font-size: 0.9rem;
}

.cm-enrollment-header-actions {
    grid-area: actions;
    display: flex;
    flex-direction: column; /* Stack buttons vertically */
    gap: 0.5rem;
    align-items: flex-end; /* Align to the right */
    flex-shrink: 0;
}

.new-course-instruction {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: #e7f3ff; /* Light info blue */
    border: 1px solid #b3d7ff;
    border-left-width: 4px;
    border-left-color: var(--primary-color);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin: 1rem 0 0 0;
}
.new-course-instruction svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--primary-color);
}
.new-course-instruction span {
    font-size: 0.9rem;
    color: #004085; /* Dark blue text for contrast */
    line-height: 1.5;
}
#cm-enrollment-view {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    /* Custom scrollbar styling for the enrollment view */
    scrollbar-width: thin;
    scrollbar-color: #a8a8a8 #f1f1f1;
}

/* WebKit scrollbar styling for enrollment view */
#cm-enrollment-view::-webkit-scrollbar {
    width: 8px;
}

#cm-enrollment-view::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

#cm-enrollment-view::-webkit-scrollbar-thumb {
    background-color: #c1c1c1;
    border-radius: 6px;
    border: 1px solid #f1f1f1;
}

#cm-enrollment-view::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8;
}

#cm-enrollment-view:not(.cm-enrollment-view-placeholder) {
    padding-top: 0;
}
.enrollment-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex-grow: 1;
    overflow: hidden;
}

.enrollment-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Ensure section has a maximum height to trigger scrolling */
    max-height: 60vh;
    min-height: 300px;
}

.enrollment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.enrollment-header h4 {
    margin: 0;
    font-size: 1rem;
}

.enrollment-section .user-search-container {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.enrollment-user-list {
    overflow-y: auto;
    flex-grow: 1;
    /* Custom scrollbar styling for better visibility */
    scrollbar-width: thin;
    scrollbar-color: #a8a8a8 #f1f1f1;
}

/* WebKit scrollbar styling for enrollment lists */
.enrollment-user-list::-webkit-scrollbar {
    width: 8px;
}

.enrollment-user-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.enrollment-user-list::-webkit-scrollbar-thumb {
    background-color: #c1c1c1;
    border-radius: 6px;
    border: 1px solid #f1f1f1;
}

.enrollment-user-list::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8;
}

.enrollment-user-list table {
    width: 100%;
    border-collapse: collapse;
}

.enrollment-user-list th,
.enrollment-user-list td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #e9ecef;
    text-align: left;
}

.enrollment-user-list th {
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
}

.enrollment-user-list .checkbox-column {
    width: 40px;
    text-align: center;
}

/* Pagination styles for course management enrollment tables */
.enrollment-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    background-color: #f8f9fa;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.cm-page-btn {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    min-width: 2rem;
    text-align: center;
    line-height: 1;
}

.cm-page-btn:hover:not(:disabled) {
    background-color: #f8f9fa;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.cm-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f8f9fa;
}

.pagination-info {
    color: #6c757d;
    font-weight: 500;
    margin: 0 0.5rem;
}
