#!/usr/bin/env python3
"""Generate Firehouse 1st Floor Plan V1 - Professional Architectural Drawing
Matches style of generate_v11.py (2nd floor plan)"""

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.patches import FancyBboxPatch, Arc, Circle
import numpy as np

# Scale: 1 foot = 1 unit in plot coordinates
# Building: 48' wide, ~40' deep (approx)
# Origin at bottom-left of building

fig, ax = plt.subplots(1, 1, figsize=(16, 18))
fig.patch.set_facecolor('white')
ax.set_facecolor('white')

# Building dimensions
BW = 48   # building width
BH = 52   # building height — increased for deeper garage
MARGIN = 8

ax.set_xlim(-MARGIN - 4, BW + MARGIN + 6)  # extra room for mudroom bump-out
ax.set_ylim(-14, BH + MARGIN + 2)
ax.set_aspect('equal')
ax.axis('off')

# ============================================================
# HELPER FUNCTIONS (copied from 2nd floor plan for consistency)
# ============================================================

def draw_rect(x, y, w, h, lw=2, color='black', fill=None, ls='-'):
    rect = patches.Rectangle((x, y), w, h, linewidth=lw, edgecolor=color,
                               facecolor=fill if fill else 'none', linestyle=ls, zorder=2)
    ax.add_patch(rect)

def draw_wall(x1, y1, x2, y2, lw=2, color='black'):
    ax.plot([x1, x2], [y1, y2], color=color, linewidth=lw, solid_capstyle='round', zorder=3)

def label(x, y, text, size=7, bold=True, color='black', ha='center', va='center', rotation=0):
    weight = 'bold' if bold else 'normal'
    ax.text(x, y, text, fontsize=size, fontweight=weight, color=color,
            ha=ha, va=va, rotation=rotation, zorder=5,
            fontfamily='sans-serif')

def dim_label(x, y, text, size=5.5, rotation=0):
    ax.text(x, y, text, fontsize=size, fontweight='normal', color='#444444',
            ha='center', va='center', rotation=rotation, zorder=5, fontstyle='italic',
            fontfamily='sans-serif')

def draw_door_arc(cx, cy, radius, start_angle, end_angle, direction='ccw'):
    theta = np.linspace(np.radians(start_angle), np.radians(end_angle), 30)
    xs = cx + radius * np.cos(theta)
    ys = cy + radius * np.sin(theta)
    ax.plot(xs, ys, color='#555555', linewidth=0.8, linestyle='--', zorder=3)
    ax.plot([cx, xs[0]], [cy, ys[0]], color='#555555', linewidth=1, zorder=3)
    ax.plot([cx, xs[-1]], [cy, ys[-1]], color='#555555', linewidth=1, zorder=3)

def draw_window(x1, y1, x2, y2, orientation='h'):
    if orientation == 'h':
        mid = (y1 + y2) / 2
        offset = 0.3
        ax.plot([x1, x2], [mid - offset, mid - offset], color='#2277CC', linewidth=1.5, zorder=4)
        ax.plot([x1, x2], [mid + offset, mid + offset], color='#2277CC', linewidth=1.5, zorder=4)
        ax.plot([x1, x2], [mid, mid], color='#88BBEE', linewidth=0.5, zorder=4)
    else:
        mid = (x1 + x2) / 2
        offset = 0.3
        ax.plot([mid - offset, mid - offset], [y1, y2], color='#2277CC', linewidth=1.5, zorder=4)
        ax.plot([mid + offset, mid + offset], [y1, y2], color='#2277CC', linewidth=1.5, zorder=4)
        ax.plot([mid, mid], [y1, y2], color='#88BBEE', linewidth=0.5, zorder=4)

def draw_stairs(x, y, w, h, direction='up', n_steps=8, arrow_dir='up'):
    """Draw stair symbol with step lines and arrow"""
    draw_rect(x, y, w, h, lw=1.5, color='black')
    fill_r = patches.Rectangle((x, y), w, h, facecolor='#F0F0F0', edgecolor='none', zorder=1)
    ax.add_patch(fill_r)
    step_h = h / n_steps
    for i in range(n_steps):
        sy = y + i * step_h
        ax.plot([x, x + w], [sy, sy], color='#555', linewidth=0.6, zorder=3)
    mid_x = x + w / 2
    if arrow_dir == 'up':
        ax.annotate('', xy=(mid_x, y + h), xytext=(mid_x, y),
                    arrowprops=dict(arrowstyle='->', color='black', lw=1.2), zorder=4)
    else:
        ax.annotate('', xy=(mid_x, y), xytext=(mid_x, y + h),
                    arrowprops=dict(arrowstyle='->', color='black', lw=1.2), zorder=4)

