/* ── Image Editor — jazudu.com ────────────────────────────── */
/* Uses CSS variables from /theme.css (supports light + dark themes) */

body { overflow: hidden; height: 100vh; }

.nav-spacer { height: 56px; flex-shrink: 0; }

/* ── Project Bar ──────────────────────────────────────────── */
.project-bar {
    display: flex; align-items: center; gap: 12px;
    height: 38px; padding: 0 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    position: relative; z-index: 2;
}
.project-name-input {
    background: transparent; border: 1px solid transparent; border-radius: 4px;
    color: var(--text); font-size: 13px; padding: 4px 8px;
    font-weight: 600; width: 200px;
}
.project-name-input:focus { outline: none; border-color: var(--cyan); }
.save-indicator { font-size: 11px; color: var(--dim); transition: color 0.3s; }
.save-indicator.saving { color: var(--cyan); }
.save-indicator.saved { color: var(--lime); }
.project-actions { display: flex; gap: 6px; margin-left: auto; }
.bar-btn {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
    color: var(--dim); font-size: 11px; padding: 4px 10px; cursor: pointer; transition: all 0.15s;
}
.bar-btn:hover { color: var(--text); border-color: var(--border-hover); background: var(--border); }
.bar-btn-danger:hover { color: var(--pink); border-color: var(--pink); }

/* ── App Layout ───────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: calc(100vh - 56px - 38px);
    position: relative; z-index: 1;
}

/* ── Left Panel: Image Bank ───────────────────────────────── */
.panel-left {
    width: 220px; min-width: 220px;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); font-weight: 600; }
.bank-count { font-size: 11px; color: var(--dim); }
.cropped-header { border-top: 1px solid var(--border); }
.cropped-bank { min-height: 40px; }

.image-bank {
    flex: 1; overflow-y: auto; padding: 8px;
    display: flex; flex-direction: column; gap: 4px;
}
.image-bank::-webkit-scrollbar { width: 4px; }
.image-bank::-webkit-scrollbar-track { background: transparent; }
.image-bank::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }

.bank-drop-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 16px 8px;
    border: 2px dashed var(--border); border-radius: var(--radius);
    cursor: pointer; transition: all 0.2s; min-height: 80px;
}
.bank-drop-zone:hover, .bank-drop-zone.drag-over { border-color: var(--cyan); background: rgba(0,229,255,0.04); }
.drop-icon { font-size: 24px; color: var(--dim); line-height: 1; }
.drop-text { font-size: 12px; color: var(--dim); }
.drop-hint { font-size: 10px; color: var(--dim); opacity: 0.6; }

