/* floorplan.css - styles of the openPlan3D area (/private/floorplan)
   Used by templates/floorplan/*.html together with static/js/floorplan.js.
   Colours come from the design tokens of quantix-style.css. */

/* --- shell: Werkzeugleiste unter der festen Hauptnavigation, Editor darunter -
   Die Navigation aus templates/base.html ist `position: fixed` und deckt den
   oberen Rand des Fensters ab.  Ohne den Abstand lägen die Bedienelemente
   ("Meine Pläne", "Grundriss-Editor", "Serverplan", ...) darunter. ------- */
.fp-shell {
    --fp-nav-offset: calc(var(--nav-height, 104px) + 14px);
    display: flex;
    flex-direction: column;
    min-height: 70vh;
    /* oben der Platz der Navigation, unten 14px Luft: der Editor füllt den
       Rest des Fensters (100vh - var(--fp-nav-offset) - 14px) */
    padding: var(--fp-nav-offset) 16px 0;
    height: calc(100vh - 14px);
}

.fp-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.fp-toolbar-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 6px;
}

.fp-select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.fp-select select {
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    padding: 6px 8px;
    max-width: 260px;
}

.fp-frame-wrap {
    flex: 1 1 auto;
    margin-top: 10px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #ffffff;
}

.fp-frame {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 480px;
    border: 0;
}

.fp-hint {
    margin: 10px 2px 0;
    font-size: 0.86rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.fp-not-built { padding: 8px 2px 24px; }

/* --- status line ------------------------------------------------------- */
.fp-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.fp-status.is-error { color: var(--rose); }
.fp-status-wide { display: block; margin-top: 14px; }

/* --- overview: summary, upload, table --------------------------------- */
.fp-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    padding: 16px 18px;
    margin: 18px 0 26px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.fp-stat { display: flex; flex-direction: column; min-width: 120px; }
.fp-stat-value { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); }
.fp-stat-label { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.fp-stat-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.fp-stat-actions form { margin: 0; }

.fp-section-title {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 26px 0 6px;
}

.fp-upload {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr);
    gap: 12px 16px;
    align-items: end;
    padding: 16px 18px;
    margin-top: 10px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.fp-upload .hint-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }

/* Hinweis zum Ziel der Datei ("Ablage"): er gehoert unter beide Spalten. */
.fp-upload-note { grid-column: 1 / -1; margin: 0; }

.fp-table-wrap { overflow-x: auto; margin-top: 12px; }
.fp-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.fp-danger { color: var(--rose) !important; }

.fp-revisions summary { cursor: pointer; color: var(--text-secondary); font-size: 0.85rem; }
.fp-revision-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; min-width: 180px; }
.fp-revision { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-secondary); }

/* --- login / instruction pages ---------------------------------------- */
.fp-login-card {
    max-width: 460px;
    padding: 20px 22px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.fp-login-card .contact-form { display: flex; flex-direction: column; gap: 14px; }

.fp-steps { color: var(--text-secondary); line-height: 1.7; }
.fp-steps code,
.fp-not-built code,
.alert code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.86em;
    background: var(--surface-3);
    color: var(--text-primary);
    padding: 1px 5px;
    border-radius: var(--radius-xs);
}

.fp-logout { margin: 0; }

/* --- Freigabe-Panel (templates/floorplan/_share_panel.html) -------------
   Ein nativer <dialog>: die Verdunkelung und das Fangen des Fokus uebernimmt
   der Browser, static/js/floorplan.js oeffnet und schliesst ihn. ---------- */
.fp-share {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 20px 22px 18px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    color: var(--text-primary);
    overflow-y: auto;
}

.fp-share::backdrop { background: rgba(23, 23, 28, 0.55); }

.fp-share-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.fp-share-head h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.fp-share-close {
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
}

.fp-share-close:hover { color: var(--text-primary); }

.fp-share-note,
.fp-share-hint {
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 10px 0;
}

.fp-share-plan {
    font-weight: 700;
    color: var(--text-primary);
    margin: 12px 0 4px;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.fp-share-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.fp-share-status {
    min-height: 1.2em;
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.fp-share-status.is-error { color: var(--rose); }

.fp-share-result {
    margin-top: 12px;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
}

.fp-share-label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.fp-share-link-row { display: flex; gap: 8px; align-items: center; }

.fp-share-link {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
}

.fp-share-subtitle {
    margin: 20px 0 8px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.fp-share-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fp-share-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
}

.fp-share-item-plan { font-weight: 600; color: var(--text-primary); }
.fp-share-item-meta { color: var(--text-muted); font-size: 0.8rem; }
.fp-share-item .btn { margin-left: auto; }

.fp-share-empty { font-size: 0.85rem; color: var(--text-muted); margin: 0; }

/* --- oeffentliche Freigabe-Seite (templates/floorplan/share.html) ------- */
.fp-share-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    padding: 14px 18px;
    margin: 18px 0 8px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.fp-share-fact { display: flex; flex-direction: column; min-width: 96px; }
.fp-share-fact-label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.fp-share-fact-value { font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }

/* --- Planansicht der oeffentlichen Freigabe-Seite ----------------------- */
.fp-viewer {
    margin: 18px 0 8px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.fp-viewer-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-subtle);
}

.fp-viewer-badge {
    padding: 3px 9px;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.fp-viewer-field {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.fp-viewer-field select {
    font: inherit;
    font-size: 0.82rem;
    color: var(--text-primary);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    padding: 5px 8px;
}

.fp-viewer-floors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.fp-viewer-floor,
.fp-viewer-btn {
    font: inherit;
    font-size: 0.8rem;
    padding: 5px 10px;
    color: var(--text-primary);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xs);
    cursor: pointer;
}

.fp-viewer-floor:hover,
.fp-viewer-btn:hover { border-color: var(--text-muted); }

.fp-viewer-floor.is-active {
    color: var(--surface-1);
    background: var(--text-primary);
    border-color: var(--text-primary);
}

.fp-viewer-zoom { display: flex; gap: 6px; margin-left: auto; }

.fp-viewer-stage {
    position: relative;
    height: clamp(320px, 62vh, 640px);
    background: #f8fafc;
}

.fp-viewer-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: grab;
}

.fp-viewer.is-dragging .fp-viewer-canvas { cursor: grabbing; }

.fp-viewer-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 20px;
    text-align: center;
    font-size: 0.9rem;
    color: #475569;
}

