/* ═══════════════════════════════════════════
   MuralStyle.css — PixAid · Mobile-First
   ═══════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

:root {
    --bg:         #FFEDDF;
    --panel:      #fff8f2;
    --card:       #ffffff;
    --border:     #ffc2db;
    --accent:     #F85898;
    --accent2:    #ffc2db;
    --neon:       #F85898;
    --gold:       #ffd700;
    --text:       #1a1a1a;
    --muted:      #6b7280;
    --danger:     #ef4444;
    --success:    #22c55e;
    --hot:        #ff00aa;
    --pixel-font: 'Press Start 2P', monospace;
    --px-font:    'Courier New', monospace;
    --bottom-nav: 68px;
}

html, body {
    font-family: 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ══════════════════════════════════════════
   LOAD OVERLAY
══════════════════════════════════════════ */
#loadOverlay {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 9999;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 18px;
}
#loadOverlay.hidden { display: none; }

.load-spinner {
    width: 44px; height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════
   MAIN LAYOUT
══════════════════════════════════════════ */
.editor-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

/* ── Sidebars: hidden on mobile ── */
.sidebar-left,
.sidebar-right {
    display: none;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    background: var(--panel);
}
.sidebar-left::-webkit-scrollbar,
.sidebar-right::-webkit-scrollbar { width: 3px; }
.sidebar-left::-webkit-scrollbar-thumb,
.sidebar-right::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.sidebar-left  { width: 210px; border-right: 2px solid var(--border); }
.sidebar-right { width: 190px; border-left:  2px solid var(--border); }

.sidebar-section {
    padding: 10px;
    border-bottom: 1.5px solid var(--border);
}
.sidebar-section:last-child { border-bottom: none; }

.section-title {
    font-family: var(--pixel-font);
    font-size: 7px; letter-spacing: 1px;
    color: var(--muted);
    padding: 2px 0 8px;
    display: flex; align-items: center; gap: 6px;
}
.section-title i { color: var(--accent); }

/* ══════════════════════════════════════════
   CANVAS AREA
══════════════════════════════════════════ */
.canvas-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f0e8ff;
    background-image:
        linear-gradient(rgba(248,88,152,.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(248,88,152,.07) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: auto;
    position: relative;
    /* bottom padding for the nav bar on mobile */
    padding-bottom: var(--bottom-nav);
}
.canvas-area::-webkit-scrollbar { width: 4px; height: 4px; }
.canvas-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.pixel-canvas-wrap {
    position: relative;
    border: 2.5px solid #000;
    border-radius: 4px;
    box-shadow: 4px 4px 0 #000;
    cursor: crosshair;
    touch-action: none;
}
.pixel-canvas-wrap canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
#overlayHighlights {
    position: absolute; top: 0; left: 0;
    pointer-events: none;
}

/* ── Zoom controls (floating) ── */
.zoom-controls {
    position: fixed;
    bottom: calc(var(--bottom-nav) + 12px);
    left: 50%;
    transform: translateX(-50%);
    display: flex; align-items: center; gap: 6px;
    background: var(--card);
    border: 2px solid #000;
    border-radius: 10px;
    padding: 6px 10px;
    box-shadow: 3px 3px 0 #000;
    z-index: 50;
}
.zoom-btn {
    width: 32px; height: 32px;
    border-radius: 6px;
    border: 1.5px solid var(--border);
    background: var(--bg);
    color: var(--text);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 13px;
    transition: all .15s; font-family: inherit;
}
.zoom-btn:hover, .zoom-btn:active {
    background: var(--accent); border-color: var(--accent); color: #fff;
}
.zoom-level {
    font-family: var(--pixel-font); font-size: 9px;
    color: var(--text); min-width: 44px; text-align: center;
}

/* ── Coords display ── */
.coords-display {
    position: fixed;
    bottom: calc(var(--bottom-nav) + 12px);
    right: 12px;
    font-family: var(--pixel-font); font-size: 8px;
    color: var(--muted);
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 5px 9px;
    z-index: 50;
}
.coords-display span { color: var(--accent); }

/* ══════════════════════════════════════════
   BOTTOM NAV (mobile)
══════════════════════════════════════════ */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav);
    background: var(--bg);
    border-top: 2.5px solid #000;
    display: flex;
    z-index: 200;
}
.bottom-nav-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    border-right: 1.5px solid #000;
    cursor: pointer;
    font-family: var(--pixel-font);
    font-size: 6px;
    color: var(--muted);
    padding: 6px 4px;
    transition: background .15s, color .15s;
    position: relative;
}
.bottom-nav-btn:last-child { border-right: none; }
.bottom-nav-btn i { font-size: 18px; transition: color .15s; }
.bottom-nav-btn.active {
    background: rgba(248,88,152,.08);
    color: var(--accent);
}
.bottom-nav-btn.active i { color: var(--accent); }
.bottom-nav-btn:active { background: rgba(248,88,152,.15); }

