/* whiteboard/style.css — Whiteboard app styles */
/* Shared base styles provided by /theme.css */

:root {
    --radius: 8px;
    --nav-h: 56px;
    --topbar-h: 44px;
    --toolbar-w: 160px;
}

body {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    overflow: hidden;
    height: 100vh;
}

/* ============================================================
   TOPBAR
   ============================================================ */
#topbar {
    position: fixed; top: var(--nav-h); left: 0; right: 0;
    height: var(--topbar-h); z-index: 95;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.project-name {
    font-size: 13px; font-weight: 600; color: var(--text);
    background: transparent; border: 1px solid transparent;
    padding: 3px 8px; border-radius: 4px;
    font-family: inherit; outline: none;
    width: 180px; max-width: 220px;
    transition: all 0.2s;
}
.project-name:hover { border-color: var(--border); background: var(--purple-bg); }
.project-name:focus {
    border-color: var(--cyan); background: var(--surface);
    box-shadow: 0 0 0 2px var(--cyan-bg);
}
.save-status { font-size: 11px; color: var(--dim); transition: all 0.3s; }
.save-status.unsaved { color: var(--pink); }
.save-status.flash {
    color: var(--cyan); font-weight: 600;
    animation: save-flash 1.5s ease-out;
}
@keyframes save-flash {
    0% { color: var(--cyan); transform: scale(1.1); }
    50% { color: var(--cyan); }
    100% { color: var(--dim); transform: scale(1); font-weight: 400; }
}
.topbar-center { display: flex; align-items: center; gap: 8px; }
.topbar-tools {
    display: flex; align-items: center; gap: 2px;
    padding: 2px 4px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius);
}
.topbar-tools .tool-btn { width: 30px; height: 30px; }
.tool-sep-h { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.topbar-toggle {
    display: flex; align-items: center; gap: 5px;
    cursor: pointer; padding: 4px 8px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 11px; color: var(--dim);
    transition: all 0.2s; white-space: nowrap;
}
.topbar-toggle:hover { color: var(--text); border-color: var(--border-hover); }
.topbar-toggle:has(input:checked) { color: var(--cyan); border-color: var(--cyan); background: var(--cyan-bg); }
.topbar-toggle input { width: 13px; height: 13px; accent-color: var(--cyan); cursor: pointer; margin: 0; }
.topbar-colors {
    display: flex; align-items: center; gap: 3px;
    padding: 3px 5px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius);
}
.topbar-colors .swatch {
    width: 20px; height: 20px; border-radius: 4px;
    border: 2px solid transparent; cursor: pointer;
    transition: all 0.15s; flex-shrink: 0; aspect-ratio: auto;
}
.topbar-colors .swatch:hover { transform: scale(1.15); }
.topbar-colors .swatch.active { border-color: var(--text); box-shadow: 0 0 4px rgba(0,0,0,0.3); }
.topbar-custom-color {
    display: flex; align-items: center; gap: 5px;
    padding: 3px 8px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: var(--radius);
}
.custom-color-icon {
    display: flex; align-items: center; color: var(--dim); cursor: pointer;
}
.topbar-custom-color:hover .custom-color-icon { color: var(--text); }
.custom-color-input {
    width: 26px; height: 22px; border: 1px solid var(--border);
    border-radius: 4px; background: none; cursor: pointer; padding: 0; flex-shrink: 0;
}
.custom-color-input::-webkit-color-swatch-wrapper { padding: 1px; }
.custom-color-input::-webkit-color-swatch { border: none; border-radius: 3px; }
.custom-color-hex {
    font-size: 10px; color: var(--dim); font-family: inherit;
    min-width: 52px; letter-spacing: 0.3px;
}
.topbar-right { display: flex; align-items: center; gap: 4px; }
.top-btn {
    display: flex; align-items: center; gap: 5px;
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--dim); padding: 5px 10px; border-radius: var(--radius);
    font-size: 12px; cursor: pointer; transition: all 0.2s;
    font-family: inherit;
}
.top-btn:hover { color: var(--text); border-color: var(--border-hover); background: var(--cell-hover); }
.top-btn.accent { color: var(--cyan); border-color: var(--cyan-bg); }
.top-btn.accent:hover { border-color: var(--cyan); background: var(--cyan-bg); }

