/**
 * @file admin-editor.css
 * @brief Styles for the Admin Editor page-view visual/code editor
 *
 * Layout: top toolbar, left component palette, center canvas, right code panel.
 * Supports drag-and-drop from palette to canvas, inline editing, and mode toggling.
 */

/* ================================================================
   EDITOR SHELL
   ================================================================ */
.admin-editor {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    background: var(--bg-primary, #0d0d1a);
    border-radius: 12px;
    overflow: hidden;
}

/* ================================================================
   TOOLBAR
   ================================================================ */
.ae-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary, #1a1a2e);
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,.2));
    flex-shrink: 0;
    min-height: 48px;
}
.ae-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.ae-toolbar-group + .ae-toolbar-group {
    margin-left: 0.5rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--border-color, rgba(168,85,247,.15));
}
.ae-toolbar-spacer {
    flex: 1;
}
.ae-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border-color, rgba(168,85,247,.25));
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary, #e2e2f0);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.ae-btn:hover {
    background: rgba(168,85,247,.12);
    border-color: rgba(168,85,247,.4);
}
.ae-btn.active {
    background: rgba(168,85,247,.2);
    border-color: #a855f7;
    color: #c084fc;
}
.ae-btn i { font-size: 0.875rem; }
.ae-btn-save {
    background: rgba(34,197,94,.15);
    border-color: rgba(34,197,94,.4);
    color: #4ade80;
}
.ae-btn-save:hover {
    background: rgba(34,197,94,.25);
    border-color: rgba(34,197,94,.6);
}
.ae-file-select {
    padding: 0.375rem 0.625rem;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(168,85,247,.25));
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #e2e2f0);
    font-size: 0.8125rem;
    max-width: 280px;
    cursor: pointer;
}
.ae-file-select:focus {
    outline: none;
    border-color: #a855f7;
}

/* ================================================================
   EDITOR BODY — 3-column layout
   ================================================================ */
.ae-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ================================================================
   PALETTE (left column)
   ================================================================ */
.ae-palette {
    width: 220px;
    flex-shrink: 0;
    background: var(--bg-secondary, #1a1a2e);
    border-right: 1px solid var(--border-color, rgba(168,85,247,.15));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ae-palette-header {
    padding: 0.625rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #9d9daf);
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,.1));
}
.ae-palette-search {
    margin: 0.5rem 0.5rem 0;
    padding: 0.375rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color, rgba(168,85,247,.2));
    background: var(--bg-primary, #0d0d1a);
    color: var(--text-primary, #e2e2f0);
    font-size: 0.75rem;
    width: calc(100% - 1rem);
}
.ae-palette-search:focus {
    outline: none;
    border-color: #a855f7;
}
.ae-palette-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.ae-palette-section {
    margin-bottom: 0.75rem;
}
.ae-palette-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary, #9d9daf);
    margin-bottom: 0.375rem;
    padding-left: 0.25rem;
}
.ae-palette-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: 6px;
    cursor: grab;
    font-size: 0.75rem;
    color: var(--text-primary, #e2e2f0);
    transition: background .12s;
    user-select: none;
}
.ae-palette-item:hover {
    background: rgba(168,85,247,.1);
}
.ae-palette-item:active {
    cursor: grabbing;
}
.ae-palette-item i {
    width: 18px;
    text-align: center;
    color: #a855f7;
    font-size: 0.8125rem;
}
.ae-palette-item[hidden] {
    display: none;
}

/* ================================================================
   CANVAS (center)
   ================================================================ */
.ae-canvas-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}
.ae-canvas {
    flex: 1;
    overflow: auto;
    padding: 1.5rem;
    position: relative;
    background:
        radial-gradient(circle at 50% 50%, rgba(168,85,247,.03) 0%, transparent 70%),
        var(--bg-primary, #0d0d1a);
}
.ae-canvas-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary, #9d9daf);
    font-size: 0.875rem;
    text-align: center;
    gap: 0.75rem;
}
.ae-canvas-empty i {
    font-size: 2.5rem;
    color: rgba(168,85,247,.3);
}