def draw_pocket_door(x, y, length, orientation='v'):
    """Draw pocket door symbol (dashed line in wall)"""
    if orientation == 'v':
        ax.plot([x, x], [y, y + length], color='#555', linewidth=1.5, linestyle=':', zorder=4)
        # pocket (wall cavity)
        ax.plot([x - 0.3, x - 0.3], [y, y + length], color='#999', linewidth=0.8, linestyle='--', zorder=3)
        ax.plot([x + 0.3, x + 0.3], [y, y + length], color='#999', linewidth=0.8, linestyle='--', zorder=3)
    else:
        ax.plot([x, x + length], [y, y], color='#555', linewidth=1.5, linestyle=':', zorder=4)
        ax.plot([x, x + length], [y - 0.3, y - 0.3], color='#999', linewidth=0.8, linestyle='--', zorder=3)
        ax.plot([x, x + length], [y + 0.3, y + 0.3], color='#999', linewidth=0.8, linestyle='--', zorder=3)


# ============================================================
# LAYOUT COORDINATES
# ============================================================
# Upper row (garage/BR5): y=28 to y=52 (24' deep — doubled)
# Middle row (entry area): y=18 to y=28 (10' deep)
# Lower row (living): y=0 to y=18 (18' deep)

UPPER_Y = 28
UPPER_H = 24   # doubled from 12 to 24
MID_Y = 18
MID_H = 10
LOWER_Y = 0
LOWER_H = 18

# ============================================================
# EXTERIOR WALLS - Main building outline
# ============================================================

# Main building rectangle (lower + middle sections)
draw_rect(0, 0, BW, BH, lw=4, color='black')

# Vestibule bump-out (extends left of main building)
VEST_X = -5
VEST_Y = 22
VEST_W = 5
VEST_H = 6
draw_wall(VEST_X, VEST_Y, VEST_X, VEST_Y + VEST_H, lw=4)  # left wall
draw_wall(VEST_X, VEST_Y + VEST_H, 0, VEST_Y + VEST_H, lw=4)  # top wall
draw_wall(VEST_X, VEST_Y, 0, VEST_Y, lw=4)  # bottom wall

# ============================================================
# UPPER ROW: BEDROOM 5 + EXISTING GARAGE + MUDROOM
# ============================================================

# --- Bedroom 5: 8' x 12', lower-left of upper section (flipped — empty space on top) ---
BR5_X, BR5_Y = 0, UPPER_Y  # bottom of the upper section
BR5_W, BR5_H = 8, 12
draw_rect(BR5_X, BR5_Y, BR5_W, BR5_H, lw=2)
fill_br5 = patches.Rectangle((BR5_X, BR5_Y), BR5_W, BR5_H, 
                               facecolor='#FFFDE7', edgecolor='none', zorder=1)
ax.add_patch(fill_br5)
label(BR5_X + BR5_W/2, BR5_Y + BR5_H/2 + 1, 'BEDROOM 5', size=7)
dim_label(BR5_X + BR5_W/2, BR5_Y + BR5_H/2 - 1, "8'-0\" × 12'-0\"", size=5)
# Window on north wall
draw_window(2, BH - 0.3, 6, BH + 0.3, 'h')
# Pocket door on right wall (between BR5 and garage)
draw_pocket_door(BR5_X + BR5_W, BR5_Y + 3, 3, 'v')
label(BR5_X + BR5_W + 1.5, BR5_Y + 4.5, 'POCKET\nDOOR', size=4.5, bold=False, color='#666')

# --- Existing Garage: x=8 to x=44 (expanded — mudroom moved to middle row) ---
GAR_X, GAR_Y = 8, UPPER_Y
GAR_W, GAR_H = 36, UPPER_H  # 36' wide, full upper depth

# Garage fill (light gray)
fill_gar = patches.Rectangle((GAR_X, GAR_Y), GAR_W, GAR_H, 
                               facecolor='#F5F5F5', edgecolor='none', zorder=1)
ax.add_patch(fill_gar)
# Garage walls
draw_wall(GAR_X, GAR_Y, GAR_X, GAR_Y + GAR_H, lw=2)  # left wall (shared with BR5)

