body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Hide the logout button in DSA login dialog since we have our own */
#dsa-login-screen #logout-button {
    display: none !important;
}

/* Top Toolbar */
#top-toolbar {
    background: #2c3e50;
    color: white;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.toolbar-left h1 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 300;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.toolbar-right .login-status {
    font-size: 0.9em;
    color: #ecf0f1;
}

.toolbar-right .login-btn {
    padding: 6px 12px;
    border: 1px solid #3498db;
    background: #3498db;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.toolbar-right .login-btn:hover {
    background: #2980b9;
}

.toolbar-right .logout-btn {
    padding: 6px 12px;
    border: 1px solid #e74c3c;
    background: #e74c3c;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.toolbar-right .logout-btn:hover {
    background: #c0392b;
}


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

/* Left Annotation Browser Sidebar */
.annotation-sidebar {
    width: 300px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    order: -1;
    /* Position before main content */
}

.annotation-sidebar.collapsed {
    width: 40px;
}

.annotation-sidebar.collapsed .sidebar-header {
    position: relative;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 10px 5px;
    height: 100vh;
}

.annotation-sidebar.collapsed .sidebar-header h3 {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.9em;
    margin: 0;
    margin-top: 50px;
    transform: rotate(180deg);
    white-space: nowrap;
}

.annotation-sidebar.collapsed .sidebar-content {
    display: none;
}

.annotation-browser {
    margin-top: 15px;
    min-height: 200px;
    flex: 1;
    overflow-y: auto;
}

/* Collapse/Expand button styling */
.sidebar-toggle-collapse {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    color: #6c757d;
    padding: 4px 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 4px;
}

.sidebar-toggle-collapse:hover {
    color: #495057;
    background-color: rgba(0, 0, 0, 0.05);
}

.annotation-sidebar.collapsed .sidebar-toggle-collapse {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

.annotation-sidebar.collapsed .sidebar-toggle-collapse:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Right Image Navigation Sidebar */
.image-sidebar {
    width: 300px;
    background-color: #f8f9fa;
    border-left: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
}

.image-sidebar.collapsed {
    width: 40px;
}

.image-sidebar.collapsed .sidebar-header {
    position: relative;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 10px 5px;
    height: 100vh;
}

.image-sidebar.collapsed .sidebar-header h3 {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.9em;
    margin: 0;
    margin-top: 50px;
    transform: rotate(180deg);
    white-space: nowrap;
}

.image-sidebar.collapsed .sidebar-content {
    display: none;
}

.image-sidebar.collapsed .sidebar-toggle-collapse {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: #495057;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    color: #495057;
}

.sidebar-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

.dsa-browser {
    margin-top: 15px;
    min-height: 200px;
    flex: 1;
    overflow-y: auto;
}

/* DSA Folder Browser Styles */
.dsa-folder-browser {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.folder-browser-header {
    padding: 10px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.folder-browser-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.folder-browser-header h4 {
    margin: 0;
    font-size: 1.1em;
    color: #495057;
}

.load-dsa-btn {
    padding: 4px 8px;
    border: 1px solid #007cba;
    background: #007cba;
    color: white;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background 0.2s;
}

.load-dsa-btn:hover {
    background: #005a87;
}

.folder-browser-content {
    flex: 1;
    overflow-y: auto;
}

.loading {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

.folder-list {
    padding: 5px;
}

.folder-item {
    padding: 8px 12px;
    margin: 2px 0;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}

.folder-item:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.folder-item.back-button {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    font-weight: bold;
    color: #495057;
}

.folder-item.back-button:hover {
    background-color: #e9ecef;
}

.folder-item.collection-header {
    background-color: #e3f2fd;
    border-color: #90caf9;
    font-weight: bold;
    color: #1565c0;
    cursor: default;
}

.folder-item.collection-header:hover {
    background-color: #e3f2fd;
}

.folder-item.image-item {
    background-color: #f0f8ff;
    border-color: #b3d9ff;
}

.folder-item.image-item:hover {
    background-color: #e6f3ff;
}

.folder-name,
.item-name {
    font-size: 0.9em;
    color: #495057;
}

.image-item .item-name {
    color: #0066cc;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Allows flex item to shrink below content size */
    order: 0;
    /* Position between left and right sidebars */
}


.dsa-ui-container {
    padding: 10px;
    background-color: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

#header {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    padding: 2px 5px;
    background: #f8f8f8;
    border-bottom: 1px solid #ddd;
}

.header-top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 1em;
    align-items: center;
}

.header-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid #e0e0e0;
    margin-top: 5px;
    gap: 1em;
}

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

.header-bottom-right {
    display: flex;
    align-items: center;
    gap: 1em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1em;
}

/* Browse button removed - DSA browser opens automatically */

.login-btn {
    padding: 6px 12px;
    border: 1px solid #007cba;
    background: #007cba;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.login-btn:hover {
    background: #005a87;
}

.login-status {
    font-size: 0.8em;
    color: #666;
    font-style: italic;
}

#header .dsa-link {
    width: 20em;
}

#viewer-container {
    flex: 1;
    min-height: 0;
}

