/* ══════════════════════════════════════════════════════════════════════════
   editor.css — Guessle Fragen-Editor
   Requires: base.css, game.css (for .board-grid, .board-category etc.)
══════════════════════════════════════════════════════════════════════════ */

/* ── Page Layout ─────────────────────────────────────────────────────────── */
.editor-page {
    position: relative; z-index: 10;
    display: flex; flex-direction: column;
    max-width: 1800px; margin: 0 auto;
    padding: 0 1.5% 4rem;
    min-height: calc(100vh - 73px);
    gap: 1rem;
}

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.editor-toolbar {
    display: flex; align-items: center; gap: 1.25rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-card); padding: .85rem 1.5rem;
    backdrop-filter: blur(24px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
    flex-wrap: wrap;
    margin-top: 1rem;
}
.editor-toolbar-left {
    display: flex; align-items: center; gap: .85rem;
    flex-shrink: 0;
}
.editor-toolbar-actions {
    display: flex; align-items: center; gap: .6rem;
    flex-shrink: 0; margin-left: auto;
}

.editor-board-name {
    font-family: var(--font-display); font-size: 1.05rem; font-weight: 700;
    background: transparent; border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-main); padding: .25rem .5rem;
    outline: none; transition: border-color .2s;
    width: 260px;
}
.editor-board-name::placeholder { color: var(--text-dim); }
.editor-board-name:focus { border-bottom-color: var(--gold); }

/* ── Sliders ─────────────────────────────────────────────────────────────── */
.editor-sliders {
    display: flex; align-items: center; gap: 1.25rem;
    flex-shrink: 0; margin-left: 1rem;
}
.editor-slider-sep {
    width: 1px; height: 32px; background: var(--border);
}
.editor-slider-group {
    display: flex; flex-direction: column; gap: .3rem;
    min-width: 140px;
}
.editor-slider-label {
    display: flex; justify-content: space-between; align-items: center;
    font-size: .68rem; color: var(--text-muted);
    font-family: var(--font-display); letter-spacing: .06em;
}
.editor-slider-val {
    font-family: var(--font-display); font-size: .75rem; font-weight: 800;
    color: var(--gold); min-width: 16px; text-align: right;
}
.editor-slider-track-wrap { display: flex; flex-direction: column; gap: .2rem; }
.editor-slider {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px;
    background: linear-gradient(to right, var(--gold) 0%, var(--gold) var(--fill,50%), rgba(255,255,255,.1) var(--fill,50%));
    border-radius: 2px; outline: none; cursor: pointer;
    transition: background .15s;
}
.editor-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 3px rgba(0,212,255,.2), 0 0 8px rgba(0,212,255,.4);
    cursor: pointer; transition: box-shadow .2s;
}
.editor-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 4px rgba(0,212,255,.3), 0 0 14px rgba(0,212,255,.5);
}
.editor-slider::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%; border: none;
    background: var(--gold);
    box-shadow: 0 0 0 3px rgba(0,212,255,.2);
    cursor: pointer;
}
.editor-slider-range-labels {
    display: flex; justify-content: space-between;
    font-size: .6rem; color: var(--text-dim); padding: 0 2px;
}

/* ── Action Buttons ──────────────────────────────────────────────────────── */
.editor-action-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .5rem .9rem;
    background: rgba(255,255,255,.04); border: 1px solid var(--border);
    border-radius: var(--radius-inner);
    color: var(--text-muted); font-size: .8rem; cursor: pointer;
    transition: all .2s; white-space: nowrap;
}
.editor-action-btn:hover {
    border-color: rgba(255,255,255,.2); color: var(--text-main);
    background: rgba(255,255,255,.07);
}

/* ── Board Wrap ──────────────────────────────────────────────────────────── */
.editor-board-wrap {
    flex: 1;
}

/* Override board-grid to use exact column count set via JS custom property */
#editor-board-grid {
    grid-template-columns: repeat(var(--cat-count, 4), 1fr);
    align-items: stretch;
}
#editor-board-grid .board-card {
    min-height: 72px;
}

/* ── Complete category highlight ────────────────────────────────────────── */
.board-category.category-complete {
    border-color: rgba(0,229,160,.35);
    box-shadow: 0 0 12px rgba(0,229,160,.08);
}
.board-category.category-complete .editor-cat-header-wrap {
    background: rgba(0,229,160,.06);
    border-bottom-color: rgba(0,229,160,.2);
}
.board-category.category-complete .editor-cat-name-text {
    color: var(--green);
}