label(GAR_X + GAR_W/2, GAR_Y + GAR_H/2 + 1, 'EXISTING GARAGE', size=10)
dim_label(GAR_X + GAR_W/2, GAR_Y + GAR_H/2 - 1, "36'-1 1/4\"", size=6)

# --- Closet: upper right corner (stays in garage area) ---
CL_X = 44
CL_Y = UPPER_Y + UPPER_H - 8
CL_W = 4
CL_H = 8
draw_rect(CL_X, CL_Y, CL_W, CL_H, lw=1.5)
fill_cl = patches.Rectangle((CL_X, CL_Y), CL_W, CL_H,
                              facecolor='#F5F5F5', edgecolor='none', zorder=1)
ax.add_patch(fill_cl)
label(CL_X + CL_W/2, CL_Y + CL_H/2, 'CL', size=6)
# Wall separating closet from garage
draw_wall(44, CL_Y, 44, CL_Y + CL_H, lw=2)

# --- Mudroom: right side of building, between garage and office ---
MUD_X = BW  # flush with right exterior wall, bumps out
MUD_Y = UPPER_Y  # same height as bottom of garage/upper section
MUD_W = 6
MUD_H = 10
draw_rect(MUD_X, MUD_Y, MUD_W, MUD_H, lw=3, color='black')
fill_mud = patches.Rectangle((MUD_X, MUD_Y), MUD_W, MUD_H,
                               facecolor='#F5F5F5', edgecolor='none', zorder=1)
ax.add_patch(fill_mud)
label(MUD_X + MUD_W/2, MUD_Y + MUD_H/2, 'MUD\nROOM', size=6)
# Entry arrow into mudroom from outside (right side)
ax.annotate('', xy=(MUD_X + MUD_W/2, MUD_Y + MUD_H/2),
            xytext=(MUD_X + MUD_W + 3, MUD_Y + MUD_H/2),
            arrowprops=dict(arrowstyle='->', color='#1155CC', lw=2), zorder=5)
label(MUD_X + MUD_W + 4, MUD_Y + MUD_H/2, 'ENTRY', size=5, color='#1155CC')

# ============================================================
# MIDDLE ROW: VESTIBULE, EXISTING ENTRY, PANTRY
# ============================================================

# --- Vestibule ---
fill_vest = patches.Rectangle((VEST_X, VEST_Y), VEST_W, VEST_H,
                                facecolor='#F5F5F5', edgecolor='none', zorder=1)
ax.add_patch(fill_vest)
label(VEST_X + VEST_W/2, VEST_Y + VEST_H/2, 'VESTIBULE', size=6, rotation=90)
# Entry arrow from outside
ax.annotate('', xy=(VEST_X + VEST_W/2, VEST_Y + VEST_H/2), 
            xytext=(VEST_X - 3, VEST_Y + VEST_H/2),
            arrowprops=dict(arrowstyle='->', color='#1155CC', lw=2), zorder=5)
label(VEST_X - 4, VEST_Y + VEST_H/2, 'ENTRY', size=5, color='#1155CC', rotation=90)

# --- Existing Entry: 12' x 10', with stairs ---
ENTRY_X, ENTRY_Y = 0, MID_Y
ENTRY_W, ENTRY_H = 12, MID_H
draw_rect(ENTRY_X, ENTRY_Y, ENTRY_W, ENTRY_H, lw=2)
fill_entry = patches.Rectangle((ENTRY_X, ENTRY_Y), ENTRY_W, ENTRY_H,
                                 facecolor='#F0F0F0', edgecolor='none', zorder=1)
ax.add_patch(fill_entry)

# Stairs in entry (small stair symbol)
draw_stairs(1, 20, 4, 6, n_steps=6, arrow_dir='up')
label(3, 27.2, 'UP', size=5.5, color='#333')
label(3, 19.5, 'DN', size=5.5, color='#333')

label(8, 25, 'EXISTING\nENTRY', size=7)

# FAP label
label(0.8, 27.5, 'FAP', size=5, bold=True, color='#CC3333', ha='left')

# FP (Fireplace) symbol
label(6, 19.5, 'FP', size=5.5, bold=True, color='#555')
# Simple fireplace symbol
draw_rect(5, 18, 3, 1.5, lw=1, color='#555', fill='#E0E0E0')