#viewer {
    background-color: #000;
    width: 100%;
    height: 100%;
}

#annotation-controls {
    padding: 5px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}


/* Draw Mode Toggle - Radio Button Style */
.draw-mode-toggle {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 0 10px;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mode-btn {
    position: relative;
    padding: 8px 16px 8px 32px;
    border: 2px solid #6c757d;
    background-color: #ffffff;
    color: #6c757d;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
}

.mode-btn::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid #6c757d;
    border-radius: 50%;
    background-color: #ffffff;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background-color: #e9ecef;
    border-color: #495057;
    color: #495057;
}

.mode-btn:hover::before {
    border-color: #495057;
}

.mode-btn.active {
    background-color: #007bff;
    border-color: #007bff;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.mode-btn.active::before {
    border-color: white;
    background-color: white;
    box-shadow: inset 0 0 0 3px #007bff;
}

.mode-btn.active:hover {
    background-color: #0056b3;
    border-color: #0056b3;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.4);
}

/* Annotation control buttons */
.annotation-button {
    padding: 8px 16px;
    margin: 4px;
    border: none;
    border-radius: 4px;
    background-color: #4CAF50;
    color: white;
    cursor: pointer;
}

.annotation-button:hover {
    background-color: #45a049;
}

/* Hotkey indicators */
.hotkey {
    font-size: 0.8em;
    color: #666;
    margin-left: 8px;
}

#magnification-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

#magnification-controls button {
    padding: 6px 12px;
    border: 1px solid #bbb;
    background: #f8f8f8;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.2s;
}

#magnification-controls button:hover {
    background: #e0e0e0;
}

.hotkey-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hotkey-button {
    padding: 4px 8px;
    border: 1px solid #bbb;
    background: #f8f8f8;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    color: #333;
    transition: background 0.2s;
    min-width: 32px;
    height: 28px;
}

.hotkey-button:hover {
    background: #e0e0e0;
}

/* Protocol Indicator Styling */
.protocol-indicator {
    display: flex;
    align-items: center;
    margin-right: 15px;
    padding: 4px 8px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 12px;
    color: #495057;
}

.protocol-label {
    font-weight: 500;
    margin-right: 4px;
}

.protocol-name {
    font-family: monospace;
    font-weight: 600;
    color: #007bff;
}

/* ROI Display Styling */
#roi-display {
    margin-left: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
}

#roi-display:not([style*="background-color"]) {
    background-color: #f5f5f5;
    color: #666;
    border: 1px solid #ccc;
}

.help-button {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.help-button:hover {
    background: #0056b3;
}

.mouse-coords {
    margin-left: 10px;
    color: #666;
    font-size: 0.9em;
}

.mouse-coords span {
    color: #333;
    background-color: #e8f4f8;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid #b3d9e6;
    font-family: monospace;
}

/* Hotkey Help Modal */
.hotkey-help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hotkey-help-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    margin: 20px;
}

.hotkey-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.hotkey-help-header h3 {
    margin: 0;
    color: #2c3e50;
}

.hotkey-help-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #7f8c8d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hotkey-help-close:hover {
    color: #e74c3c;
}

.hotkey-help-body {
    padding: 20px;
}

.hotkey-section {
    margin-bottom: 25px;
}

.hotkey-section h4 {
    margin: 0 0 15px 0;
    color: #34495e;
    font-size: 1.1em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.hotkey-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 0;
}

.hotkey-key {
    background: #34495e;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-weight: bold;
    min-width: 30px;
    text-align: center;
    margin-right: 15px;
    font-size: 0.9em;
}

.hotkey-desc {
    color: #2c3e50;
    flex: 1;
}