:root {
    --primary-color: #D81B60;
    /* Magenta/Fucsia */
    --primary-hover: #ad1457;
    --text-dark: #333333;
    --text-light: #666666;
    --bg-light: #f5f5f5;
    --white: #ffffff;
    --sidebar-width: 280px;
    --toolbar-height: 60px;
    --shadow-card: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-dark);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.dashboard-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--white);
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.sidebar-header {
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}

.sidebar-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
}

.file-list {
    list-style: none;
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 20px;
}

.file-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dark);
}

.file-item:hover {
    background-color: #fce4ec;
    /* Light pink hover */
    color: var(--primary-color);
}

.file-item.active {
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: var(--shadow-card);
}

.empty-state {
    color: var(--text-light);
    font-style: italic;
    text-align: center;
    margin-top: 20px;
}

/* Mini Gallery in Sidebar */
.gallery-preview {
    border-top: 1px solid #e0e0e0;
    padding-top: 15px;
    max-height: 200px;
    /* Limit height */
    overflow-y: auto;
}

.gallery-preview h3 {
    font-size: 0.9rem;
    margin-bottom: 10px;
    color: var(--text-light);
}

.mini-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-bottom: 10px;
}

.mini-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: transform 0.2s;
}

.mini-thumb:hover {
    transform: scale(1.1);
    border-color: var(--primary-color);
}

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: #fafafa;
}

/* Toolbar */
.toolbar {
    height: var(--toolbar-height);
    background-color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 5;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 15px;
    border-right: 1px solid #eee;
}

.toolbar-group:last-child {
    border-right: none;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background-color: #d5d5d5;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: #f0f0f0;
    color: var(--primary-color);
}

.btn-icon.active {
    background-color: var(--primary-color);
    color: var(--white);
}

/* Viewer Area */
.viewer-area {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    /* Important for pan behaviors */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #e0e0e0;
    /* Neutral background behind canvas */
    cursor: grab;
}

.viewer-area.panning {
    cursor: grabbing;
}

.viewer-area.crosshair {
    cursor: crosshair;
}

#canvas-wrapper {
    transition: transform 0.1s ease-out;
    /* Smooth transforms for pan/zoom if applied here, but we will draw on canvas */
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

/* Canvas styling */
canvas {
    display: block;
    image-rendering: auto;
    /* Or pixelated if needed */
}

/* Crop Overlay */
#crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    /* transparent pointer events allow clicking through if needed, 
       but for crop we need to catch events */
}

#selection-box {
    border: 2px dashed var(--primary-color);
    background-color: rgba(216, 27, 96, 0.1);
    position: absolute;
    display: none;
    pointer-events: none;
    /* Let events pass through to overlay handler */
}

/* Hidden Utility */
.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--white);
    padding: 20px;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    text-align: center;
}

.preview-container {
    margin: 20px 0;
    max-height: 300px;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.preview-container img {
    max-width: 100%;
    max-height: 300px;
    box-shadow: var(--shadow-card);
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* Loading Indicator */
#loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    z-index: 50;
    color: var(--primary-color);
}

/* OSD Filters */
.filter-invert {
    filter: invert(100%);
}

.filter-grayscale {
    filter: grayscale(100%);
}