/* Color indicator dot on color tab */
.color-dot-indicator {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid #000;
    box-shadow: 1px 1px 0 #000;
    margin-bottom: 2px;
    transition: background .15s;
}

/* ══════════════════════════════════════════
   BOTTOM SHEETS
══════════════════════════════════════════ */
.bottom-sheet {
    position: fixed;
    bottom: var(--bottom-nav);
    left: 0; right: 0;
    background: var(--bg);
    border-top: 2.5px solid #000;
    box-shadow: 0 -4px 0 rgba(0,0,0,.08);
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.34,1.4,.64,1);
    z-index: 150;
    max-height: 55vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
}
.bottom-sheet.open { transform: translateY(0); }
.bottom-sheet::-webkit-scrollbar { width: 3px; }
.bottom-sheet::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* Sheet handle */
.sheet-handle {
    width: 40px; height: 4px;
    background: #000;
    border-radius: 99px;
    margin: 10px auto 0;
    opacity: .2;
}

.sheet-body { padding: 12px 16px 16px; }

/* ── Sheet: Color ── */
.sheet-color-current {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    background: var(--card);
    border: 2px solid #000;
    border-radius: 10px;
    box-shadow: 3px 3px 0 #000;
    margin-bottom: 12px;
}
.sheet-color-preview {
    width: 44px; height: 44px;
    border-radius: 8px;
    border: 2px solid #000;
    flex-shrink: 0;
}
.sheet-color-hex {
    font-family: var(--pixel-font); font-size: 11px;
    color: var(--accent); font-weight: 700;
}
.sheet-color-label { font-size: 10px; color: var(--muted); margin-bottom: 3px; }

/* Big color grid for mobile */
.color-grid-mobile {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 7px;
    margin-bottom: 12px;
}
.color-swatch-mobile {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid #000;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s;
    box-shadow: 2px 2px 0 #000;
}
.color-swatch-mobile:active { transform: scale(.9); }
.color-swatch-mobile.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent), 2px 2px 0 #000;
    transform: scale(1.08);
}
/* Also used by buildPaletteFromGuia */
.color-palette { display: grid; grid-template-columns: repeat(5,1fr); gap: 5px; }
.color-swatch {
    aspect-ratio: 1; border-radius: 6px;
    border: 2px solid transparent; cursor: pointer;
    transition: transform .12s, box-shadow .12s;
}
.color-swatch:hover    { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--accent); box-shadow: 0 0 6px rgba(248,88,152,.5); transform: scale(1.1); }

.custom-color-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 8px;
}
.custom-color-row label { font-family: var(--pixel-font); font-size: 7px; color: var(--muted); white-space: nowrap; }
.custom-color-row input[type="color"] {
    flex: 1; height: 36px;
    border: 1.5px solid var(--border); border-radius: 6px;
    cursor: pointer; background: none; padding: 2px;
}

/* ── Sheet: Tools ── */
.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.tool-card {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 7px;
    padding: 14px 10px;
    background: var(--card);
    border: 2px solid #000;
    border-radius: 10px;
    box-shadow: 3px 3px 0 #000;
    cursor: pointer;
    font-family: var(--pixel-font); font-size: 7px;
    color: var(--text);
    transition: transform .12s, box-shadow .12s, background .15s;
}
.tool-card i { font-size: 22px; color: var(--accent); }
.tool-card:active { transform: translateY(2px); box-shadow: 1px 1px 0 #000; }
.tool-card.active {
    background: rgba(248,88,152,.1);
    border-color: var(--accent);
    color: var(--accent);
}
.tool-card.active i { color: var(--hot); }
.tool-card .tool-cost {
    font-size: 8px; color: #92400e; font-weight: 700;
    display: flex; align-items: center; gap: 4px;
}

/* Pixel coins widget in sheet */
.pc-widget {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    background: rgba(255,215,0,.08);
    border: 2px solid rgba(255,215,0,.4);
    border-radius: 10px;
    box-shadow: 2px 2px 0 rgba(0,0,0,.08);
}
.pc-icon { font-size: 28px; color: var(--gold); flex-shrink: 0; }
.pc-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 2px; }
.pc-amount {
    font-family: var(--pixel-font); font-size: 22px; font-weight: 900;
    color: #92400e; line-height: 1;
    transition: transform .2s, color .2s;
}
.pc-amount.bump { transform: scale(1.18); color: var(--accent); }

