/* ==========================================================================
   AskiPaint 3.0 Plus — Dedicated Editor Stylesheet
   ========================================================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #8b5cf6;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-toolbar: #1e293b;
    --border-color: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
}

body.light-mode {
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-toolbar: #ffffff;
    --border-color: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #64748b;
}

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

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

/* ================= TOP HEADER ================= */
.editor-header {
    height: 52px;
    background: var(--bg-toolbar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    user-select: none;
    flex-shrink: 0;
    z-index: 50;
}

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

.brand-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 700;
    font-size: 16px;
}

.brand-badge img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.version-pill {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

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

.nav-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    transition: all 0.15s ease;
    cursor: pointer;
}

.nav-pill-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #64748b;
    transform: translateY(-1px);
}

.nav-pill-btn.primary-pill {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    border: none;
    color: white;
}

.nav-pill-btn.primary-pill:hover {
    background: linear-gradient(135deg, #1d4ed8, #6d28d9);
}

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

.action-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    transition: all 0.15s ease;
}

.action-tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #64748b;
}

.action-tool-btn.btn-save {
    background: #10b981;
    color: white;
    border: none;
}
.action-tool-btn.btn-save:hover {
    background: #059669;
}

.action-tool-btn.btn-export {
    background: #3b82f6;
    color: white;
    border: none;
}
.action-tool-btn.btn-export:hover {
    background: #2563eb;
}

/* ================= 3.0 FONTS & CANVAS RIBBON ================= */
.editor-ribbon {
    background: #1e293b;
    border-bottom: 1px solid var(--border-color);
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    user-select: none;
    flex-shrink: 0;
    z-index: 40;
}

body.light-mode .editor-ribbon {
    background: #f8fafc;
    border-bottom-color: #e2e8f0;
}

.ribbon-section {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.ribbon-section:not(:last-child)::after {
    content: '';
    display: block;
    width: 1px;
    height: 22px;
    background: var(--border-color);
    margin-left: 8px;
}

.ribbon-tag {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.ribbon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
}

.ribbon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.ribbon-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.ribbon-select {
    padding: 4px 8px;
    font-size: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 5px;
    outline: none;
    cursor: pointer;
}

.ribbon-slider-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--text-muted);
}

.ribbon-slider-wrap input[type="range"] {
    width: 70px;
    cursor: pointer;
}

.color-picker-mini {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    background: transparent;
}

/* ================= MAIN WORKSPACE ================= */
.editor-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* LEFT TOOLBAR */
.editor-sidebar {
    width: 210px;
    background: var(--bg-toolbar);
    border-right: 1px solid var(--border-color);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    user-select: none;
    flex-shrink: 0;
}

.tool-group-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.tool-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.sidebar-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sidebar-tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-tool-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.sidebar-tool-btn.full-width {
    grid-column: span 2;
    flex-direction: row;
    padding: 8px 10px;
    gap: 8px;
}

.color-swatches-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-top: 6px;
}

.swatch-color {
    aspect-ratio: 1;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.2);
    transition: transform 0.1s;
}

.swatch-color:hover {
    transform: scale(1.15);
}

/* CANVAS VIEWPORT */
.canvas-viewport {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #090d16;
    padding: 30px;
    position: relative;
}

body.light-mode .canvas-viewport {
    background: #cbd5e1;
}

.canvas-container {
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    background: #ffffff;
    user-select: none;
    line-height: 0;
}

#paintCanvas {
    display: block;
    background: #ffffff;
    cursor: crosshair;
    touch-action: none;
}

canvas {
    touch-action: none;
}

#paintCanvas[style*="grab"] {
    cursor: grab;
}

#paintCanvas[style*="grabbing"] {
    cursor: grabbing;
}

#traceOverlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    display: block;
}

.crop-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    cursor: crosshair;
    background: rgba(0, 0, 0, 0.38);
}

.crop-overlay[hidden],
.crop-controls[hidden] {
    display: none !important;
}

.crop-selection {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #fff;
    background: transparent;
    box-shadow: 0 0 0 99999px rgba(0, 0, 0, 0.48);
    cursor: move;
    touch-action: none;
}

.crop-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    margin: -6px;
    border: 2px solid #2563eb;
    border-radius: 50%;
    background: #fff;
    box-sizing: border-box;
    touch-action: none;
}
.crop-handle.nw { left: 0; top: 0; cursor: nwse-resize; }
.crop-handle.n { left: 50%; top: 0; cursor: ns-resize; }
.crop-handle.ne { right: 0; top: 0; cursor: nesw-resize; }
.crop-handle.e { right: 0; top: 50%; cursor: ew-resize; }
.crop-handle.se { right: 0; bottom: 0; cursor: nwse-resize; }
.crop-handle.s { left: 50%; bottom: 0; cursor: ns-resize; }
.crop-handle.sw { left: 0; bottom: 0; cursor: nesw-resize; }
.crop-handle.w { left: 0; top: 50%; cursor: ew-resize; }

.crop-controls {
    position: fixed;
    left: 50%;
    bottom: 46px;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 12px 35px rgba(0,0,0,.45);
    white-space: nowrap;
}
.crop-controls-title { font-weight: 700; font-size: 13px; margin-right: 2px; }
.crop-controls label { font-size: 11px; color: var(--text-muted); }
.crop-size-label { min-width: 82px; font-size: 11px; color: var(--text-muted); text-align: center; }

/* BOTTOM STATUS BAR */
.editor-status-bar {
    height: 30px;
    background: var(--bg-toolbar);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 11.5px;
    color: var(--text-muted);
    user-select: none;
    flex-shrink: 0;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ================= MODALS ================= */
.modal-overlay {
    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: 1000;
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 520px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    color: var(--text-main);
}

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

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.modal-close-btn:hover {
    color: var(--text-main);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group-row {
    display: flex;
    gap: 12px;
}

.form-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-field input, .form-field select {
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
}

.preset-buttons-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.preset-btn {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.preset-btn:hover {
    background: rgba(255,255,255,0.12);
    border-color: #3b82f6;
}

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