/* Modern Dark Theme Photo Retouching UI */
:root {
    --bg-main: #141518;
    --bg-panel: #1e2024;
    --bg-subpanel: #262930;
    --bg-input: #111214;
    --border-color: #32353c;
    --text-main: #f0f1f3;
    --text-dim: #9aa0a6;
    --accent: #00e5ff;
    --accent-hover: #33ebff;
    --accent-dim: rgba(0, 229, 255, 0.15);
    --warning: #ffbb00;
    --danger: #ff5252;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* Header */
.app-header {
    height: 48px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand h1 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.file-info {
    font-size: 12px;
    color: var(--text-dim);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Main Layout */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    position: relative;
    background-color: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
}

/* Floating View Toolbar */
.view-toolbar {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(30, 32, 36, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 15;
}

.canvas-wrapper {
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.05s ease-out;
}

#mainCanvas {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 120px);
    object-fit: contain;
}

#overlayCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Split View Divider */
.split-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--accent);
    cursor: ew-resize;
    z-index: 12;
    transform: translateX(-50%);
}

.split-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--accent);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
    pointer-events: auto;
}

.split-handle span {
    line-height: 1;
}

/* Drop Zone */
.drop-zone {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(20, 21, 24, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
}

.drop-zone p {
    font-size: 16px;
    color: var(--text-dim);
}

/* Sidebar */
.sidebar {
    width: 390px;
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.panel-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0px;
    cursor: pointer;
    user-select: none;
    padding: 2px 0;
}

.panel-section:not(.collapsed) .section-header {
    margin-bottom: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapse-icon {
    display: inline-block;
    font-size: 11px;
    color: var(--text-dim);
    transition: transform 0.2s ease;
}

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

.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-main);
}

.section-header:hover .section-title {
    color: var(--accent);
}

/* Panel Body Collapse & Disable */
.panel-body {
    transition: opacity 0.2s ease, filter 0.2s ease;
}

.panel-section.collapsed .panel-body {
    display: none;
}

.panel-section.is-disabled .panel-body {
    opacity: 0.35;
    filter: grayscale(100%);
    pointer-events: none;
}


/* Tone Curve & Histogram Container */
.tone-curve-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
}

.curve-canvas-wrapper {
    position: relative;
    width: 280px;
    height: 280px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    background: #141518;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5);
}

#toneCurveCanvas {
    display: block;
    width: 280px;
    height: 280px;
    cursor: crosshair;
}

#histogramCanvas {
    display: block;
    width: 100%;
    height: 80px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #141518;
}

/* Form Controls */
.control-row {
    margin-bottom: 10px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 4px;
    color: var(--text-main);
}

.control-val {
    color: var(--accent);
    font-family: monospace;
}

input[type="range"] {
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
}

select, input[type="number"], input[type="text"] {
    width: 100%;
    padding: 6px 8px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 4px;
    font-size: 12px;
    outline: none;
}

select:focus, input:focus {
    border-color: var(--accent);
}

/* Buttons */
.btn {
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--accent);
    color: #000;
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: var(--bg-subpanel);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: #33363d;
}

.btn-active {
    background-color: var(--accent-dim) !important;
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}

.btn-sm {
    padding: 3px 8px;
    font-size: 11px;
}

.btn-full {
    width: 100%;
    margin-top: 6px;
}

/* Toggle Switch */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
}

.switch input {
    accent-color: var(--accent);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 540px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.modal-body {
    padding: 18px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.6;
    color: #ccc;
}

.modal-body h4 {
    margin: 12px 0 6px 0;
    color: var(--text-main);
    font-size: 13px;
}

.modal-body pre {
    background: var(--bg-input);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 11px;
    margin: 6px 0 12px 0;
    overflow-x: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-color);
}

.hidden {
    display: none !important;
}

/* Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 229, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 8px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