/* ── Editor overrides for board-category header (make it editable) ──────── */
.editor-cat-header-wrap {
    display: flex; align-items: center;
    padding: .75rem 1rem;
    background: rgba(255,255,255,.03);
    border-bottom: 1px solid var(--border);
    gap: .6rem; cursor: pointer;
    transition: background .2s;
}
.editor-cat-header-wrap:hover { background: rgba(255,255,255,.06); }

.editor-cat-icon { font-size: 1.2rem; flex-shrink: 0; }
.editor-cat-name-text {
    font-family: var(--font-display); font-size: .8rem; font-weight: 700;
    color: var(--text-main); flex: 1; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.editor-cat-edit-btn {
    opacity: 0; flex-shrink: 0; width: 22px; height: 22px;
    background: rgba(255,255,255,.06); border: 1px solid var(--border);
    border-radius: 5px; display: flex; align-items: center; justify-content: center;
    transition: opacity .2s, background .2s; cursor: pointer; padding: 0;
    color: var(--text-dim); font-size: .7rem;
}
.editor-cat-header-wrap:hover .editor-cat-edit-btn { opacity: 1; }
.editor-cat-edit-btn:hover { background: rgba(255,255,255,.12); color: var(--text-main); }

/* Empty category placeholder */
.editor-cat-placeholder {
    display: flex; align-items: center; justify-content: center;
    gap: .5rem; color: var(--text-dim); font-size: .8rem;
    flex: 1; min-height: 40px; cursor: pointer;
    transition: color .2s;
}
.editor-cat-header-wrap:hover .editor-cat-placeholder { color: var(--orange); }

/* ── Board Cards (editor variant) ───────────────────────────────────────── */
.board-card.editor-card-empty {
    border-style: dashed;
    border-color: rgba(255,255,255,.08);
    background: rgba(255,255,255,.01);
    opacity: .55;
}
.board-card.editor-card-empty:hover {
    border-color: var(--orange);
    border-style: dashed;
    background: rgba(0,184,212,.05);
    color: var(--orange);
    opacity: 1;
    transform: none;
}
.board-card.editor-card-filled {
    background: rgba(255,255,255,.03);
    border-color: rgba(255,255,255,.12);
}
.board-card.editor-card-filled:hover {
    border-color: var(--orange);
    background: rgba(0,184,212,.08);
    color: var(--orange);
    transform: translateX(2px);
}
.editor-card-content {
    display: flex; flex-direction: column; align-items: center; gap: .25rem;
    width: 100%;
}
.editor-card-num-large {
    font-family: var(--font-display); font-weight: 800;
    color: var(--orange); font-size: 1.6rem; line-height: 1;
}
.editor-card-empty-icon {
    font-size: 1.1rem; opacity: .5;
}
.editor-card-q-snippet {
    font-size: .62rem; color: var(--text-dim); text-align: center;
    line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
}
.editor-card-filled-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--green); opacity: .8; margin-top: .1rem;
}

/* ── Footer Progress ─────────────────────────────────────────────────────── */
.editor-footer {
    display: flex; align-items: center; gap: 1rem;
    padding: .6rem 0;
}
.editor-progress-label {
    font-size: .72rem; color: var(--text-muted); flex-shrink: 0;
    font-family: var(--font-display); letter-spacing: .05em;
}
.editor-progress-bar {
    flex: 1; height: 4px; border-radius: 2px;
    background: rgba(255,255,255,.07); overflow: hidden;
}
.editor-progress-fill {
    height: 100%; border-radius: 2px;
    background: linear-gradient(90deg, var(--green), var(--gold));
    transition: width .4s ease;
}

/* ── Modal Overlay ───────────────────────────────────────────────────────── */
.editor-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.75);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
}
.editor-modal-overlay.hidden { display: none; }

.editor-modal-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-card);
    width: 100%; max-width: 680px; max-height: 92vh;
    overflow-y: auto; display: flex; flex-direction: column;
    box-shadow: 0 32px 80px rgba(0,0,0,.7);
}

.editor-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.75rem; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--bg-card); z-index: 2;
}
.editor-modal-title {
    font-family: var(--font-display); font-weight: 700; font-size: 1rem;
}
.editor-modal-close {
    width: 28px; height: 28px; background: transparent;
    border: 1px solid var(--border); border-radius: 6px;
    color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .78rem; transition: all .2s; flex-shrink: 0;
}
.editor-modal-close:hover { background: rgba(255,255,255,.08); color: var(--text-main); }

