/* ============================================================
   EDITOR v3 — Styles
   ============================================================ */
:root {
    --ed-bg: #1a1a2e;
    --ed-surface: #252540;
    --ed-border: #333355;
    --ed-text: #ddd;
    --ed-accent: #7c5cfc;
    --ed-accent2: #9b7fff;
    --ed-danger: #ff4d6a;
    --ed-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ================================================================
   TOGGLE BUTTON
   ================================================================ */
#ed-toggle {
    position: fixed; top: 12px; right: 12px; z-index: 9999999;
    background: var(--ed-accent); color: #fff; border: none;
    padding: 10px 20px; border-radius: 24px;
    font: 600 14px var(--ed-font); cursor: pointer;
    box-shadow: 0 4px 20px rgba(124,92,252,0.5);
    transition: 0.2s;
}
#ed-toggle:hover { background: var(--ed-accent2); transform: scale(1.05); }

/* ================================================================
   PANEL
   ================================================================ */
#ed-panel {
    position: fixed; top: 0; right: -340px;
    width: 310px; height: 100vh;
    background: var(--ed-bg); z-index: 9999998;
    box-shadow: -4px 0 30px rgba(0,0,0,0.6);
    transition: right 0.3s ease;
    display: flex; flex-direction: column;
    font: 13px var(--ed-font); color: var(--ed-text);
}
#ed-panel.open { right: 0; }
#ed-panel.collapsed { right: -270px; }

/* Tab on left side to collapse/expand */
#ed-panel-tab {
    position: absolute; left: -34px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 60px; background: var(--ed-bg);
    border: 1px solid var(--ed-border); border-right: none;
    border-radius: 8px 0 0 8px;
    display: none; align-items: center; justify-content: center;
    font-size: 14px; color: var(--ed-text); cursor: pointer;
    box-shadow: -3px 0 10px rgba(0,0,0,0.4);
}
#ed-panel-tab:hover { background: var(--ed-surface); color: #fff; }
#ed-panel.open #ed-panel-tab { display: flex; }

