/* Room Planner & Materials Estimator */
/* Lite edition: hide pro-only accordions (material settings, etc.); body class set in room_planner.php */
body.rp-edition-lite .rp-pro-only {
    display: none !important;
}

:root {
    --rp-surface: #ffffff;
    --rp-surface-muted: #f8fafc;
    --rp-surface-elevated: #f1f5f9;
    --rp-border: #e2e8f0;
    --rp-border-strong: #cbd5e1;
    --rp-text: #0f172a;
    --rp-text-muted: #64748b;
    --rp-accent: #1e40af;
    --rp-accent-soft: #eff6ff;
    --rp-accent-muted: #334155;
    --rp-radius: 10px;
    --rp-radius-sm: 8px;
    --rp-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    --rp-shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
}

.rp-page-wrap .rp-page-header {
    margin-bottom: 1rem;
}
.rp-page-title {
    margin: 0 0 0.35rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--rp-text);
    background: linear-gradient(120deg, #0f172a 0%, #1e3a8a 55%, #1d4ed8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
@supports not (background-clip: text) {
    .rp-page-title {
        color: var(--rp-text);
        background: none;
    }
}
.rp-page-lead {
    margin: 0;
    color: var(--rp-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 52rem;
}

.rp-app {
    display: grid;
    grid-template-columns: 288px 1fr 308px;
    gap: 0;
    min-height: calc(100vh - 120px);
    max-width: 1600px;
    margin: 0 auto;
    background: var(--rp-surface-muted);
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius);
    overflow: hidden;
    box-shadow: var(--rp-shadow-md);
}
.rp-sidebar {
    background: var(--rp-surface);
    border-right: 1px solid var(--rp-border);
    padding: 0.85rem 0.9rem 1rem;
    overflow-y: auto;
    scrollbar-gutter: stable;
}
.rp-main {
    background: linear-gradient(180deg, var(--rp-surface-elevated) 0%, #e8eef5 100%);
    padding: 0.75rem 0.85rem;
    min-height: 520px;
    display: flex;
    flex-direction: column;
}
.rp-canvas-wrap {
    flex: 1;
    background: var(--rp-surface);
    border-radius: var(--rp-radius-sm);
    border: 1px solid var(--rp-border-strong);
    box-shadow: var(--rp-shadow);
    overflow: hidden;
    position: relative;
    touch-action: none;
}
#rpSvg {
    width: 100%;
    min-height: min(65vh, 560px);
    height: min(70vh, 640px);
    display: block;
    cursor: crosshair;
}

/* Floating assistants on the plan canvas (parallel / perpendicular / snap) */
.rp-draw-assist-bar {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 4;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.35rem;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--rp-border-strong);
    border-radius: var(--rp-radius-sm);
    box-shadow: var(--rp-shadow-md);
}
.rp-draw-assist-btn {
    width: 2.25rem;
    height: 2.25rem;
    margin: 0;
    padding: 0;
    font-size: 1.15rem;
    line-height: 1;
    font-weight: 700;
    color: var(--rp-text);
    background: var(--rp-surface);
    border: 1px solid var(--rp-border-strong);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.rp-draw-assist-btn:hover {
    background: var(--rp-accent-soft);
    border-color: var(--rp-accent);
    color: var(--rp-accent);
}
.rp-draw-assist-btn[aria-pressed="true"] {
    background: var(--rp-accent);
    border-color: #1e3a8a;
    color: #fff;
}
.rp-draw-assist-btn.rp-draw-assist-clear {
    font-size: 0.95rem;
    font-weight: 600;
}
.rp-draw-assist-btn.rp-draw-assist-undo,
.rp-draw-assist-btn.rp-draw-assist-redo {
    font-size: 1rem;
    font-weight: 700;
}
.rp-draw-assist-esc-hint {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 4;
    margin: 0;
    max-width: min(100%, 20rem);
    padding: 0.3rem 0.45rem;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--rp-text);
    background: rgba(254, 243, 199, 0.95);
    border: 1px solid rgba(217, 119, 6, 0.45);
    border-radius: 6px;
    box-shadow: var(--rp-shadow);
    pointer-events: none;
}
.rp-draw-assist-esc-hint kbd {
    font-size: 0.68rem;
    padding: 0.05rem 0.2rem;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 0.85);
}
.rp-draw-assist-float {
    position: absolute;
    z-index: 50;
    flex-direction: column;
    gap: 0.4rem;
    max-width: min(100%, 17rem);
    padding: 0.45rem 0.55rem;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--rp-border-strong);
    border-radius: 8px;
    box-shadow: var(--rp-shadow-md);
    pointer-events: auto;
}
.rp-draw-assist-float-text {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--rp-text);
}
.rp-draw-assist-status {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.45rem;
    z-index: 3;
    margin: 0;
    padding: 0.35rem 0.5rem;
    max-width: min(100%, 42rem);
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--rp-text);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--rp-border);
    border-radius: 6px;
    box-shadow: var(--rp-shadow);
    pointer-events: none;
}
.rp-draw-assist-status:empty {
    display: none;
}
#rpSvg.rp-tool-select {
    cursor: default;
}
#rpSvg.rp-tool-edit {
    cursor: default;
}
#rpSvg.rp-tool-floorlevel {
    cursor: crosshair;
}
#rpSvg.rp-tool-floorstep {
    cursor: crosshair;
}
#rpSvg.rp-tool-edit .rp-edge-note,
.rp-vertex-handle {
    cursor: grab;
}
.rp-dim-vertex-drag-lock-hi text.rp-dim-hit {
    fill: #b45309 !important;
    stroke: #fff7ed !important;
}
.rp-dim-vertex-drag-lock-hi rect[fill="transparent"] {
    stroke: rgba(217, 119, 6, 0.65);
    stroke-width: 6px;
}
.rp-angle-vertex-drag-lock-hi text.rp-angle-hit {
    fill: #b45309 !important;
}
.rp-angle-vertex-drag-lock-hi rect[fill="transparent"] {
    stroke: rgba(217, 119, 6, 0.75);
    stroke-width: 5px;
}
#rpSvg.rp-tool-edit .rp-edge-note-sel .rp-edge-note-bg {
    stroke: #b45309;
    stroke-width: 10;
}
.rp-dim-hit {
    cursor: pointer;
}
.rp-dim-hit:hover {
    fill: #7c3aed;
}
.rp-angle-hit {
    cursor: pointer;
}
.rp-angle-hit:hover {
    fill: #0d9488;
}
/* Explicit pencil targets beside wall length / interior angle numbers (larger hit than text alone). */
.rp-plan-label-edit-btn {
    cursor: pointer;
}
.rp-plan-label-edit-btn:hover circle {
    filter: brightness(0.96);
    stroke-width: 22px;
}
.rp-plan-label-edit-dim:hover circle {
    stroke: #4338ca;
}
.rp-plan-label-edit-angle:hover circle {
    stroke: #0f766e;
}
.rp-plan-lock-hit {
    cursor: pointer;
}
.rp-plan-lock-hit:hover rect:first-of-type {
    fill: rgba(146, 64, 14, 0.28);
}
.rp-preview-line {
    pointer-events: none;
}
.rp-preview-hud {
    pointer-events: none;
}
.rp-opening-label-inp {
    width: 4.25rem;
    padding: 0.2rem 0.35rem;
    font-size: 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    margin-right: 0.35rem;
    vertical-align: middle;
}
.rp-opening-row {
    margin: 0.35rem 0;
    padding: 0.25rem 0;
    border-bottom: 1px solid #f1f5f9;
    list-style: none;
}
.rp-opening-row:last-child {
    border-bottom: none;
}
.rp-tool-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
    align-items: center;
}
.rp-main-toolbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.65rem;
    padding: 0.35rem 0.45rem;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid var(--rp-border);
    border-radius: var(--rp-radius-sm);
    backdrop-filter: blur(6px);
}
.rp-btn-ic {
    display: inline-flex !important;
    align-items: center;
    gap: 0.4rem;
}
.rp-btn-ic .rp-icon {
    flex-shrink: 0;
    opacity: 0.92;
}
.rp-tool-mode-row {
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.65rem;
}
.rp-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.7rem;
    border-radius: var(--rp-radius-sm);
    border: 1px solid var(--rp-border-strong);
    background: var(--rp-surface);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--rp-accent-muted);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.rp-tool-btn:hover {
    background: var(--rp-accent-soft);
    border-color: #93c5fd;
    color: var(--rp-accent);
}
.rp-tool-btn .rp-icon {
    flex-shrink: 0;
    opacity: 0.88;
}
.rp-tool-btn.active {
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border-color: #1e3a8a;
    box-shadow: 0 1px 2px rgba(30, 58, 138, 0.35);
}
.rp-tool-btn.active .rp-icon {
    opacity: 1;
    color: #fff;
}
/* Floating touch dock — mirrors primary tools (min ~44px touch target) */
.rp-tool-dock {
    position: absolute;
    left: 50%;
    bottom: 0.65rem;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.45rem 0.55rem;
    max-width: min(96%, 520px);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--rp-border);
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(8px);
    pointer-events: auto;
}
.rp-tool-dock-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 44px;
    min-height: 44px;
    padding: 0.45rem 0.65rem;
    border-radius: var(--rp-radius-sm);
    border: 1px solid var(--rp-border-strong);
    background: var(--rp-surface);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--rp-accent-muted);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.rp-tool-dock-btn:hover {
    background: var(--rp-accent-soft);
    border-color: #93c5fd;
    color: var(--rp-accent);
}
.rp-tool-dock-btn .rp-icon {
    flex-shrink: 0;
    opacity: 0.88;
}
.rp-tool-dock-btn.active {
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border-color: #1e3a8a;
    box-shadow: 0 1px 2px rgba(30, 58, 138, 0.35);
}
.rp-tool-dock-btn.active .rp-icon {
    opacity: 1;
    color: #fff;
}
.rp-err {
    color: #b91c1c;
    font-size: 0.85rem;
    margin: 0.15rem 0;
}
.rp-muted {
    color: #64748b;
    font-size: 0.88rem;
}
.rp-right {
    background: var(--rp-surface);
    border-left: 1px solid var(--rp-border);
    padding: 0.85rem 0.9rem 1rem;
    overflow-y: auto;
    scrollbar-gutter: stable;
}
.rp-right h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}
.rp-right .rp-accordion-head {
    font-size: 0.95rem;
}
.rp-right label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    margin-top: 0.5rem;
}
.rp-right input[type="text"],
.rp-right input[type="number"],
.rp-right select {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    background: var(--rp-surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rp-right input:focus,
.rp-right select:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.rp-section {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}
.rp-section:last-child {
    border-bottom: none;
}

/* Icons (inline SVG) */
.rp-icon {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
    color: #475569;
}
.rp-accordion-head:hover .rp-icon:not(.rp-accordion-chevron-icon) {
    color: var(--rp-accent);
}
.rp-accordion-item.is-open .rp-accordion-head .rp-icon:not(.rp-accordion-chevron-icon) {
    color: var(--rp-accent);
}

/* Sidebar accordions — one open per column; click head to expand/collapse */
.rp-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.rp-accordion-item {
    border-radius: var(--rp-radius-sm);
    margin-bottom: 0;
    padding-bottom: 0;
    border: 1px solid transparent;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.rp-accordion-item.is-open {
    background: linear-gradient(180deg, var(--rp-accent-soft) 0%, rgba(255, 255, 255, 0) 100%);
    border-color: #bfdbfe;
}
.rp-accordion-item:last-child {
    border-bottom: none;
}
.rp-accordion-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0;
    padding: 0.6rem 0.45rem 0.6rem 0.5rem;
    border: none;
    border-radius: var(--rp-radius-sm);
    background: transparent;
    font: inherit;
    font-size: 0.92rem;
    color: var(--rp-text);
    text-align: left;
    cursor: pointer;
    list-style: none;
    gap: 0.5rem;
}
.rp-accordion-head:hover {
    background: rgba(241, 245, 249, 0.9);
}
.rp-accordion-item.is-open > .rp-accordion-head {
    background: rgba(255, 255, 255, 0.7);
}
.rp-accordion-head-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}
.rp-accordion-title {
    font-weight: 600;
    letter-spacing: -0.01em;
}
.rp-accordion-chevron-icon {
    flex-shrink: 0;
    color: var(--rp-text-muted);
    transition: transform 0.2s ease, color 0.15s ease;
}
.rp-accordion-head:hover .rp-accordion-chevron-icon {
    color: var(--rp-accent);
}
.rp-accordion-item.is-open .rp-accordion-head .rp-accordion-chevron-icon {
    transform: rotate(0deg);
    color: var(--rp-accent);
}
.rp-accordion-item:not(.is-open) .rp-accordion-head .rp-accordion-chevron-icon {
    transform: rotate(-90deg);
}
.rp-accordion-panel {
    padding: 0.15rem 0.35rem 0.9rem 0.5rem;
}
.rp-accordion-item:not(.is-open) .rp-accordion-panel {
    display: none;
}
.rp-sidebar .rp-accordion-item .rp-accordion-panel label:first-of-type {
    margin-top: 0;
}
.rp-sidebar label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--rp-accent-muted);
    margin-top: 0.5rem;
}
.rp-sidebar input[type="text"],
.rp-sidebar input[type="number"],
.rp-sidebar select {
    width: 100%;
    padding: 0.4rem 0.55rem;
    border: 1px solid var(--rp-border-strong);
    border-radius: 6px;
    margin-bottom: 0.2rem;
    font-size: 0.9rem;
    background: var(--rp-surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.rp-sidebar input:focus,
.rp-sidebar select:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
@media print {
    .rp-accordion-head {
        display: none;
    }
    .rp-accordion-panel {
        display: block !important;
    }
    .rp-accordion-item {
        border: none;
        background: none;
    }
}
@media (max-width: 1100px) {
    .rp-app {
        grid-template-columns: minmax(260px, 1fr);
        grid-template-rows: auto auto auto;
    }
    .rp-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--rp-border);
        max-height: min(50vh, 420px);
    }
    .rp-right {
        border-left: none;
        border-top: 1px solid var(--rp-border);
        max-height: min(50vh, 480px);
    }
}
.rp-results-print {
    font-size: 0.9rem;
    line-height: 1.5;
}
.rp-results-print h4 {
    margin: 1rem 0 0.35rem;
    font-size: 0.95rem;
}
/* Floor area label at polygon centroid — must not intercept wall clicks */
.rp-plan-area-overlay {
    pointer-events: none;
}
.rp-partition-popup {
    position: fixed;
    z-index: 10050;
    display: none;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem 0.65rem;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    max-width: min(240px, calc(100vw - 16px));
}
.rp-partition-popup .btn {
    width: 100%;
    justify-content: center;
}
.rp-floor-area-choice-popup {
    max-width: min(340px, calc(100vw - 20px));
}
#rpSvg.rp-await-first-corner {
    cursor: crosshair;
}
#rpSvg.rp-construction-guide-placement {
    cursor: crosshair;
}
.rp-add-room-hint {
    margin: 0.35rem 0;
    padding: 0.45rem 0.65rem;
    background: #eff6ff;
    border: 1px solid #93c5fd;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.45;
}
.rp-add-room-hint kbd {
    font-size: 0.78em;
    padding: 0.1em 0.35em;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
}
.rp-add-room-manual-block {
    border-top: 1px solid #e2e8f0;
    margin: 0.35rem 0 0;
    padding-top: 0.35rem;
}
.rp-details-advanced summary {
    user-select: none;
}
.rp-wall-elev-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}
.rp-wall-elev-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.rp-wall-elev-dialog {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: min(96vw, 1280px);
    max-width: 100%;
    max-height: min(92vh, 900px);
    overflow: auto;
    padding: 1rem 1.1rem 1.25rem;
    box-sizing: border-box;
}
.rp-wall-elev-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}
.rp-wall-elev-header h3 {
    margin: 0;
    font-size: 1.1rem;
}
.rp-wall-elev-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 1rem;
    align-items: start;
}
/* One column for zoom + SVG so the drawing is not auto-placed in the narrow 280px column */
.rp-wall-elev-canvas-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 0.35rem;
}
@media (max-width: 900px) {
    .rp-wall-elev-body {
        grid-template-columns: 1fr;
    }
}
.rp-wall-elev-svg-wrap {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.35rem;
    min-height: 280px;
    width: 100%;
    min-width: 0;
}
#rpWallElevSvg {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 900 / 420;
    min-height: 240px;
    max-height: min(65vh, 600px);
    overflow: visible;
}
#rpWallElevSvg .rp-wall-elev-floor-node {
    filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.35));
}
.rp-wall-elev-side {
    max-height: 380px;
    overflow-y: auto;
}
/* Note midpoint snap preview mode — cursor feedback on plan canvas */
#rpSvg.rp-cursor-note-mid-snap {
    cursor: crosshair !important;
}
.rp-snap-note-mid-overlay {
    pointer-events: none;
}

@media print {
    .site-top-nav,
    .rp-sidebar,
    .rp-toolbar-hide-print,
    .rp-no-print,
    .rp-partition-popup {
        display: none !important;
    }
    .rp-app {
        display: block;
        border: none;
    }
    .rp-main {
        page-break-inside: avoid;
    }
    #rpSvg {
        height: auto;
        min-height: 400px;
    }
}

/* Public sketch / iframe (e.g. Free tools): canvas + dock only */
body.rp-public-draw .rp-sidebar,
body.rp-public-draw .rp-right {
    display: none !important;
}
body.rp-public-draw .rp-app {
    grid-template-columns: 1fr;
    min-height: min(72vh, 640px);
    max-width: 100%;
}
body.rp-public-embed {
    margin: 0;
    background: #f8fafc;
}
body.rp-public-embed .rp-page-wrap {
    padding: 0.35rem !important;
    max-width: none;
}
body.rp-public-embed .rp-page-header {
    display: none;
}
body.rp-public-draw #rpToolFloorArea {
    display: none !important;
}