# --- Chimney: center of middle row ---
CHIM_X, CHIM_Y = 22, 21
CHIM_W, CHIM_H = 4, 4
draw_rect(CHIM_X, CHIM_Y, CHIM_W, CHIM_H, lw=2, color='#555', fill='#D0D0D0')
label(CHIM_X + CHIM_W/2, CHIM_Y + CHIM_H/2, 'CHIMNEY', size=5.5, color='#444')

# --- Pantry: below entry area ---
PANTRY_X, PANTRY_Y = 2, 14
PANTRY_W, PANTRY_H = 8, 4
draw_rect(PANTRY_X, PANTRY_Y, PANTRY_W, PANTRY_H, lw=1.5)
fill_pantry = patches.Rectangle((PANTRY_X, PANTRY_Y), PANTRY_W, PANTRY_H,
                                  facecolor='#F5F5F5', edgecolor='none', zorder=1)
ax.add_patch(fill_pantry)
label(PANTRY_X + PANTRY_W/2, PANTRY_Y + PANTRY_H/2, 'PANTRY', size=6.5)

# Wall between entry and lower rooms
draw_wall(0, MID_Y, BW, MID_Y, lw=2, color='#333')
# Wall between pantry bottom and kitchen
draw_wall(0, 14, 12, 14, lw=1.5, color='#555')

# ============================================================
# LOWER ROW: KITCHEN, DINING, GREAT ROOM
# ============================================================

# --- Kitchen: 16' x 18', lower left ---
KIT_X, KIT_Y = 0, 0
KIT_W, KIT_H = 16, 18
draw_rect(KIT_X, KIT_Y, KIT_W, KIT_H, lw=2)
fill_kit = patches.Rectangle((KIT_X, KIT_Y), KIT_W, KIT_H,
                               facecolor='#FFFDE7', edgecolor='none', zorder=1)
ax.add_patch(fill_kit)
label(KIT_X + KIT_W/2, KIT_Y + 4, 'KITCHEN', size=9)

# Kitchen Island (centered in kitchen)
ISL_W, ISL_H = 7, 3
ISL_X = KIT_X + (KIT_W - ISL_W) / 2
ISL_Y = KIT_Y + (KIT_H - ISL_H) / 2 - 1
island = patches.FancyBboxPatch((ISL_X, ISL_Y), ISL_W, ISL_H,
                                 boxstyle="round,pad=0.2", linewidth=1.2,
                                 edgecolor='#555', facecolor='#E8E0D0', zorder=4)
ax.add_patch(island)
label(ISL_X + ISL_W/2, ISL_Y + ISL_H/2, 'ISLAND', size=6, bold=False, color='#555')

# Windows on south wall (kitchen)
draw_window(3, -0.3, 8, 0.3, 'h')
# Window on west wall
draw_window(-0.3, 4, 0.3, 10, 'v')

# --- Dining: 12' x 18', lower center ---
DIN_X, DIN_Y = 16, 0
DIN_W, DIN_H = 12, 18
# Dining is open to kitchen (no wall between them at lower portion, just a partition line)
draw_wall(DIN_X, 0, DIN_X, 14, lw=1.5, color='#555')  # partial wall
fill_din = patches.Rectangle((DIN_X, DIN_Y), DIN_W, DIN_H,
                               facecolor='#FFFDE7', edgecolor='none', zorder=1)
ax.add_patch(fill_din)
label(DIN_X + DIN_W/2, DIN_Y + DIN_H/2, 'DINING', size=9)
dim_label(DIN_X + DIN_W/2, DIN_Y + DIN_H/2 - 2, "12'-0\" × 18'-0\"", size=5)

# Windows on south wall (dining)
draw_window(18, -0.3, 24, 0.3, 'h')

# --- Great Room: 20' x 18', lower right ---
GR_X, GR_Y = 28, 0
GR_W, GR_H = 20, 18
draw_wall(GR_X, 0, GR_X, MID_Y, lw=2, color='#333')  # left wall of great room extends up
fill_gr = patches.Rectangle((GR_X, GR_Y), GR_W, GR_H,
                              facecolor='#FFFDE7', edgecolor='none', zorder=1)
ax.add_patch(fill_gr)
label(GR_X + GR_W/2, GR_Y + GR_H/2 + 1, 'GREAT ROOM', size=10)
label(GR_X + GR_W/2, GR_Y + GR_H/2 - 1.5, '(LIVING ROOM)', size=6, bold=False, color='#666')
dim_label(GR_X + GR_W/2, GR_Y + GR_H/2 - 3.5, "20'-0\" × 18'-0\"", size=5.5)