/* ── Sheet: Preview ── */
.mini-preview {
    width: 100%; aspect-ratio: 1;
    background: #f5f0fa;
    border: 2px solid #000;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 3px 3px 0 #000;
    image-rendering: pixelated;
    margin-bottom: 12px;
}
.mini-preview canvas { width: 100%; height: 100%; image-rendering: pixelated; }

/* ── Online users ── */
.online-list { display: flex; flex-direction: column; gap: 5px; }
.online-user {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 10px;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 8px; font-size: 12px;
}
.online-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--success); box-shadow: 0 0 5px var(--success); flex-shrink: 0;
}
.online-count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent); color: #fff;
    font-family: var(--pixel-font); font-size: 7px;
    width: 20px; height: 20px; border-radius: 50%;
    border: 1.5px solid #000; margin-left: 6px;
}

/* ── Sheet: Stats / Info ── */
.stats-info-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.stat-info-card {
    padding: 10px 12px;
    background: var(--card);
    border: 2px solid #000;
    border-radius: 8px;
    box-shadow: 2px 2px 0 #000;
}
.stat-info-label { font-family: var(--pixel-font); font-size: 6.5px; color: var(--muted); margin-bottom: 5px; }
.stat-info-val   { font-family: var(--px-font); font-size: 18px; font-weight: 900; color: var(--accent); }
.stat-info-val.green { color: var(--success); }
.stat-info-val.gold  { color: #92400e; }

/* Guide upload */
.guide-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.guide-btn {
    padding: 10px; border-radius: 8px;
    border: 2px solid #000; background: var(--card);
    font-family: var(--pixel-font); font-size: 7px;
    cursor: pointer; box-shadow: 2px 2px 0 #000;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    color: var(--text); transition: transform .12s, box-shadow .12s;
}
.guide-btn:active { transform: translateY(1px); box-shadow: 0 0 0 #000; }
.guide-btn.danger { color: var(--danger); border-color: var(--danger); box-shadow: 2px 2px 0 var(--danger); }

/* ══════════════════════════════════════════
   TOOL BUTTONS — sidebar (desktop only)
══════════════════════════════════════════ */
.tool-btn {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 10px; border-radius: 8px;
    border: 1.5px solid transparent;
    background: var(--card); color: var(--text);
    cursor: pointer; font-size: 11px; font-weight: 600;
    transition: all .15s; width: 100%; text-align: left;
    margin-bottom: 3px; font-family: inherit;
}
.tool-btn i { width: 16px; text-align: center; color: var(--accent); }
.tool-btn:hover, .tool-btn.active { border-color: var(--accent); background: rgba(248,88,152,.1); }
.tool-btn.active { box-shadow: 0 0 0 1px rgba(248,88,152,.3); }

.current-color-display {
    display: flex; align-items: center; gap: 8px;
    padding: 8px; background: rgba(248,88,152,.04);
    border-radius: 8px; border: 1.5px solid var(--border);
    margin-bottom: 6px;
}
.current-color-preview {
    width: 32px; height: 32px;
    border-radius: 6px; border: 2px solid var(--border); flex-shrink: 0;
}
.current-color-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.current-color-hex   { font-family: var(--pixel-font); font-size: 11px; font-weight: 700; color: var(--accent); }
.color-custom { display: flex; align-items: center; gap: 8px; padding: 6px 2px; margin-top: 2px; }
.color-custom label { font-size: 10px; color: var(--muted); white-space: nowrap; }
.color-custom input[type="color"] { flex: 1; height: 28px; border: 1.5px solid var(--border); border-radius: 5px; cursor: pointer; background: none; padding: 1px; }

/* ══════════════════════════════════════════
   STATUSBAR
══════════════════════════════════════════ */
.statusbar {
    background: var(--bg);
    border-top: 2px solid var(--border);
    padding: 4px 14px;
    display: none; /* hidden on mobile — info is in sheet */
    align-items: center; gap: 16px;
    font-size: 10px; color: var(--muted);
    flex-shrink: 0; font-family: var(--px-font); font-weight: 700;
    position: relative;
}
.statusbar::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, transparent 5%, var(--hot) 35%, var(--accent) 65%, transparent 95%);
}
.statusbar > div { display: flex; align-items: center; gap: 4px; }
.statusbar span { color: var(--text); font-weight: 700; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: var(--success); box-shadow: 0 0 4px var(--success); }
.dot-gold  { background: var(--accent);  box-shadow: 0 0 4px rgba(248,88,152,.5); }