/* Drop zones */
.ae-drop-zone {
    min-height: 48px;
    border: 2px dashed rgba(168,85,247,.2);
    border-radius: 8px;
    transition: border-color .15s, background .15s;
    margin-bottom: 0.75rem;
    position: relative;
}
.ae-drop-zone.over {
    border-color: #a855f7;
    background: rgba(168,85,247,.06);
}

/* Placed components on canvas */
.ae-placed {
    position: relative;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    transition: border-color .12s, box-shadow .12s;
    background: var(--bg-secondary, #1a1a2e);
    cursor: grab;
}
.ae-placed:hover {
    border-color: rgba(168,85,247,.3);
    box-shadow: 0 0 0 2px rgba(168,85,247,.08);
}
.ae-placed.selected {
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168,85,247,.15);
}
.ae-placed.dragging {
    opacity: 0.5;
    cursor: grabbing;
}
.ae-placed-label {
    position: absolute;
    top: -10px;
    left: 8px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #a855f7;
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    z-index: 1;
    pointer-events: none;
}
.ae-placed-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    gap: 0.25rem;
    z-index: 2;
}
.ae-placed:hover .ae-placed-actions,
.ae-placed.selected .ae-placed-actions {
    display: flex;
}
.ae-placed-actions button {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: none;
    background: rgba(255,255,255,.08);
    color: var(--text-secondary, #9d9daf);
    cursor: pointer;
    font-size: 0.6875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s;
}
.ae-placed-actions button:hover {
    background: rgba(168,85,247,.2);
    color: #c084fc;
}
.ae-placed-actions .ae-delete-btn:hover {
    background: rgba(239,68,68,.2);
    color: #f87171;
}
.ae-placed-preview {
    pointer-events: none;
    overflow: hidden;
    max-height: 300px;
    border-radius: 6px;
}

/* ================================================================
   CODE PANEL (right, toggleable)
   ================================================================ */
.ae-code-panel {
    width: 0;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg-secondary, #1a1a2e);
    border-left: 1px solid var(--border-color, rgba(168,85,247,.15));
    display: flex;
    flex-direction: column;
    transition: width .2s ease;
}
.ae-code-panel.open {
    width: 420px;
}
.ae-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color, rgba(168,85,247,.1));
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #9d9daf);
}
.ae-code-editor {
    flex: 1;
    overflow: auto;
}
.ae-code-editor textarea {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-primary, #0d0d1a);
    color: #c9d1d9;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Mono', monospace;
    font-size: 0.8125rem;
    line-height: 1.5;
    padding: 1rem;
    resize: none;
    tab-size: 2;
}
.ae-code-editor textarea:focus {
    outline: none;
}

/* ================================================================
   DRAG GHOST (follows cursor during drag)
   ================================================================ */
.ae-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid #a855f7;
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    color: #c084fc;
    box-shadow: 0 4px 16px rgba(168,85,247,.25);
    opacity: 0.9;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
    .ae-palette {
        width: 160px;
    }
    .ae-code-panel.open {
        width: 280px;
    }
}
@media (max-width: 480px) {
    .ae-body {
        flex-direction: column;
    }
    .ae-palette {
        width: 100%;
        height: 120px;
        border-right: none;
        border-bottom: 1px solid var(--border-color, rgba(168,85,247,.15));
    }
    .ae-palette-list {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 0.25rem;
    }
    .ae-code-panel.open {
        width: 100%;
        height: 200px;
        border-left: none;
        border-top: 1px solid var(--border-color, rgba(168,85,247,.15));
    }
}

/* ================================================================
   STATUS BAR
   ================================================================ */
.ae-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary, #1a1a2e);
    border-top: 1px solid var(--border-color, rgba(168,85,247,.1));
    font-size: 0.6875rem;
    color: var(--text-secondary, #9d9daf);
    flex-shrink: 0;
}
.ae-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}
.ae-status-dot.dirty {
    background: #fbbf24;
}