.fp-viewer.is-ready .fp-viewer-fallback { display: none; }
/* Not ready yet: keep the canvas in the layout (visibility, not display), so
   the script can measure it and draw.  With display:none the canvas would be
   0 x 0 pixels, the first render would bail out and the page would never get
   the is-ready class. */
.fp-viewer:not(.is-ready) .fp-viewer-canvas { visibility: hidden; }

.fp-viewer-hint {
    margin: 0;
    padding: 9px 14px;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
}

/* --- Vollbild der Planansicht (static/js/floorplan_view.js) -------------
   Der Knopf "Vollbild" laesst die Ansicht den Bildschirm fuellen: mit
   Fullscreen-API uebernimmt der Browser (.fp-viewer:fullscreen), sonst liegt
   dieselbe Flaeche als Overlay ueber der Seite (.fp-viewer.is-fullscreen).
   Der schwebende Knopf unten rechts holt die normale Seite zurueck. ----- */
html.fp-fullscreen-open { overflow: hidden; }

.fp-viewer:fullscreen,
.fp-viewer:-webkit-full-screen,
.fp-viewer.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1080;              /* ueber der Seite, unter den Meldungen (1100) */
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #ffffff;
}

/* Im Vollbild nimmt die Buehne den freien Platz; der Hinweistext weicht. */
.fp-viewer:fullscreen .fp-viewer-stage,
.fp-viewer:-webkit-full-screen .fp-viewer-stage,
.fp-viewer.is-fullscreen .fp-viewer-stage {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
}

.fp-viewer:fullscreen .fp-viewer-hint,
.fp-viewer:-webkit-full-screen .fp-viewer-hint,
.fp-viewer.is-fullscreen .fp-viewer-hint { display: none; }

/* Der schwebende Knopf: nur im Vollbild sichtbar - wie .nav-collapse-float
   der Kopfzeile (quantix-style.css). */
.fp-viewer-exit {
    display: none;
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1090;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font: inherit;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    box-shadow: 0 2px 10px rgba(23, 23, 28, 0.12);
    cursor: pointer;
}

.fp-viewer-exit:hover { color: var(--text-primary); }

.fp-viewer:fullscreen .fp-viewer-exit,
.fp-viewer:-webkit-full-screen .fp-viewer-exit,
.fp-viewer.is-fullscreen .fp-viewer-exit { display: inline-flex; }

/* Ist die Kopfzeile eingeklappt, sitzt unten rechts schon der Knopf der
   Navigation (html.header-collapsed .nav-collapse-float) - dann eine Zeile
   hoeher, damit sich beide nicht ueberdecken. */
html.header-collapsed .fp-viewer:fullscreen .fp-viewer-exit,
html.header-collapsed .fp-viewer:-webkit-full-screen .fp-viewer-exit,
html.header-collapsed .fp-viewer.is-fullscreen .fp-viewer-exit { bottom: 62px; }

.fp-viewer-note {
    margin: 12px 0 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.fp-share-preview {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.fp-share-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.fp-share-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    background: var(--surface-3);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.fp-share-thumb img { width: 100%; height: 100%; object-fit: contain; }
.fp-share-thumb-empty { font-size: 0.78rem; color: var(--text-muted); }
.fp-share-card-name {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.fp-share-void {
    padding: 18px 20px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.fp-share-void .hint-actions { margin-top: 12px; }

/* --- Notizen je Etage (Tabelle der Freigabe-Seite) ---------------------- */
.fp-notes {
    margin: 18px 0 0;
    padding: 16px 18px 18px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.fp-notes-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.fp-notes-project {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
}

.fp-notes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.fp-notes-table th {
    text-align: left;
    padding: 6px 10px;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
}

.fp-notes-table td {
    padding: 7px 10px;
    vertical-align: top;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-subtle);
    overflow-wrap: anywhere;
}

.fp-notes-table tr:last-child td { border-bottom: 0; }
.fp-notes-table .is-muted { color: var(--text-muted); }

@media (max-width: 780px) {
    .fp-shell { height: auto; }
    .fp-upload { grid-template-columns: 1fr; }
    .fp-stat-actions { margin-left: 0; width: 100%; }
    .fp-frame { min-height: 420px; }
    .fp-viewer-zoom { margin-left: 0; }
    .fp-viewer-stage { height: 64vh; }
}