/* ============================================================
   TOOLBAR (Layers Panel)
   ============================================================ */
#toolbar {
    position: fixed; top: calc(var(--nav-h) + var(--topbar-h)); left: 0; bottom: 0;
    width: var(--toolbar-w); z-index: 90;
    display: flex; flex-direction: column;
    padding: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}
#toolbar::-webkit-scrollbar { width: 4px; }
#toolbar::-webkit-scrollbar-track { background: transparent; }
#toolbar::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }

.tool-btn {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid transparent;
    color: var(--dim); border-radius: var(--radius); cursor: pointer;
    transition: all 0.2s; flex-shrink: 0;
}
.tool-btn:hover { color: var(--text); background: var(--purple-bg); border-color: var(--border); }
.tool-btn.active { color: var(--cyan); background: var(--cyan-bg); border-color: var(--cyan); }

.section-label {
    font-size: 9px; color: var(--dim); text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Topbar inline groups */
.topbar-group {
    display: flex; align-items: center; gap: 2px;
}
.topbar-label {
    font-size: 10px; color: var(--dim); white-space: nowrap; margin-right: 2px;
}
.topbar-stroke-slider {
    width: 60px; height: 4px; -webkit-appearance: none; appearance: none;
    background: var(--border); border-radius: 2px; outline: none;
}
.topbar-stroke-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--cyan); cursor: pointer;
}
.topbar-stroke-slider::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--cyan); cursor: pointer; border: none;
}
.topbar-zoom {
    font-size: 10px; color: var(--dim); padding: 0 4px; white-space: nowrap; user-select: none;
}

/* Color swatches */
.color-swatches {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 2px; padding: 0 2px;
}
.swatch {
    width: 100%; aspect-ratio: 1; border-radius: 4px;
    border: 2px solid transparent; cursor: pointer;
    transition: all 0.15s;
}
.swatch:hover { transform: scale(1.15); }
.swatch.active { border-color: var(--text); box-shadow: 0 0 6px rgba(0,0,0,0.2); }
.custom-color {
    width: 100%; height: 20px; border: 1px solid var(--border);
    border-radius: 4px; background: var(--surface); cursor: pointer;
    padding: 0;
}
.custom-color::-webkit-color-swatch-wrapper { padding: 1px; }
.custom-color::-webkit-color-swatch { border: none; border-radius: 3px; }

/* Stroke slider */
.stroke-slider {
    width: 100%; height: 4px; -webkit-appearance: none; appearance: none;
    background: var(--border); border-radius: 2px; outline: none;
}
.stroke-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--cyan); cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.stroke-slider::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--cyan); cursor: pointer; border: none;
}

/* Fill toggle */
.fill-toggle {
    display: flex; align-items: center; gap: 6px;
    cursor: pointer; padding: 2px 0; justify-content: center;
}
.fill-toggle input[type="checkbox"] {
    width: 14px; height: 14px; accent-color: var(--cyan);
    cursor: pointer;
}
.fill-label { font-size: 10px; color: var(--dim); }

/* Zoom display */
/* Kept for backwards compat — now using .topbar-zoom */
.zoom-display {
    font-size: 10px; color: var(--dim); text-align: center;
    padding: 4px 0; user-select: none;
}

/* ============================================================
   LAYERS
   ============================================================ */
.layer-section {
    width: 100%; padding: 0;
    display: flex; flex-direction: column;
    flex: 1; min-height: 0;
}
.layer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px 6px;
}
.layer-header .section-label { font-size: 10px; }
.layer-list {
    display: flex; flex-direction: column; gap: 2px;
    flex: 1; overflow-y: auto;
    padding: 0 6px 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}