# Windows on south wall (great room)
draw_window(32, -0.3, 38, 0.3, 'h')
draw_window(40, -0.3, 46, 0.3, 'h')
# Window on east wall
draw_window(BW - 0.3, 4, BW + 0.3, 10, 'v')
draw_window(BW - 0.3, 20, BW + 0.3, 26, 'v')

# ============================================================
# OFFICE: 8'-2" x 11'-0", right side (was stairwell in V1)
# ============================================================
STW_X = 40
STW_Y = MID_Y
STW_W = 8.17  # 8'-2"
STW_H = 10

draw_rect(STW_X, STW_Y, STW_W, STW_H, lw=2)
fill_ofc = patches.Rectangle((STW_X, STW_Y), STW_W, STW_H,
                               facecolor='#FFFDE7', edgecolor='none', zorder=1)
ax.add_patch(fill_ofc)
label(STW_X + STW_W/2, STW_Y + STW_H/2 + 1, 'OFFICE', size=8)
dim_label(STW_X + STW_W/2, STW_Y + STW_H/2 - 1, "8'-2\" × 11'-0\"", size=5)

# Wall for stairwell
draw_wall(STW_X, STW_Y, STW_X, STW_Y + STW_H, lw=2)
draw_wall(STW_X, STW_Y + STW_H, STW_X + STW_W, STW_Y + STW_H, lw=2)

# ============================================================
# ADDITIONAL WALLS & DETAILS
# ============================================================

# Horizontal divider between upper row and middle row
draw_wall(0, UPPER_Y, BW, UPPER_Y, lw=3, color='#333')

# Wall between great room and stairwell (right side, mid area)
draw_wall(GR_X, MID_Y, STW_X, MID_Y, lw=2)

# Door arcs
# Door from vestibule into entry
draw_door_arc(0, 24, 2.5, 0, 90)

# Door from entry up to BR5
draw_door_arc(6, UPPER_Y, 2.5, 270, 360)

# Door from pantry
draw_door_arc(6, 14, 2, 270, 360)

# Door from kitchen to dining (opening)
# (open concept - no door needed, just the opening)

# Door into great room from hallway
draw_door_arc(28, 14, 2.5, 90, 180)

# Door into office
draw_door_arc(STW_X, MID_Y, 2.5, 0, 90)

# ============================================================
# DIMENSIONS (outside building)
# ============================================================

# Bottom dimension - full width 48'-0"
ax.annotate('', xy=(0, -2.5), xytext=(BW, -2.5),
            arrowprops=dict(arrowstyle='<->', color='black', lw=1), zorder=5)
dim_label(BW / 2, -3.5, "48'-0\"", size=7)

# Top dimension - garage width 36'-1 1/4"
ax.annotate('', xy=(8, BH + 3), xytext=(44, BH + 3),
            arrowprops=dict(arrowstyle='<->', color='black', lw=1), zorder=5)
dim_label(26, BH + 4, "36'-1 1/4\"", size=6)

# BR5 width dimension
ax.annotate('', xy=(0, BH + 3), xytext=(8, BH + 3),
            arrowprops=dict(arrowstyle='<->', color='black', lw=1), zorder=5)
dim_label(4, BH + 4, "8'-0\"", size=5.5)

# Left side dimension (full height)
ax.annotate('', xy=(-3.5, 0), xytext=(-3.5, BH),
            arrowprops=dict(arrowstyle='<->', color='black', lw=1), zorder=5)
dim_label(-5, BH / 2, "52'-0\"", size=6, rotation=90)

# Right side dimension
ax.annotate('', xy=(BW + 3, 0), xytext=(BW + 3, BH),
            arrowprops=dict(arrowstyle='<->', color='black', lw=1), zorder=5)
dim_label(BW + 5, BH / 2, "52'-0\"", size=6, rotation=90)

# Stairwell dimension
ax.annotate('', xy=(STW_X, STW_Y + STW_H + 2), xytext=(STW_X + STW_W, STW_Y + STW_H + 2),
            arrowprops=dict(arrowstyle='<->', color='black', lw=0.8), zorder=5)

