/* =====================================================================
   Aufnahmetool - Foto-Editor (Vermassung / Annotationen)
   Vollbild-Overlay, mobile-first
   ===================================================================== */

body.editor-offen { overflow: hidden; }

.editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #0d0d14;
    display: flex;
    flex-direction: column;
    color: #fff;
    /* Safe-Area iPhone */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.editor-overlay.hidden { display: none; }

/* ── Kopfzeile ── */
.editor-topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.editor-scale {
    font-size: 0.78rem;
    color: var(--gray-500);
    text-align: center;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-scale.aktiv { color: #ffd400; }

.ed-btn-text {
    background: none;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    padding: 8px 4px;
    cursor: pointer;
}

.ed-btn-primary {
    background: var(--accent-bright);
    border: none;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 9px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.ed-btn-primary:disabled { opacity: 0.6; }

/* ── Zeichenfläche ── */
.editor-stage {
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
    background: #0d0d14;
    overflow: hidden;
}

#edCanvas {
    display: block;
    /* Browser-Gesten unterdrücken, damit Zeichnen/Pinch sauber funktioniert */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.editor-hint {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    max-width: 92%;
    background: rgba(0,0,0,0.6);
    color: var(--gray-300);
    font-size: 0.75rem;
    line-height: 1.3;
    padding: 6px 12px;
    border-radius: 999px;
    text-align: center;
    pointer-events: none;
}

/* ── Werkzeugleiste ── */
.editor-toolbar {
    flex: 0 0 auto;
    background: #16161f;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 8px 8px 10px;
}

.editor-tools {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}

.editor-tools::-webkit-scrollbar { display: none; }

.ed-tool {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 62px;
    padding: 8px 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--gray-400);
    font-size: 0.68rem;
    cursor: pointer;
}

.ed-tool.active {
    background: rgba(233,69,96,0.18);
    border-color: var(--accent-bright);
    color: #fff;
}

.editor-options {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.editor-colors { display: flex; gap: 6px; }

.ed-color {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.25);
    cursor: pointer;
    padding: 0;
}

.ed-color.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--accent-bright);
}

.editor-widths { display: flex; gap: 4px; }

.ed-width {
    width: 30px;
    height: 26px;
    background: rgba(255,255,255,0.06);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--gray-400);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
}

.ed-width.active {
    background: rgba(255,255,255,0.16);
    border-color: var(--gray-500);
    color: #fff;
}

.editor-actions {
    display: flex;
    gap: 5px;
    margin-left: auto;
}

.ed-btn-icon {
    padding: 6px 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--gray-300);
    font-size: 0.72rem;
    cursor: pointer;
}

.ed-btn-icon:disabled { opacity: 0.35; cursor: default; }

/* Umschalter (Kanten-Einrasten) */
.ed-btn-icon.active {
    background: rgba(41,121,255,0.22);
    border-color: #2979ff;
    color: #fff;
}

.ed-prompt-unit:disabled { background: var(--gray-100); color: var(--gray-600); }

/* ── Eingabedialog ── */
#edPrompt { z-index: 2100; }

.ed-prompt { max-width: 420px; }

.modal-hint.hidden { display: none; }

.ed-prompt-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ed-prompt-row .search-input { flex: 1; }

.ed-prompt-unit {
    padding: 12px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 1rem;
    color: var(--gray-800);
}

.ed-prompt-unit.hidden { display: none; }

.ed-prompt-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.ed-prompt-actions .btn-primary,
.ed-btn-secondary { flex: 1; }

.ed-btn-secondary {
    padding: 12px 16px;
    background: var(--gray-200);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--gray-800);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

/* ── Bearbeiten-Button in der Vorschau ── */
.preview-edit {
    position: absolute;
    left: 4px;
    bottom: 22px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.6);
    border: none;
    border-radius: 999px;
    color: #fff;
    font-size: 0.68rem;
    cursor: pointer;
}

.preview-edit:active { background: rgba(0,0,0,0.8); }

.preview-badge {
    position: absolute;
    left: 4px;
    top: 4px;
    padding: 2px 7px;
    background: var(--success);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 600;
    border-radius: 999px;
}

/* Grössere Schaltflächen auf dem Desktop */
@media (min-width: 700px) {
    .ed-tool { min-width: 72px; font-size: 0.74rem; }
    .editor-hint { font-size: 0.82rem; }
}

/* Querformat auf flachen Bildschirmen: Bedienleisten kompakt halten,
   damit möglichst viel Platz fürs Foto bleibt */
@media (orientation: landscape) and (max-height: 560px) {
    .editor-topbar { padding: 6px 12px; }
    .editor-toolbar { padding: 5px 8px 6px; }
    .ed-tool { flex-direction: row; min-width: 0; padding: 6px 10px; gap: 5px; }
    .ed-tool span { font-size: 0.7rem; }
    .editor-options { margin-top: 5px; }
    .ed-color { width: 22px; height: 22px; }
    .ed-width { height: 22px; }
    .ed-btn-icon { padding: 4px 9px; }
    .editor-hint { display: none; }
}