.bank-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-radius: 6px;
    cursor: pointer; transition: background 0.15s; position: relative;
}
.bank-item:hover { background: var(--surface2); }
.bank-item.selected { background: var(--surface2); outline: 1px solid var(--cyan); }
.bank-thumb {
    width: 40px; height: 40px; border-radius: 4px;
    object-fit: contain; background: var(--surface2); image-rendering: pixelated;
}
.bank-info { flex: 1; min-width: 0; }
.bank-name { font-size: 11px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bank-dims { font-size: 10px; color: var(--dim); }
.bank-delete {
    opacity: 0; width: 18px; height: 18px;
    background: none; border: none; color: var(--pink);
    cursor: pointer; font-size: 14px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: opacity 0.15s;
}
.bank-item:hover .bank-delete { opacity: 1; }
.bank-delete:hover { background: rgba(255,45,149,0.15); }

/* ── Center Panel ─────────────────────────────────────────── */
.panel-center { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.canvas-area { flex: 1; position: relative; overflow: hidden; background: var(--bg); }
.canvas-view { display: none; width: 100%; height: 100%; position: relative; }
.canvas-view.active { display: flex; align-items: center; justify-content: center; overflow: hidden; }

.zoom-indicator {
    position: absolute; bottom: 8px; right: 8px; z-index: 10;
    background: rgba(14,11,26,0.85); border: 1px solid var(--border);
    border-radius: 4px; padding: 3px 8px;
    font-size: 11px; color: var(--dim); font-family: 'Courier New', monospace;
    pointer-events: none; transition: opacity 0.3s;
}
.zoom-indicator.faded { opacity: 0; }

.canvas-wrapper { position: relative; display: inline-block; }
#editor-canvas { display: block; image-rendering: pixelated; }

.canvas-empty {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}
.canvas-empty p { font-size: 14px; color: var(--dim); text-align: center; }

.canvas-wrapper.checkerboard {
    background-image:
        linear-gradient(45deg, #1a1830 25%, transparent 25%),
        linear-gradient(-45deg, #1a1830 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1530 75%),
        linear-gradient(-45deg, transparent 75%, #1a1530 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.canvas-wrapper.bg-dark { background: #0e0b1a; }
.canvas-wrapper.bg-white { background: #ffffff; }

/* Canvas Background Toggle */
.canvas-bg-toggle {
    position: absolute; bottom: 8px; left: 8px; z-index: 10;
    display: flex; gap: 3px;
    background: rgba(14,11,26,0.85); border: 1px solid var(--border);
    border-radius: 6px; padding: 3px;
}
.bg-opt {
    width: 24px; height: 24px; border: 1px solid transparent;
    border-radius: 4px; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: none; transition: all 0.15s;
}
.bg-opt:hover { border-color: var(--border-hover); }
.bg-opt.active { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.bg-opt-swatch {
    width: 14px; height: 14px; border-radius: 2px;
    border: 1px solid var(--border); display: block;
}

/* ── Crop Overlay ─────────────────────────────────────────── */
.crop-overlay { position: absolute; inset: 0; z-index: 5; cursor: crosshair; }
.crop-overlay.hidden { display: none; }
.crop-region {
    position: absolute; border: 2px dashed var(--cyan);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5); cursor: move;
}
.crop-handle {
    position: absolute; width: 12px; height: 12px;
    background: var(--cyan); border: 2px solid #fff; border-radius: 2px;
    z-index: 6; box-shadow: 0 0 4px rgba(0,0,0,0.5);
}
.crop-handle[data-handle="nw"] { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle[data-handle="n"]  { top: -6px; left: 50%; margin-left: -6px; cursor: n-resize; }
.crop-handle[data-handle="ne"] { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle[data-handle="e"]  { top: 50%; margin-top: -6px; right: -6px; cursor: e-resize; }
.crop-handle[data-handle="se"] { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-handle[data-handle="s"]  { bottom: -6px; left: 50%; margin-left: -6px; cursor: s-resize; }
.crop-handle[data-handle="sw"] { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle[data-handle="w"]  { top: 50%; margin-top: -6px; left: -6px; cursor: w-resize; }

/* ── Right Panel: Properties ──────────────────────────────── */
.panel-right {
    width: 260px; min-width: 220px;
    background: var(--surface); border-left: 1px solid var(--border);
    overflow-y: auto;
}
.panel-right::-webkit-scrollbar { width: 4px; }
.panel-right::-webkit-scrollbar-track { background: transparent; }
.panel-right::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }

.panel-section { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.panel-section h3 {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--dim); margin-bottom: 10px; font-weight: 600;
    cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    user-select: none;
}
.panel-section h3::after {
    content: '\25B4'; font-size: 9px; transition: transform 0.2s; color: var(--dim);
}
.panel-section h3:hover { color: var(--text); }
.panel-section.collapsed h3 { margin-bottom: 0; }
.panel-section.collapsed h3::after { transform: rotate(180deg); }
.panel-section.collapsed .section-body { display: none; }

.param-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.param-row:last-child { margin-bottom: 0; }

.field-label { font-size: 11px; color: var(--dim); min-width: 16px; text-transform: uppercase; font-weight: 600; }
.field-input {
    flex: 1; min-width: 0;
    background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
    color: var(--text); font-size: 12px; padding: 5px 8px; font-family: 'Courier New', monospace;
}
.field-input:focus { outline: none; border-color: var(--cyan); }
.field-input::placeholder { color: var(--dim); opacity: 0.5; }

.field-select {
    flex: 1; min-width: 0;
    background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
    color: var(--text); font-size: 12px; padding: 5px 8px; cursor: pointer;
}
.field-select:focus { outline: none; border-color: var(--cyan); }

.slider-val { font-size: 12px; color: var(--cyan); font-family: 'Courier New', monospace; min-width: 32px; text-align: right; }

input[type="range"] { -webkit-appearance: none; flex: 1; height: 4px; background: var(--border); border-radius: 2px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; background: var(--cyan); border-radius: 50%; cursor: pointer; border: 2px solid var(--surface); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: var(--cyan); border-radius: 50%; cursor: pointer; border: 2px solid var(--surface); }

.toggle-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; }
.toggle-label input[type="checkbox"] { display: none; }
.toggle-text { color: var(--dim); transition: color 0.15s; }
.toggle-label input:checked + .toggle-text { color: var(--text); }
.toggle-label input[type="checkbox"] + .toggle-text::before {
    content: ''; display: inline-block; width: 28px; height: 16px;
    background: var(--border); border-radius: 8px;
    vertical-align: middle; margin-right: 6px;
    transition: background 0.2s; position: relative;
}
.toggle-label input:checked + .toggle-text::before { background: var(--cyan); }

.color-swatch { display: inline-block; width: 24px; height: 24px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface2); }
.hint { font-size: 11px; color: var(--dim); margin-bottom: 8px; }

/* ── BG Removal Multi-Color ──────────────────────────────── */
.bg-color-list {
    display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
    flex: 1; min-height: 24px;
}
.bg-no-colors { font-size: 11px; color: var(--dim); }
.bg-color-chip {
    width: 20px; height: 20px; border-radius: 3px;
    border: 1px solid var(--border); cursor: pointer;
    position: relative; flex-shrink: 0;
}
.bg-color-chip:hover::after {
    content: '\00d7'; position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: bold; color: #fff;
    background: rgba(0,0,0,0.5); border-radius: 2px;
}
.btn-tiny {
    background: none; border: 1px solid var(--border); border-radius: 3px;
    color: var(--dim); cursor: pointer; font-size: 14px; line-height: 1;
    width: 22px; height: 22px; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0;
}
.btn-tiny:hover { color: var(--text); border-color: var(--text); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-small {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
    color: var(--text); font-size: 11px; padding: 6px 12px;
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-small:hover { border-color: var(--border-hover); background: var(--border); }
.btn-small.active { border-color: var(--cyan); color: var(--cyan); }
.btn-accent { border-color: var(--cyan); color: var(--cyan); }
.btn-accent:hover { background: rgba(0,229,255,0.1); }

.revert-section { padding: 8px 14px; }
.btn-revert { width: 100%; border-color: var(--pink); color: var(--pink); }
.btn-revert:hover { background: rgba(255,45,149,0.1); }

.btn-primary {
    width: 100%; padding: 10px 16px;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    border: none; border-radius: var(--radius);
    color: #fff; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }

.preset-section { margin-top: 10px; }
.preset-label { display: block; margin-bottom: 6px; }
.preset-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.preset-grid-2 { grid-template-columns: repeat(2, 1fr); }
.preset-btn {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
    color: var(--dim); font-size: 11px; padding: 4px 2px;
    cursor: pointer; transition: all 0.15s; text-align: center;
    font-family: 'Courier New', monospace;
}
.preset-btn:hover { color: var(--cyan); border-color: var(--cyan); background: rgba(0,229,255,0.06); }
.scale-btn { flex: 1; }

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.btn-row { display: flex; gap: 6px; }

.export-section { border-bottom: none; }

/* ── Modals ───────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(8,6,15,0.8); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
}
.modal-backdrop.hidden { display: none; }
.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; width: 560px; max-width: 92vw;
    max-height: 80vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-small { width: 360px; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 14px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--dim); font-size: 20px; cursor: pointer; line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 18px; overflow-y: auto; }

.project-list { display: flex; flex-direction: column; gap: 4px; }
.project-list-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border-radius: 6px; cursor: pointer; transition: background 0.15s;
}
.project-list-item:hover { background: var(--surface2); }
.project-list-name { font-size: 13px; }
.project-list-date { font-size: 11px; color: var(--dim); }
.project-list-delete {
    background: none; border: none; color: var(--dim);
    cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px;
}
.project-list-delete:hover { color: var(--pink); background: rgba(255,45,149,0.1); }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    z-index: 2000; padding: 10px 20px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 13px; color: var(--text);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4); transition: opacity 0.3s, transform 0.3s;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(10px); pointer-events: none; }
.toast.success { border-color: var(--lime); }
.toast.error { border-color: var(--pink); }

/* ── Mobile ───────────────────────────────────────────────── */
.mobile-hint {
    display: none; position: fixed; inset: 0; z-index: 10000;
    background: var(--bg); align-items: center; justify-content: center; text-align: center; padding: 32px;
}
.mobile-hint p { font-size: 16px; color: var(--dim); }

@media (max-width: 600px) {
    .mobile-hint { display: flex; }
    .app-layout, .project-bar, nav { display: none; }
}
@media (max-width: 1024px) and (min-width: 601px) {
    .app-layout { flex-direction: column; height: auto; overflow-y: auto; }
    .panel-left {
        width: 100%; min-width: unset; flex-direction: row;
        border-right: none; border-bottom: 1px solid var(--border); max-height: 120px;
    }
    .panel-left .panel-header { writing-mode: vertical-lr; padding: 8px 6px; }
    .image-bank { flex-direction: row; flex-wrap: wrap; overflow-x: auto; overflow-y: hidden; }
    .bank-drop-zone { min-height: unset; min-width: 100px; padding: 8px; flex-direction: row; }
    .panel-center { min-height: 400px; }
    .panel-right {
        width: 100%; min-width: unset;
        border-left: none; border-top: 1px solid var(--border);
        flex-direction: row; flex-wrap: wrap; overflow-y: visible;
    }
    .panel-right .panel-section { flex: 1; min-width: 200px; }
    .export-section { margin-top: 0; }
}

.bank-item.dragging { opacity: 0.4; }

/* ── Watermark Removal ───────────────────────────────────── */
.wm-brush-active { cursor: none !important; }
.wm-cursor {
    position: fixed; pointer-events: none; z-index: 100;
    border: 2px solid rgba(255,45,149,0.8); border-radius: 50%;
    transform: translate(-50%, -50%);
}
#btn-wm-toggle.active { border-color: var(--pink); color: var(--pink); }