/* ══════════════════════════════════════════
   PIXEL TOOLTIP
══════════════════════════════════════════ */
#pixelTooltip {
    position: fixed;
    background: var(--card);
    border: 2px solid #000;
    border-radius: 10px;
    padding: 10px 13px;
    font-size: 11px;
    z-index: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    min-width: 140px;
    box-shadow: 3px 3px 0 #000;
}
#pixelTooltip.show { opacity: 1; }
.tooltip-row { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.tooltip-row:last-child { margin-bottom: 0; }
.tooltip-color { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); flex-shrink: 0; }
.tooltip-label { color: var(--muted); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; }
.tooltip-val   { color: var(--text); font-weight: 700; }

/* ══════════════════════════════════════════
   MODAL (perfil) — se usa en x:MenuComun
══════════════════════════════════════════ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(60,10,10,.45);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity .22s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: #FFEDDF;
    border: 2.5px solid #000;
    border-radius: 12px;
    width: 100%; max-width: 400px;
    box-shadow: 5px 5px 0 #000;
    overflow: hidden;
    transform: translateY(16px) scale(.97);
    transition: transform .26s cubic-bezier(.34,1.56,.64,1);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header {
    position: relative;
    padding: 13px 16px 28px;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--accent); overflow: hidden;
}
.modal-header::after {
    content: ''; position: absolute;
    bottom: 0; left: 0; right: 0; height: 16px;
    background-image: repeating-conic-gradient(var(--accent) 0% 25%, #FFEDDF 0% 50%);
    background-size: 16px 16px; pointer-events: none;
}
.modal-header span {
    font-family: var(--pixel-font); font-size: 9px; color: #fff;
    letter-spacing: .5px; position: relative; z-index: 1;
    text-shadow: 2px 2px 0 rgba(0,0,0,.3);
}
.modal-header i { color: #fff; }
.modal-close {
    width: 26px; height: 26px; border-radius: 5px;
    border: 2px solid rgba(255,255,255,.5);
    background: rgba(255,255,255,.15);
    color: #fff; font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    position: relative; z-index: 1; transition: all .15s;
}
.modal-close:hover { background: rgba(239,68,68,.65); border-color: #fff; }
.modal-body {
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 12px;
    max-height: 75vh; overflow-y: auto;
    background: #FFEDDF;
}

/* ══════════════════════════════════════════
   TOAST
══════════════════════════════════════════ */
.toast {
    position: fixed;
    top: 90px; right: 14px;
    background: var(--card);
    border: 2px solid #000;
    border-radius: 10px;
    padding: 10px 14px;
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; font-weight: 700;
    color: var(--success);
    box-shadow: 3px 3px 0 #000;
    transform: translateX(120%);
    transition: transform .3s cubic-bezier(.34,1.56,.64,1);
    z-index: 2000; max-width: 260px;
}
.toast.show  { transform: translateX(0); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.warn  { border-color: var(--gold);  color: #92400e; }

/* ══════════════════════════════════════════
   DESKTOP — ≥ 768px
══════════════════════════════════════════ */
@media (min-width: 768px) {

    :root { --bottom-nav: 0px; }

    .sidebar-left, .sidebar-right { display: flex; }
    .bottom-nav   { display: none; }
    .bottom-sheet { display: none !important; }
    .statusbar    { display: flex; }

    .canvas-area { padding-bottom: 0; }
    .zoom-controls {
        position: absolute;
        bottom: 16px; left: 50%;
        transform: translateX(-50%);
    }
    .coords-display {
        position: absolute;
        bottom: 16px; right: 16px;
    }
}

/* ══════════════════════════════════════════
   MISC UTILS
══════════════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: 7px;
    font-family: var(--pixel-font); font-size: 7.5px; letter-spacing: .5px;
    cursor: pointer; border: 2px solid #000;
    background: var(--card); color: var(--accent);
    box-shadow: 3px 3px 0 #000;
    transition: transform .12s, box-shadow .12s; text-decoration: none;
}
.btn:hover  { transform: translateY(-1px); box-shadow: 3px 4px 0 #000; }
.btn:active { transform: translateY(1px);  box-shadow: 1px 1px 0 #000; }

/* Pixel highlight dots (guia) */
.pixel-highlight {
    position: absolute;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}