.layer-item {
    display: flex; flex-direction: column; gap: 4px;
    padding: 6px; border-radius: 6px;
    cursor: pointer; font-size: 10px; color: var(--dim);
    border: 1px solid transparent;
    transition: all 0.15s;
}
.layer-item:hover { background: var(--purple-bg); }
.layer-item.active { color: var(--cyan); border-color: var(--cyan); background: var(--cyan-bg); }
.layer-item-row {
    display: flex; align-items: center; gap: 4px;
}
.layer-eye {
    width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: inherit; cursor: pointer;
    font-size: 11px; flex-shrink: 0;
    opacity: 0.6;
}
.layer-eye:hover { opacity: 1; }
.layer-eye.hidden-layer { opacity: 0.25; }
.layer-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 10px;
}
.layer-actions {
    display: flex; gap: 1px; flex-shrink: 0;
}
.layer-action-btn {
    width: 16px; height: 16px; display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--dim); cursor: pointer;
    font-size: 9px; border-radius: 2px;
}
.layer-action-btn:hover { color: var(--text); background: var(--cell-hover); }
.layer-preview {
    width: 100%; aspect-ratio: 16/9;
    border-radius: 4px; border: 1px solid var(--border);
    background: var(--surface2);
    image-rendering: auto;
}
.layer-add-btn {
    width: 24px; height: 24px; padding: 0;
    background: var(--surface2);
    border: 1px dashed var(--border); border-radius: 4px;
    color: var(--dim); font-size: 14px; cursor: pointer;
    font-family: inherit; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.layer-add-btn:hover { color: var(--text); border-color: var(--border-hover); }

/* ============================================================
   TOOLBAR RESIZE HANDLE
   ============================================================ */
.toolbar-resize-handle {
    position: absolute; top: 0; right: -3px; bottom: 0; width: 6px;
    cursor: col-resize; z-index: 95;
}
.toolbar-resize-handle::after {
    content: ''; position: absolute; top: 50%; right: 2px;
    width: 2px; height: 24px; border-radius: 1px;
    background: var(--border); transform: translateY(-50%);
    opacity: 0; transition: opacity 0.2s;
}
.toolbar-resize-handle:hover::after { opacity: 1; }

/* ============================================================
   BACKGROUND PICKER
   ============================================================ */
.bg-picker { position: relative; }
.bg-picker-trigger {
    display: flex !important; align-items: center; gap: 5px;
}
.bg-swatch-preview {
    display: inline-block; width: 14px; height: 14px;
    border-radius: 3px; border: 1px solid var(--border);
    flex-shrink: 0;
}
.bg-chevron { transition: transform 0.2s; }
.bg-picker:hover .bg-chevron { transform: rotate(180deg); }
.bg-picker-menu {
    display: none; position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 160px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 200;
}
.bg-picker:hover .bg-picker-menu { display: block; }
.bg-picker-menu::before {
    content: ''; position: absolute; top: -10px; left: 0; right: 0; height: 10px;
}
.bg-option {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 6px 8px; border: none; background: none;
    color: var(--text-secondary); font-size: 12px; font-family: inherit;
    border-radius: 4px; cursor: pointer; transition: all 0.15s;
}
.bg-option:hover { background: var(--cyan-bg); color: var(--cyan); }
.bg-option.active { background: var(--cyan-bg); color: var(--cyan); font-weight: 600; }
.bg-option-swatch {
    width: 18px; height: 18px; border-radius: 4px;
    border: 1px solid var(--border); flex-shrink: 0;
}
.bg-custom-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border-top: 1px solid var(--border); margin-top: 4px;
}
.bg-custom-row label { font-size: 12px; color: var(--dim); }
.bg-custom-row input[type="color"] {
    width: 32px; height: 22px; border: 1px solid var(--border);
    border-radius: 4px; background: none; cursor: pointer; padding: 0;
}

/* ============================================================
   PALETTE PICKER
   ============================================================ */
.palette-picker { position: relative; }
.palette-picker-trigger { display: flex !important; align-items: center; gap: 5px; }
.palette-chevron { transition: transform 0.2s; }
.palette-picker.open .palette-chevron { transform: rotate(180deg); }
.palette-picker-menu {
    display: none; position: absolute; top: calc(100% + 6px); left: 50%;
    transform: translateX(-50%);
    min-width: 220px; max-height: 300px; overflow-y: auto;
    padding: 6px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 200;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}