/* Header */
.ed-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--ed-border); flex-shrink: 0;
}
.ed-header span { font-weight: 700; font-size: 14px; color: #fff; }
.ed-btn-exit {
    background: var(--ed-danger); color: #fff; border: none;
    padding: 6px 14px; border-radius: 14px; font: 600 12px var(--ed-font);
    cursor: pointer; transition: 0.2s;
}
.ed-btn-exit:hover { opacity: 0.85; }

/* Body */
.ed-body { flex: 1; overflow-y: auto; padding: 8px 12px; }
.ed-body::-webkit-scrollbar { width: 5px; }
.ed-body::-webkit-scrollbar-thumb { background: var(--ed-border); border-radius: 3px; }

/* ================================================================
   SECTIONS
   ================================================================ */
.ed-sec { margin-bottom: 10px; border-bottom: 1px solid var(--ed-border); padding-bottom: 8px; }
.ed-sec:last-child { border-bottom: none; }

.ed-sec-title {
    font: 700 11px var(--ed-font); text-transform: uppercase; letter-spacing: 0.5px;
    color: #888; cursor: pointer; padding: 4px 0; user-select: none;
}
.ed-sec-title:hover { color: var(--ed-accent); }

.ed-sec-content { margin-top: 6px; }

/* ================================================================
   VIEWPORT
   ================================================================ */
.vp-row { display: flex; gap: 4px; background: var(--ed-surface); padding: 3px; border-radius: 6px; }
.vp-btn {
    flex: 1; padding: 7px; font: 500 12px var(--ed-font);
    border: none; background: transparent; color: var(--ed-text);
    border-radius: 4px; cursor: pointer; transition: 0.15s;
}
.vp-btn.active { background: var(--ed-accent); color: #fff; }
.vp-btn:hover:not(.active) { background: rgba(255,255,255,0.05); }

/* ================================================================
   BUTTONS
   ================================================================ */
.ed-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.ed-btn {
    padding: 7px 10px; font: 500 12px var(--ed-font);
    background: var(--ed-surface); border: 1px solid var(--ed-border);
    color: var(--ed-text); border-radius: 6px; cursor: pointer; transition: 0.15s;
}
.ed-btn:hover { background: var(--ed-accent); color: #fff; border-color: var(--ed-accent); }
.ed-danger { color: var(--ed-danger) !important; border-color: rgba(255,77,106,0.3) !important; }
.ed-danger:hover { background: var(--ed-danger) !important; color: #fff !important; }
.ed-full { grid-column: 1 / -1; margin-top: 4px; }

.ed-btn-sm {
    padding: 4px 10px; font: 500 12px var(--ed-font);
    background: var(--ed-surface); border: 1px solid var(--ed-border);
    color: var(--ed-text); border-radius: 4px; cursor: pointer;
}
.ed-btn-sm:hover { background: var(--ed-accent); color: #fff; }

/* ================================================================
   PROPERTIES
   ================================================================ */
.ed-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.ed-row label { font-size: 11px; color: #777; width: 42px; flex-shrink: 0; }
.ed-row input[type="number"] {
    flex: 1; background: var(--ed-surface); border: 1px solid var(--ed-border);
    color: var(--ed-text); padding: 5px 6px; border-radius: 4px; font-size: 12px;
}
.ed-row input[type="number"]:focus { border-color: var(--ed-accent); outline: none; }
.ed-row input[type="range"] {
    flex: 1; -webkit-appearance: none; height: 4px;
    background: var(--ed-surface); border-radius: 2px; outline: none;
}
.ed-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 14px; height: 14px;
    border-radius: 50%; background: var(--ed-accent); cursor: grab;
}
.ed-row span { font-size: 10px; color: #666; min-width: 32px; text-align: right; }

.ed-layer-row { display: flex; gap: 4px; margin: 6px 0; }

/* ================================================================
   ASSETS
   ================================================================ */
.ed-hint { font-size: 11px; color: #555; margin: 0 0 6px; }
#ed-assets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.ed-asset-thumb {
    width: 100%; aspect-ratio: 1; object-fit: contain;
    background: var(--ed-surface); border: 1px solid var(--ed-border);
    border-radius: 6px; padding: 4px; cursor: pointer; transition: 0.15s;
}
.ed-asset-thumb:hover { border-color: var(--ed-accent); transform: scale(1.06); }

/* ================================================================
   SELECTION HANDLES
   ================================================================ */
#ed-handles {
    position: fixed; pointer-events: none; z-index: 9999990;
    border: 2px solid var(--ed-accent); border-radius: 1px;
}
.ed-h {
    position: absolute; pointer-events: auto;
    background: #fff; border: 2px solid var(--ed-accent);
}
.ed-h-tl, .ed-h-tr, .ed-h-bl, .ed-h-br { width: 10px; height: 10px; border-radius: 2px; }
.ed-h-t, .ed-h-r, .ed-h-b, .ed-h-l { width: 8px; height: 8px; border-radius: 2px; }
.ed-h-tl { top: -6px; left: -6px; cursor: nwse-resize; }
.ed-h-tr { top: -6px; right: -6px; cursor: nesw-resize; }
.ed-h-bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.ed-h-br { bottom: -6px; right: -6px; cursor: nwse-resize; }
.ed-h-t { top: -5px; left: 50%; margin-left: -4px; cursor: ns-resize; }
.ed-h-b { bottom: -5px; left: 50%; margin-left: -4px; cursor: ns-resize; }
.ed-h-l { left: -5px; top: 50%; margin-top: -4px; cursor: ew-resize; }
.ed-h-r { right: -5px; top: 50%; margin-top: -4px; cursor: ew-resize; }
.ed-h-rot {
    position: absolute; top: -36px; left: 50%; margin-left: -11px;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--ed-accent); border: 2px solid #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: #fff; cursor: grab;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.ed-h-rot:active { cursor: grabbing; }
#ed-handles::before {
    content: ''; position: absolute; top: -26px; left: 50%;
    width: 1px; height: 24px; background: var(--ed-accent); pointer-events: none;
}

/* ================================================================
   SELECTED ELEMENT
   ================================================================ */
.ed-selected {
    outline: 2px solid var(--ed-accent) !important;
    outline-offset: 2px;
}

/* ================================================================
   EDIT MODE OVERRIDES
   ================================================================ */
.edit-mode::after { z-index: 0 !important; }
.edit-mode .decorations { pointer-events: none !important; overflow: visible !important; }
.edit-mode [data-ed] { pointer-events: auto !important; cursor: move !important; user-select: none; }
.edit-mode .screen-content { overflow-y: auto !important; overflow-x: hidden !important; }
.edit-mode .screen { overflow: hidden !important; }
.edit-mode #laptop-screen { overflow: hidden !important; }
.edit-mode .outer-wrapper { overflow: hidden !important; }

/* ================================================================
   CONTEXT MENU
   ================================================================ */
#ed-ctx {
    position: fixed; background: var(--ed-bg);
    border: 1px solid var(--ed-border); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6); z-index: 99999999;
    padding: 4px 0; min-width: 160px; font: 13px var(--ed-font);
}
.ed-ctx-item { padding: 8px 14px; color: var(--ed-text); cursor: pointer; }
.ed-ctx-item:hover { background: var(--ed-surface); }
.ed-ctx-item.ed-danger { color: var(--ed-danger); }
.ed-ctx-hr { border: none; border-top: 1px solid var(--ed-border); margin: 3px 0; }

/* ================================================================
   DRAG & DROP OVERLAY
   ================================================================ */
#ed-drop {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(124,92,252,0.12); backdrop-filter: blur(3px);
    z-index: 99999999; display: flex; align-items: center; justify-content: center;
    transition: opacity 0.2s;
}
.ed-drop-box {
    background: var(--ed-bg); padding: 48px 64px; border-radius: 16px;
    border: 3px dashed var(--ed-accent); text-align: center;
}
.ed-drop-box h2 { font: 700 22px var(--ed-font); color: #fff; margin: 0 0 8px; }
.ed-drop-box p { font: 400 14px var(--ed-font); color: #888; margin: 0; }

/* ================================================================
   TOAST
   ================================================================ */
#ed-toast {
    position: fixed !important;
    bottom: 40px !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(100px) !important;
    background: #16a34a !important;
    color: #fff !important;
    padding: 16px 32px !important;
    border-radius: 14px !important;
    font: 700 16px var(--ed-font) !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
    border: 2px solid #22c55e !important;
    z-index: 999999999 !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease !important;
}
#ed-toast.show {
    opacity: 1 !important;
    transform: translateX(-50%) translateY(0) !important;
}

/* ================================================================
   MOBILE PREVIEW
   ================================================================ */
.vp-mobile .outer-wrapper {
    max-width: 390px !important; margin: 0 auto;
    height: 100vh; overflow: hidden !important;
    background: var(--pink);
}
.vp-mobile #laptop-frame {
    max-width: 390px !important; margin: 0 auto;
    height: 100vh; overflow: hidden !important;
    border: 2px solid #444; border-radius: 24px;
    box-sizing: border-box;
}
.vp-mobile #laptop-screen {
    width: 100%; height: 100%;
    overflow: hidden !important;
    border-radius: 22px;
}
.vp-mobile .screen {
    width: 100% !important; height: 100% !important;
    overflow: hidden !important;
}
.vp-mobile .screen-content {
    width: 100% !important; height: 100% !important;
    overflow: hidden !important;
}
.vp-mobile .decorations {
    overflow: hidden !important;
}
.vp-mobile .screen-main-content {
    overflow: hidden !important;
    max-height: 100% !important;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
    #ed-panel { width: 260px; right: -280px; }
    #ed-panel.collapsed { right: -220px; }
    #ed-assets { grid-template-columns: repeat(2, 1fr); }
}
