/* Room Planner. Follows the Rack Studio workspace: header, toolbar, catalog, canvas, inspector. */
:root {
    --color-bg: #f4f7f6;
    --color-bg-alt: #ffffff;
    --color-bg-workspace: #e9ecef;
    --color-border: #d1d5db;
    --color-text: #1f2937;
    --color-text-light: #6b7280;
    --color-accent: #3b82f6;
    --color-danger: #ef4444;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "Consolas", "Menlo", "Courier New", monospace;
}
#app, #app *, #rp-dialog, #rp-dialog * { box-sizing: border-box; }
#app [hidden], #rp-dialog [hidden] { display: none !important; }
#app { display: flex; flex-direction: column; height: 100%; min-height: 0; font-family: var(--font-main); font-size: 13.5px; color: var(--color-text); background: var(--color-bg); }

/* Header */
#rp-header { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 4px 10px; background: var(--color-bg-alt); border-bottom: 1px solid var(--color-border); box-shadow: 0 1px 3px rgba(0,0,0,.04); z-index: 10; }
.control-group { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
#rp-project-name { width: 195px; max-width: 55vw; padding: 3px 8px; border: 1px solid var(--color-border); border-radius: 4px; font: inherit; font-size: 12.5px; }
#app button, #app .btn, #rp-dialog button, #rp-dialog .btn { display: inline-block; padding: 3px 8px; font: inherit; font-size: 12px; background: #f3f4f6; border: 1px solid #d1d5db; border-radius: 4px; cursor: pointer; text-decoration: none; color: var(--color-text); transition: all .1s ease; user-select: none; }
#app button:hover, #app .btn:hover, #rp-dialog button:hover, #rp-dialog .btn:hover { background: #e5e7eb; border-color: #9ca3af; }
#app button:disabled, #rp-dialog button:disabled { opacity: .45; cursor: default; }
#app button.active, #app button.primary, #rp-dialog button.active, #rp-dialog button.primary { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
#app button.primary:hover, #rp-dialog button.primary:hover { background: #2563eb; }
#app button.danger, #rp-dialog button.danger { color: #b91c1c; border-color: #fca5a5; background: #fef2f2; }
#app :focus-visible, #rp-dialog :focus-visible { outline: 2px solid #1d4ed8; outline-offset: 1px; }
.kpi-group { margin-inline-start: auto; display: flex; gap: 12px; font-size: 12px; align-items: center; flex-wrap: wrap; }
.kpi { text-align: start; line-height: 1.15; }
.kpi .value { font-weight: bold; font-size: 1.02em; display: block; direction: ltr; unicode-bidi: isolate; }
[dir=rtl] .kpi .value { text-align: right; }
.kpi .label { font-size: .82em; color: var(--color-text-light); }
#app button.kpi { padding: 2px 8px; border-radius: 6px; }
#app button.kpi.ok { background: #ecfdf5; border-color: #6ee7b7; }
#app button.kpi.warn { background: #fffbeb; border-color: #fcd34d; }
#app button.kpi.bad { background: #fef2f2; border-color: #fca5a5; }

/* Toolbar */
#rp-toolbar { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; padding: 4px 10px; border-bottom: 1px solid #cbd5e1; background: #f8fafc; flex-shrink: 0; position: relative; z-index: 20; }
#rp-toolbar button { min-height: 26px; border: 1px solid #cbd5e1; border-radius: 5px; background: #fff; color: #243e60; padding: 2px 7px; font-size: 12px; white-space: nowrap; }
#rp-toolbar button:hover { background: #edf5ff; }
#rp-toolbar button.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.rp-separator { height: 18px; border-inline-start: 1px solid #cbd5e1; margin: 0 2px; }
#rp-zoom-value { min-width: 40px; text-align: center; font: 11.5px var(--font-mono); }
.rp-snap { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: #475569; white-space: nowrap; }
.rp-snap select { min-height: 26px; border: 1px solid #cbd5e1; border-radius: 5px; background: #fff; font: inherit; padding: 1px 4px; font-size: 11.5px; }
#rp-save-status { color: #64748b; font-size: 11px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-dd { position: relative; display: inline-block; }
.rp-dd-menu { display: none; position: absolute; top: calc(100% + 4px); inset-inline-start: 0; min-width: 175px; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; box-shadow: 0 10px 24px rgba(15,23,42,.14); padding: 4px; z-index: 60; flex-direction: column; gap: 2px; }
.rp-dd.open .rp-dd-menu { display: flex; }
.rp-dd-menu button { width: 100%; text-align: start; border: 0 !important; background: transparent !important; padding: 6px 10px !important; border-radius: 5px !important; font-size: 12px !important; }
.rp-dd-menu button:hover { background: #eff6ff !important; color: #1d4ed8 !important; }
.rp-host-btn { display: inline-flex !important; align-items: center; gap: 4px; padding: 3px 9px !important; border-radius: 999px !important; font-size: 11.5px !important; font-weight: 600; text-decoration: none; white-space: nowrap; border: 1px solid #cbd5e1 !important; background: #fff !important; color: #1e40af !important; }
.rp-host-btn:hover { background: #eff6ff !important; border-color: #3b82f6 !important; }
.rp-host-btn.rp-host-save { background: #1363C6 !important; border-color: #1363C6 !important; color: #fff !important; }
.rp-host-btn.rp-host-save:hover { background: #0f4fa3 !important; }
body.workspace-mode .workspace-shell { height: calc(100vh - 64px) !important; }

/* Layout */
#app > main { display: flex; flex: 1; overflow: hidden; min-height: 0; }
#rp-sidebar { width: 280px; flex-shrink: 0; background: var(--color-bg-alt); border-inline-end: 1px solid var(--color-border); overflow-y: auto; padding-bottom: 20px; z-index: 5; }
#rp-workspace { flex: 1; position: relative; min-width: 0; background: var(--color-bg-workspace); background-image: linear-gradient(var(--color-border) 1px, transparent 1px), linear-gradient(90deg, var(--color-border) 1px, transparent 1px); background-size: 20px 20px; background-position: -1px -1px; }
#rp-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; direction: ltr; cursor: default; }
#rp-hint { position: absolute; top: 10px; inset-inline: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; background: #fff; border: 1px solid #93c5fd; border-radius: 8px; box-shadow: 0 4px 14px rgba(15,23,42,.12); font-size: 12px; z-index: 4; }
#rp-hint span { color: #475569; flex: 1 1 260px; }
#rp-hint label { display: inline-flex; align-items: center; gap: 5px; }
#rp-hint input { width: 96px; }
#rp-hint input, #rp-hint select { padding: 5px; border: 1px solid #bccbdd; border-radius: 5px; font: inherit; }
body.rp-dragging, body.rp-dragging * { cursor: grabbing !important; user-select: none; }
body.rp-focus #rp-header, body.rp-focus #rp-sidebar { display: none; }

/* Sidebar */
.rp-section { border-bottom: 1px solid var(--color-border); }
.rp-section > summary { font-weight: 600; padding: 10px 12px; cursor: pointer; list-style-position: inside; }
.rp-section-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.rp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#rp-sidebar label, #rp-inspector label, .rp-form label { display: grid; gap: 4px; font-size: 12px; color: #475569; min-width: 0; }
#rp-sidebar input, #rp-sidebar select, #rp-inspector input, #rp-inspector select, #rp-inspector textarea, .rp-form input, .rp-form select { width: 100%; min-width: 0; padding: 7px 8px; border: 1px solid #bccbdd; border-radius: 5px; font: inherit; color: var(--color-text); background: #fff; }
input:disabled { background: #f1f5f9 !important; color: #64748b !important; }
label.rp-check { display: flex !important; align-items: center; gap: 7px; }
label.rp-check input { width: auto !important; }
.rp-note { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--color-text-light); }
.rp-shapes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.rp-shapes button { padding: 8px 6px; }
.rp-wallrow { display: grid; grid-template-columns: 64px 1fr auto; gap: 6px; align-items: center; margin-bottom: 5px; font-size: 12px; color: #64748b; }
.rp-wallrow button { padding: 6px 4px; font-family: var(--font-mono); }
.rp-wallrow.active button { background: #fef3c7; border-color: #f59e0b; }
.rp-catgroup > summary { cursor: pointer; padding: 6px 0; font-size: 12.5px; font-weight: 600; color: #334155; }
.rp-catgroup > summary small { color: #94a3b8; font-weight: 400; }
.catalog-item { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 10px; margin-bottom: 6px; border: 1px solid #e2e8f0; border-radius: 4px; background: #fff; cursor: grab; user-select: none; -webkit-user-select: none; font-size: .9em; touch-action: pan-y; }
.catalog-item:hover { background: #edf5ff; border-color: #80a9df; }
.catalog-item span { flex: 1; }
.catalog-item small { color: #64748b; font-family: var(--font-mono); font-size: 10.5px; white-space: nowrap; }
.rp-swatch { width: 26px; height: 26px; flex-shrink: 0; }

/* Inspector */
#rp-inspector { width: 310px; flex-shrink: 0; border-inline-start: 1px solid #cbd5e1; background: #fff; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 9px; }
.rp-insp-head, .rp-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.rp-insp-head h2 { font-size: 16px; margin: 0; overflow-wrap: anywhere; }
.rp-insp-head button, .rp-dialog-head button { font-size: 18px; line-height: 1; padding: 2px 9px; }
fieldset { margin: 0; padding: 10px; border: 1px solid #cbd5e1; border-radius: 8px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
legend { font-weight: 600; padding: 0 6px; font-size: 12px; }
.rp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rp-actions button, .rp-actions .btn { padding: 7px 11px; border-radius: 6px; }
.rp-issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rp-issues li { border-inline-start: 4px solid #94a3b8; background: #f8fafc; border-radius: 4px; font-size: 12.5px; line-height: 1.45; padding: 7px 9px; }
.rp-issues li.error { border-color: #dc2626; background: #fef2f2; }
.rp-issues li.warn { border-color: #d97706; background: #fffbeb; }
.rp-issues li.info { border-color: #2563eb; background: #eff6ff; }
.rp-issues li button { all: unset; cursor: pointer; display: block; width: 100%; }
.rp-issues li button:focus-visible { outline: 2px solid #1d4ed8; }
.rp-ok { color: #047857; font-weight: 600; }

/* Dialogs */
.rp-dialog { width: min(640px, 94vw); max-height: 88vh; border: 0; border-radius: 12px; padding: 22px; box-shadow: 0 20px 90px #0f172a55; color: #172c45; }
.rp-dialog.wide { width: min(1050px, 94vw); }
.rp-dialog::backdrop { background: #0f172a80; }
.rp-dialog h2 { font-size: 21px; margin: 0 0 14px; }
.rp-dialog h3 { font-size: 15px; margin: 16px 0 6px; }
.rp-dialog > * + * { margin-top: 12px; }
.rp-form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.rp-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.rp-table td, .rp-table th { text-align: start; border-bottom: 1px solid #dce4ed; padding: 7px 8px; overflow-wrap: anywhere; }
.rp-table th { color: #475569; font-weight: 600; }
.rp-message { margin: 0; min-height: 1.2em; font-size: 12.5px; color: #b45309; }
.rp-export { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.rp-export button { display: grid; gap: 4px; text-align: start; padding: 12px; border-radius: 8px; background: #f8fafc; }
.rp-export button span { font-size: 11.5px; color: #64748b; line-height: 1.4; }
.rp-guide { margin: 0; padding-inline-start: 18px; font-size: 13px; line-height: 1.6; }

/* Print sheets: SVG pages sized in paper millimetres */
#rp-print { display: none; }
.rp-sheet svg { display: block; }
.rp-logo-preview { height: 34px; max-width: 140px; object-fit: contain; border: 1px solid #dce4ed; border-radius: 4px; background: #fff; }
.catalog-item [data-forget] { padding: 0 6px; border: 0; background: none; color: #94a3b8; font-size: 15px; }
.catalog-item [data-forget]:hover { color: #b91c1c; background: none; }
.rp-table button { padding: 3px 8px; }
input[type=range] { padding: 0 !important; }

@media (max-width: 900px) {
    html, body { overflow: auto; }
    #app { height: auto; min-height: 100dvh; }
    main { flex-direction: column; overflow: visible; }
    #rp-sidebar { width: auto; max-height: 260px; border-inline-end: 0; border-bottom: 1px solid var(--color-border); }
    #rp-workspace { min-height: 68vh; }
    #rp-inspector { position: fixed; inset-inline: 0; bottom: 0; width: auto; max-height: 44vh; z-index: 200; border-inline-start: 0; border-top: 1px solid #cbd5e1; border-radius: 12px 12px 0 0; box-shadow: 0 -8px 30px #0003; }
    #rp-toolbar { position: sticky; top: 0; z-index: 30; flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
    #rp-toolbar > * { flex-shrink: 0; }
    #rp-toolbar button, .rp-snap select { min-height: 40px; }
    .kpi-group { margin-inline-start: 0; gap: 12px; }
    .rp-dialog { padding: 15px; }
    .rp-form { grid-template-columns: 1fr; }
}
@media print {
    html, body,
    body.workspace-mode,
    body.workspace-mode .workspace-shell {
        overflow: visible !important;
        height: auto !important;
        min-height: 0 !important;
        background: #fff !important;
    }
    #app, .rp-dialog { display: none !important; }
    #rp-print { display: block !important; }
    .rp-sheet { break-after: page; }
    .rp-sheet:last-child { break-after: auto; }
    .rp-issues li, .rp-table tr { break-inside: avoid; }
    .rp-issues li { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .rp-svg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
