/* CabinetMaker – site styles. Bootstrap 5 provides the base. */

:root {
    --cm-accent: #e67e22;
    --cm-panel: #f8f9fa;
    --cm-border: #dee2e6;
}

.skip-link {
    position: absolute;
    left: .5rem;
    top: .5rem;
    z-index: 2000;
    background: #fff;
    padding: .5rem 1rem;
}

.empty-state { background: var(--cm-panel); }
.empty-hide:empty, .validation-summary-valid.empty-hide { display: none; }
.notes { white-space: pre-wrap; }
.swatch { display: inline-block; width: .9rem; height: .9rem; border: 1px solid #888; border-radius: 2px; vertical-align: -2px; }
.part-ids { max-width: 16rem; font-family: var(--bs-font-monospace); font-size: .8rem; word-break: break-word; }
.cutlist td { vertical-align: top; }

:focus-visible { outline: 3px solid var(--cm-accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- SVG drawings and sheets */
.sheet-svg, .drawing-svg { width: 100%; height: auto; display: block; font-family: system-ui, sans-serif; }
.drawing .drawing-svg { max-height: 420px; }

/* ---------------------------------------------------------------- labels */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .5rem; }
.part-label { border: 1px dashed #999; border-radius: 4px; padding: .4rem .6rem; font-size: .85rem; break-inside: avoid; }
.label-id { font-size: 1.1rem; }

/* ---------------------------------------------------------------- editor layout */
body.app-full { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
body.app-full > main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.editor {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr) 360px;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
        "bar bar bar"
        "tree view props"
        "tree summary props";
}

.editor-bar { grid-area: bar; display: flex; align-items: center; gap: .5rem; padding: .35rem .75rem; background: #343a40; color: #fff; flex-wrap: wrap; }
.editor-tree { grid-area: tree; border-right: 1px solid var(--cm-border); overflow: auto; background: var(--cm-panel); }
.editor-viewport { grid-area: view; position: relative; display: flex; flex-direction: column; min-height: 0; }
.editor-props { grid-area: props; border-left: 1px solid var(--cm-border); overflow: auto; padding: .5rem .75rem; background: #fff; }
.editor-summary { grid-area: summary; border-top: 1px solid var(--cm-border); padding: .4rem .75rem; max-height: 30vh; overflow: auto; background: var(--cm-panel); font-size: .85rem; }

.viewport-toolbar { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .3rem .5rem; border-bottom: 1px solid var(--cm-border); background: #fff; }
.viewport { flex: 1; min-height: 240px; position: relative; background: linear-gradient(#e9eef3, #cfd8e0); outline: none; }
.viewport canvas { display: block; }
.viewport:focus-visible { outline: 3px solid var(--cm-accent); outline-offset: -3px; }
.viewport-overlay { position: absolute; inset: 40% 20% auto 20%; text-align: center; background: rgba(255, 255, 255, .92); border-radius: .5rem; padding: 1rem; pointer-events: none; }
.viewport-overlay:empty { display: none; }
.viewport-overlay.error { color: #842029; background: #f8d7da; pointer-events: auto; }
.viewport-help { position: absolute; left: .5rem; bottom: .3rem; color: #495057; background: rgba(255, 255, 255, .7); padding: 0 .4rem; border-radius: .25rem; }

.dim-label { font: 600 12px/1 system-ui, sans-serif; color: #b03a2e; background: rgba(255, 255, 255, .85); padding: 1px 4px; border-radius: 3px; white-space: nowrap; }
.part-tag { font: 11px/1 system-ui, sans-serif; color: #1b2631; background: rgba(255, 255, 255, .8); padding: 1px 3px; border-radius: 2px; white-space: nowrap; }

/* tree */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 1rem; }
.tree [role="treeitem"] { cursor: pointer; }
.tree .node { display: flex; align-items: center; gap: .35rem; padding: .2rem .5rem; border-radius: .25rem; }
.tree .node:hover { background: #e9ecef; }
.tree [aria-selected="true"] > .node { background: #fde3c8; font-weight: 600; }
.tree [role="treeitem"]:focus { outline: none; }
.tree [role="treeitem"]:focus-visible > .node { outline: 2px solid var(--cm-accent); }
.tree .badge { font-size: .65rem; }
.tree .twisty { width: 1rem; text-align: center; color: #6c757d; }
.tree .dirty::after { content: " •"; color: var(--cm-accent); }

/* properties */
.props-section { border-bottom: 1px solid var(--cm-border); padding: .4rem 0 .6rem; }
.props-section > summary { font-weight: 600; cursor: pointer; padding: .2rem 0; }
.props-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .5rem; }
.props-grid .full { grid-column: 1 / -1; }
.props-grid label { font-size: .75rem; margin-bottom: .1rem; color: #495057; }
.props-grid .form-control, .props-grid .form-select { font-size: .85rem; padding: .2rem .4rem; }
.field-error { font-size: .72rem; color: #b02a37; }
.is-invalid { border-color: #dc3545 !important; }
.edge-grid td, .edge-grid th { padding: .1rem .2rem; font-size: .75rem; }
.issue-list { font-size: .8rem; }
.dims-table td { padding: .1rem .3rem; font-size: .8rem; }

@media (max-width: 1100px) {
    .editor { grid-template-columns: 220px minmax(0, 1fr) 300px; }
}

@media (max-width: 860px) {
    body.app-full { height: auto; overflow: auto; }
    .editor {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 60vh auto auto;
        grid-template-areas: "bar" "tree" "view" "props" "summary";
    }
    .editor-tree { max-height: 30vh; border-right: 0; }
    .editor-props { border-left: 0; }
}

/* ---------------------------------------------------------------- print */
@media print {
    .navbar, .d-print-none, .btn, .alert-dismissible .btn-close { display: none !important; }
    body { font-size: 10pt; }
    main.container-xl { max-width: none; padding: 0; }
    .sheet-page, .drawing-page { break-inside: avoid; page-break-inside: avoid; }
    .sheet-page { width: 100%; flex: 0 0 100%; max-width: 100%; }
    .labels { grid-template-columns: repeat(3, 70mm); gap: 0; }
    .part-label { height: 37mm; border: 1px dotted #ccc; overflow: hidden; }
    a[href]::after { content: none; }
}
