body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    height: 100vh;
    display: flex;
    background-color: #333;
    color: #eee;
}

.container {
    display: flex;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: 250px;
    min-width: 150px;
    max-width: 600px;
    background-color: #222;
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
    padding: 10px;
    flex-shrink: 0;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
    overflow: hidden;
    position: relative; /* Context for absolute children */
}

.image-list {
    flex-grow: 1;
    overflow-y: auto;
    margin-top: 10px;
}

.image-item {
    padding: 5px 10px;
    cursor: pointer;
    border-bottom: 1px solid #333;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.image-item.labeled {
    color: #60a5fa; /* Blue */
}

.image-item.ready {
    color: #ffaa00; /* Orange */
}

.image-item.reviewed {
    color: #4ade80; /* Green */
}

.image-item.active {
    background-color: #007bff;
    color: white;
}

.toolbar {
    height: 80px; /* Increased height */
    min-height: 50px;
    max-height: 200px;
    background-color: #222;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    gap: 30px; /* Increased gap */
    flex-shrink: 0;
    overflow-x: auto; /* Handle overflow when content exceeds width */
    overflow-y: hidden;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 8px; /* Increased gap */
}

.tool-group label {
    font-weight: bold;
    font-size: 0.9em;
    color: #ccc;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-row label {
    font-weight: normal;
    color: #aaa;
    min-width: 15px;
}

.input-row input {
    width: 80px; /* Wider inputs */
    background: #444;
    border: 1px solid #555;
    color: white;
    padding: 4px 8px; /* Bigger padding */
    font-size: 14px;
}

.input-row input:focus {
    border-color: #007bff;
    outline: none;
    background: #555;
}

/* Copy Row */
.copy-row {
    display: flex;
    gap: 5px;
}
.copy-row input {
    width: 240px; /* Wide enough for UUID */
    font-family: monospace;
    font-size: 0.85em;
    padding: 4px;
    background: #333;
    border: 1px solid #555;
    color: #ddd;
}
.copy-row button {
    padding: 2px 8px;
    cursor: pointer;
}

.canvas-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #111;
    overflow: hidden;
    position: relative;
    cursor: crosshair;
    transition: border 0.3s ease;
}

.canvas-container.duplicate {
    border: 5px solid #ff0000;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

canvas {
    /* Removed max-width/height to allow zooming */
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transform-origin: 0 0; /* Important for zoom transform */
}

.help-text {
    height: 40px;
    font-size: 0.8em;
    color: #aaa;
    display: flex;
    gap: 20px;
    align-items: center;
    padding-left: 10px;
    border-top: 1px solid #444;
    background: #222;
    flex-shrink: 0;
}

/* Multi-Canvas TIFF Viewer Styles */
.multi-canvas-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
}

.channel-canvas-wrapper {
    position: relative;
    background: #111;
    border: 2px solid #444;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 4px;
}

.channel-canvas-wrapper.active {
    border-color: #00ff00;
}

.channel-label {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 3px 8px;
    font-size: 0.85em;
    font-weight: bold;
    z-index: 10;
    border-radius: 3px;
}

.channel-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: crosshair;
}

/* View Mode Button Styles */
.view-mode-btn {
    padding: 5px 15px;
    cursor: pointer;
    background: #444;
    border: 1px solid #555;
    color: white;
    border-radius: 3px;
    font-size: 0.85em;
    transition: background 0.2s;
}

.view-mode-btn.active {
    background: #007bff;
    border-color: #0056b3;
}

.view-mode-btn:hover {
    background: #555;
}

.view-mode-btn.active:hover {
    background: #0069d9;
}

/* Channel and Colormap Selectors */
#channel-select,
#colormap-select {
    width: 140px;
    background: #444;
    border: 1px solid #555;
    color: white;
    padding: 4px 8px;
    font-size: 0.85em;
    border-radius: 3px;
}

#channel-select:focus,
#colormap-select:focus {
    border-color: #007bff;
    outline: none;
    background: #555;
}

/* Resize Handles */
.resize-handle {
    background-color: #444;
    flex-shrink: 0;
    z-index: 100;
}

.resize-handle:hover {
    background-color: #666;
}

.resize-handle.active {
    background-color: #007bff;
}

.resize-handle.vertical {
    width: 5px;
    cursor: ew-resize;
    border-left: 1px solid #555;
    border-right: 1px solid #555;
}

.resize-handle.horizontal {
    height: 5px;
    cursor: ns-resize;
    border-top: 1px solid #555;
    border-bottom: 1px solid #555;
}

/* Collapsible Sections */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsible-header:hover {
    color: #fff;
}

.collapse-icon {
    font-size: 0.8em;
    transition: transform 0.2s;
}

.collapse-icon.collapsed {
    transform: rotate(-90deg);
}

.collapsible-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.collapsible-content.collapsed {
    max-height: 0;
}

/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.7); 
}

.modal-content {
    background-color: #222;
    margin: 10% auto; 
    padding: 20px;
    border: 1px solid #444;
    width: 80%; 
    max-width: 500px;
    border-radius: 5px;
    color: #eee;
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: white;
    text-decoration: none;
    cursor: pointer;
}

.modal-header {
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body .control-group {
    margin-bottom: 20px;
}