# ============================================================
# NORTH ARROW
# ============================================================
na_x, na_y = BW + 5, BH + 3
ax.annotate('N', xy=(na_x, na_y + 3), fontsize=12, fontweight='bold', ha='center', va='bottom')
ax.annotate('', xy=(na_x, na_y + 3), xytext=(na_x, na_y),
            arrowprops=dict(arrowstyle='->', color='black', lw=2.5), zorder=5)

# ============================================================
# SCALE BAR
# ============================================================
sb_x, sb_y = -6, -10
for i in range(3):
    color = 'black' if i % 2 == 0 else 'white'
    rect = patches.Rectangle((sb_x + i * 5, sb_y), 5, 0.8,
                               linewidth=1, edgecolor='black', facecolor=color, zorder=4)
    ax.add_patch(rect)
label(sb_x, sb_y - 1, "0'", size=5, bold=False)
label(sb_x + 5, sb_y - 1, "5'", size=5, bold=False)
label(sb_x + 10, sb_y - 1, "10'-0\"", size=5, bold=False)

# ============================================================
# TITLE BLOCK
# ============================================================
tb_x, tb_y = 12, -13
tb_w, tb_h = 40, 6
draw_rect(tb_x, tb_y, tb_w, tb_h, lw=2, color='black')
fill_tb = patches.Rectangle((tb_x, tb_y), tb_w, tb_h, facecolor='white', edgecolor='none', zorder=1)
ax.add_patch(fill_tb)

label(tb_x + tb_w/2, tb_y + 4.8, 'PROPOSED FIRST FLOOR PLAN — V5', size=11)
label(tb_x + tb_w/2, tb_y + 3.3, 'FIREHOUSE — 18 NEW ST, CROSSWICKS, NJ 08515', size=8)
label(tb_x + tb_w/2, tb_y + 2, 'Block 300, Lot 12  |  Old School Firehouse LLC', size=5.5, bold=False, color='#555')
dim_label(tb_x + tb_w/2, tb_y + 1, 'Scale: 1/4" = 1\'-0"  |  Date: March 29, 2026', size=5.5)

# PROPOSED stamp
stamp = patches.FancyBboxPatch((tb_x + 10, tb_y + 0.1), 20, 0.7,
                                boxstyle="round,pad=0.1", linewidth=1.5,
                                edgecolor='red', facecolor='#FFE0E0', zorder=5)
ax.add_patch(stamp)
label(tb_x + 20, tb_y + 0.45, 'PROPOSED — NOT FOR CONSTRUCTION', size=5.5, color='red')

dim_label(tb_x + tb_w - 3, tb_y + 0.45, 'Drawing A-101  |  Sheet 1 of 1', size=4.5)

# ============================================================
# LEGEND
# ============================================================
leg_x, leg_y = -6, -8
label(leg_x, leg_y, 'LEGEND:', size=6)

ax.plot([leg_x, leg_x + 4], [leg_y - 1.2, leg_y - 1.2], color='black', linewidth=4, zorder=4)
label(leg_x + 6, leg_y - 1.2, 'Exterior wall', size=5, bold=False, ha='left')

ax.plot([leg_x, leg_x + 4], [leg_y - 2.2, leg_y - 2.2], color='black', linewidth=2.5, zorder=4)
label(leg_x + 6, leg_y - 2.2, 'Interior wall', size=5, bold=False, ha='left')

ax.plot([leg_x, leg_x + 4], [leg_y - 3.2, leg_y - 3.2], color='black', linewidth=1.2, zorder=4)
label(leg_x + 6, leg_y - 3.2, 'Partition wall', size=5, bold=False, ha='left')

ax.annotate('', xy=(leg_x + 4, leg_y - 4.2), xytext=(leg_x, leg_y - 4.2),
            arrowprops=dict(arrowstyle='->', color='#1155CC', lw=1.5), zorder=5)
label(leg_x + 6, leg_y - 4.2, 'Entry / circulation', size=5, bold=False, ha='left')

# ============================================================
# SAVE
# ============================================================
plt.tight_layout(pad=1)

output_base = '/Users/joemac/.openclaw/workspace/projects/firehouse/firehouse-1st-floor-v5'
fig.savefig(f'{output_base}.png', dpi=300, bbox_inches='tight',
            facecolor='white', edgecolor='none')
fig.savefig(f'{output_base}.pdf', bbox_inches='tight',
            facecolor='white', edgecolor='none')

print(f"✅ Saved PNG: {output_base}.png")
print(f"✅ Saved PDF: {output_base}.pdf")
plt.close()