.palette-picker.open .palette-picker-menu { display: block; }

/* ============================================================
   TOOL DROPDOWN (per-tool size & dash style)
   ============================================================ */
.tool-dropdown {
    position: fixed;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: flex; flex-direction: column; gap: 8px;
    min-width: 190px;
}
.tool-dropdown.hidden { display: none; }
.td-row { display: flex; align-items: center; gap: 8px; }
.td-label {
    font-size: 10px; color: var(--dim); text-transform: uppercase;
    letter-spacing: 0.5px; min-width: 30px;
}
.td-slider {
    flex: 1; height: 4px;
    -webkit-appearance: none; appearance: none;
    background: var(--border); border-radius: 2px; outline: none;
}
.td-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--cyan); cursor: pointer;
    box-shadow: 0 0 4px rgba(0,229,255,0.3);
}
.td-slider::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--cyan); cursor: pointer; border: none;
}
.td-val {
    font-size: 11px; color: var(--text);
    min-width: 28px; text-align: right;
}
.td-styles { display: flex; gap: 4px; }
.td-style-btn {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 28px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 4px; color: var(--dim);
    cursor: pointer; transition: all 0.15s;
}
.td-style-btn:hover { color: var(--text); border-color: var(--border-hover); }
.td-style-btn.active { color: var(--cyan); border-color: var(--cyan); background: var(--cyan-bg); }

.palette-option {
    display: flex; flex-direction: column; gap: 4px;
    width: 100%; padding: 6px 8px;
    border: none; background: none; color: var(--text-secondary);
    font-size: 11px; font-family: inherit;
    border-radius: 4px; cursor: pointer; transition: all 0.15s;
    text-align: left;
}
.palette-option:hover { background: var(--cyan-bg); color: var(--cyan); }
.palette-option-name { font-weight: 500; }
.palette-option-colors { display: flex; gap: 2px; flex-wrap: wrap; }
.palette-dot {
    width: 14px; height: 14px; border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.1); flex-shrink: 0;
}
.palette-empty {
    padding: 12px 8px; color: var(--dim); font-size: 10px;
    text-align: center; line-height: 1.4;
}

/* ============================================================
   CANVAS
   ============================================================ */
#canvas {
    position: fixed;
    top: calc(var(--nav-h) + var(--topbar-h) + 1px);
    left: var(--toolbar-w);
    right: 0; bottom: 0;
    display: block;
    cursor: default;
    background: var(--bg);
}
body.tool-pan #canvas,
body.panning #canvas { cursor: grab; }
body.panning #canvas { cursor: grabbing; }
body.tool-pencil #canvas,
body.tool-eraser #canvas { cursor: crosshair; }
body.tool-line #canvas,
body.tool-rect #canvas,
body.tool-circle #canvas { cursor: crosshair; }
body.tool-text #canvas { cursor: text; }
body.tool-bucket #canvas { cursor: crosshair; }
body.tool-bgremove #canvas { cursor: crosshair; }

/* ============================================================
   TEXT EDITOR OVERLAY
   ============================================================ */
.text-editor {
    position: fixed; display: none;
    background: var(--surface);
    border: 1px solid var(--cyan);
    color: var(--text);
    font-family: inherit;
    font-size: 16px;
    padding: 4px 6px;
    resize: none;
    outline: none;
    border-radius: 4px;
    min-width: 100px; min-height: 30px;
    z-index: 200;
    box-shadow: var(--shadow-md);
}

/* ============================================================
   MODALS (base styles in theme.css)
   ============================================================ */
.modal-btn {
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--dim); padding: 6px 14px; border-radius: var(--radius);
    font-size: 12px; cursor: pointer; transition: all 0.2s;
    font-family: inherit;
}
.modal-btn:hover { color: var(--text); border-color: var(--border-hover); }
.modal-btn.accent { color: var(--cyan); border-color: var(--cyan); }
.modal-btn.accent:hover { background: var(--cyan-bg); }

