/* ── Sprite Lab — 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; }

.canvas-wrapper { position: relative; display: inline-block; }
#sheet-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;
}

/* ── Preview Bar ──────────────────────────────────────────── */
.preview-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 16px; height: 52px;
    background: var(--surface); border-top: 1px solid var(--border);
}
.preview-bar.hidden { display: none; }
.preview-canvas {
    width: 36px; height: 36px;
    border: 1px solid var(--border); border-radius: 4px;
    image-rendering: pixelated; background: var(--surface2);
}
.preview-controls { display: flex; align-items: center; gap: 8px; }
.preview-btn {
    width: 28px; height: 28px; border-radius: 4px;
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.preview-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.preview-label { font-size: 11px; color: var(--dim); margin-left: 8px; }
.preview-slider { width: 80px; }
.preview-val { font-size: 12px; color: var(--cyan); font-family: 'Courier New', monospace; min-width: 24px; }
.frame-counter { margin-left: auto; }

/* ── Right Panel: Properties ──────────────────────────────── */
.panel-right {
    width: 260px; min-width: 260px;
    background: var(--surface); border-left: 1px solid var(--border);
    overflow-y: auto; display: flex; flex-direction: column;
}
.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: 12px 14px; 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; }

.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); }

.field-color {
    width: 32px; height: 26px; border: 1px solid var(--border); border-radius: 4px;
    background: var(--surface2); cursor: pointer; padding: 2px;
}

.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); }

.hint { font-size: 11px; color: var(--dim); margin-bottom: 8px; }

/* ── 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); }
.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; }

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.btn-row { display: flex; gap: 6px; }

.export-section { margin-top: auto; border-top: 1px solid var(--border); 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); }

.split-controls { margin-bottom: 12px; }
.split-preview-wrapper {
    border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; margin-bottom: 12px;
    display: flex; align-items: center; justify-content: center;
    min-height: 200px; background: var(--surface2);
}
#split-preview-canvas { max-width: 100%; max-height: 400px; image-rendering: pixelated; }

/* ── 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; }
.canvas-view.drag-target { outline: 2px dashed var(--cyan); outline-offset: -4px; }