.editor-modal-body {
    padding: 1.5rem 1.75rem;
    display: flex; flex-direction: column; gap: 1.25rem; flex: 1;
}
.editor-modal-footer {
    display: flex; align-items: center; gap: .65rem;
    padding: 1.1rem 1.75rem; border-top: 1px solid var(--border);
    position: sticky; bottom: 0; background: var(--bg-card); z-index: 2;
}

/* ── Form Fields ─────────────────────────────────────────────────────────── */
.editor-field { display: flex; flex-direction: column; gap: .5rem; }
.editor-field-label {
    font-family: var(--font-display); font-size: .62rem;
    letter-spacing: .18em; text-transform: uppercase;
    color: var(--text-muted);
}

/* ── Answers section in modal ────────────────────────────────────────────── */
.editor-answers-section { display: flex; flex-direction: column; gap: .75rem; }
.editor-answers-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: .5rem;
}
.editor-answers-legend {
    display: flex; align-items: center; gap: .75rem; font-size: .7rem;
}
.legend-hit    { color: var(--green); }
.legend-guessle { color: #ff6b6b; }

/* 2-column grid: rows = rank entries */
.editor-answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .35rem .9rem;
}
.editor-answer-row { display: flex; align-items: center; gap: .5rem; }
.editor-answer-rank {
    font-family: var(--font-display); font-size: .7rem; font-weight: 800;
    width: 20px; text-align: right; flex-shrink: 0; color: var(--text-dim);
}
.editor-answer-rank.guessle-rank { color: #ff6b6b; }
.editor-answer-input {
    flex: 1; background: rgba(255,255,255,.04); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text-main); padding: .38rem .6rem;
    font-size: .81rem; outline: none; transition: border-color .2s;
    font-family: var(--font-body);
}
.editor-answer-input:focus { border-color: rgba(0,212,255,.4); }
.editor-answer-input.guessle-input {
    border-color: rgba(255,80,80,.22); background: rgba(255,80,80,.03);
}
.editor-answer-input.guessle-input:focus { border-color: rgba(255,80,80,.5); }
.editor-answer-input.has-value { border-color: rgba(0,229,160,.3); }

/* ── Danger action button (toolbar) ─────────────────────────────────────── */
.editor-action-btn-danger {
    border-color: rgba(255,80,80,.3);
    color: rgba(255,100,100,.7);
}
.editor-action-btn-danger:hover {
    border-color: rgba(255,80,80,.6);
    color: #ff5050;
    background: rgba(255,80,80,.08);
}
.btn-danger {
    padding: .55rem 1.2rem;
    background: rgba(255,60,60,.15);
    border: 1px solid rgba(255,80,80,.4);
    border-radius: var(--radius-inner);
    color: #ff5050; font-weight: 600;
    cursor: pointer; transition: all .2s;
    font-family: var(--font-body); font-size: .85rem;
}
.btn-danger:hover {
    background: rgba(255,60,60,.25);
    border-color: rgba(255,80,80,.6);
}

/* ── Danger buttons (small, modal) ──────────────────────────────────────── */
.editor-btn-danger-sm {
    padding: .35rem .7rem;
    background: transparent;
    border: 1px solid rgba(255,80,80,.3);
    border-radius: 6px; color: rgba(255,100,100,.65);
    cursor: pointer; font-size: .75rem; transition: all .2s; white-space: nowrap;
}
.editor-btn-danger-sm:hover {
    border-color: rgba(255,80,80,.7); color: #ff5050;
    background: rgba(255,80,80,.08);
}

/* ── Topbar back button (copied from lobby.css) ─────────────────────────── */
.topbar-back-btn {
    display: inline-flex; align-items: center; gap: .45rem;
    background: rgba(255,255,255,.04); border: 1px solid var(--border);
    border-radius: var(--radius-pill); padding: .45rem 1rem;
    color: var(--text-muted); font-size: .78rem; font-weight: 600;
    cursor: pointer; transition: all .25s; white-space: nowrap; flex-shrink: 0;
}
.topbar-back-btn:hover { border-color: rgba(255,255,255,.2); color: var(--text-main); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .editor-toolbar { gap: .75rem; }
    .editor-board-name { width: 140px; }
    .editor-sliders { gap: .75rem; }
    .editor-slider-group { min-width: 110px; }
    #editor-board-grid { grid-template-columns: repeat(var(--cat-count, 4), minmax(120px, 1fr)); }
}