/* Project list in modal */
.project-list { display: flex; flex-direction: column; gap: 4px; }
.project-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-radius: var(--radius);
    background: var(--surface2); border: 1px solid var(--border);
    cursor: pointer; transition: all 0.2s;
}
.project-item:hover { border-color: var(--border-hover); background: var(--purple-bg); }
.project-item-name { font-size: 13px; font-weight: 500; }
.project-item-date { font-size: 10px; color: var(--dim); }
.project-item-actions { display: flex; gap: 6px; }
.project-item-btn {
    background: none; border: none; color: var(--dim);
    cursor: pointer; font-size: 11px; padding: 2px 4px;
    border-radius: 4px; transition: all 0.15s;
}
.project-item-btn:hover { color: var(--text); background: var(--cell-hover); }
.project-item-btn.delete:hover { color: var(--pink); }
.project-empty {
    text-align: center; color: var(--dim); font-size: 12px; padding: 20px;
}

/* ============================================================
   SCRATCH PAD
   ============================================================ */
.scratch-bar {
    position: fixed;
    top: calc(var(--nav-h) + var(--topbar-h) + 10px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--cyan);
    border-radius: 20px;
    z-index: 100;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 229, 255, 0.15);
}
.scratch-bar.hidden { display: none; }
.scratch-bar-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--cyan);
    letter-spacing: 1px;
    white-space: nowrap;
}
.scratch-bar-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--dim);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}
.scratch-bar-btn:hover {
    color: var(--text);
    border-color: var(--border-hover);
}
.scratch-bar-btn.scratch-exit {
    color: var(--pink);
    border-color: var(--pink);
}
.scratch-bar-btn.scratch-exit:hover {
    background: rgba(255, 45, 149, 0.15);
}
.scratch-bar-select {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 3px 6px;
    border-radius: 12px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}
.scratch-bar-select:hover { border-color: var(--border-hover); }
body.scratch-active #canvas { cursor: crosshair !important; }

/* ============================================================
   RESPONSIVE — tablet and smaller (<=768px)
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --toolbar-w: 0px;
        --topbar-h: 36px;
    }

    /* --- Layers panel → bottom drawer --- */
    #toolbar {
        top: auto; left: 0; right: 0; bottom: 0;
        width: 100%; height: auto;
        max-height: 40vh;
        flex-direction: column;
        padding: 0;
        border-right: none;
        border-top: 1px solid var(--border);
    }
    .toolbar-resize-handle { display: none; }
    .layer-header { padding: 6px 8px 4px; }
    .layer-list { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 0 8px 6px; gap: 4px; }
    .layer-item { flex-direction: row; min-width: 80px; flex-shrink: 0; padding: 4px; gap: 4px; }
    .layer-preview { width: 40px; aspect-ratio: 1; flex-shrink: 0; }
    .layer-add-btn { width: 24px; height: 24px; }

    /* Topbar compact */
    #topbar { padding: 0 6px; }
    .topbar-group { gap: 1px; }
    .topbar-label { display: none; }
    .topbar-stroke-slider { width: 40px; }
    .topbar-zoom { display: none; }
    .top-btn span { display: none; }
    .top-btn { padding: 5px 7px; gap: 0; }
    .project-name { font-size: 12px; width: 100px; }
    .save-status { font-size: 10px; }
    .topbar-left { gap: 6px; }
    .topbar-center { gap: 3px; }
    .topbar-right { gap: 2px; }

    .bg-picker-trigger span:not(.bg-swatch-preview):not(.bg-chevron) { display: none; }
    .bg-picker-menu { left: auto; right: 0; min-width: 140px; }

    /* Canvas */
    #canvas { left: 0; bottom: 52px; }

    /* Modals */
    .modal { min-width: 0; width: calc(100vw - 24px); max-width: calc(100vw - 24px); }
    .modal-header { padding: 12px 14px; }
    .modal-header h2 { font-size: 14px; }
    .modal-body { padding: 12px 14px; }
    .modal-footer { padding: 10px 14px; }
}
