/* MiniKad Web — tema scuro coerente con il canvas di MiniCAD desktop (30,30,40). */
:root {
    color-scheme: dark;
    --mk-bg: #1e1e28;
    --mk-panel: #262633;
    --mk-panel-2: #2d2d3c;
    --mk-border: #3a3a4c;
    --mk-text: #e4e4ec;
    --mk-muted: #9a9ab0;
    --mk-accent: #4c8dff;
    --mk-accent-soft: rgba(76, 141, 255, .18);
    --mk-on: #5ad278;
    --mk-font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    --mk-mono: Consolas, "Cascadia Mono", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--mk-bg);
    color: var(--mk-text);
    font-family: var(--mk-font);
    font-size: 13px;
    overflow: hidden;
}

#app { height: 100%; }

.mk-app {
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    height: 100vh;
    height: 100dvh;
}

/* ── Barra menu ─────────────────────────────────────────────── */
.mk-menubar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 10px;
    background: var(--mk-panel);
    border-bottom: 1px solid var(--mk-border);
    min-width: 0;
}

.mk-brand {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: .3px;
    white-space: nowrap;
}

.mk-brand span { color: var(--mk-accent); font-weight: 600; }

.mk-menu-group {
    display: flex;
    gap: 2px;
    padding-left: 12px;
    border-left: 1px solid var(--mk-border);
}

.mk-spacer { flex: 1; }

.mk-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 9px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--mk-text);
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.mk-btn:hover:not(:disabled) { background: var(--mk-panel-2); border-color: var(--mk-border); }
.mk-btn.active { background: var(--mk-accent-soft); border-color: var(--mk-accent); }
.mk-btn:disabled { opacity: .4; cursor: default; }
.mk-btn:focus-visible, .mk-tool:focus-visible, .mk-toggle:focus-visible { outline: 2px solid var(--mk-accent); outline-offset: 1px; }

.mk-icon { flex: none; }

/* ── Corpo: strumenti | disegno | pannello ─────────────────── */
.mk-body {
    display: grid;
    grid-template-columns: 88px 1fr 250px;
    min-height: 0;
}

.mk-toolbar {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: var(--mk-panel);
    border-right: 1px solid var(--mk-border);
    overflow-y: auto;
}

.mk-tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 2px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--mk-text);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

.mk-tool:hover { background: var(--mk-panel-2); border-color: var(--mk-border); }
.mk-tool.active { background: var(--mk-accent-soft); border-color: var(--mk-accent); color: #fff; }

.mk-canvas-host {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--mk-bg);
}

.mk-canvas-host canvas {
    position: absolute;
    inset: 0;
    display: block;
}

.mk-overlay {
    cursor: none;
    touch-action: none;
}

.mk-side {
    background: var(--mk-panel);
    border-left: 1px solid var(--mk-border);
    overflow-y: auto;
    padding: 4px 12px 12px;
}

.mk-side section { padding: 8px 0 10px; border-bottom: 1px solid var(--mk-border); }
.mk-side section:last-child { border-bottom: 0; }

.mk-side h2 {
    margin: 4px 0 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--mk-muted);
    font-weight: 600;
}

.mk-side h3 { margin: 10px 0 4px; font-size: 12px; }
.mk-side p { margin: 4px 0; line-height: 1.45; }
.mk-side ul { margin: 4px 0; padding-left: 16px; line-height: 1.55; }

.mk-field { display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 8px; margin: 6px 0; }
.mk-field > span:first-child { color: var(--mk-muted); }
.mk-color-row { display: flex; align-items: center; gap: 6px; }

.mk-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid var(--mk-border);
    flex: none;
}

select {
    width: 100%;
    height: 28px;
    padding: 0 6px;
    border: 1px solid var(--mk-border);
    border-radius: 5px;
    background: var(--mk-panel-2);
    color: var(--mk-text);
    font: inherit;
}

.mk-list { list-style: none; padding: 0 !important; }
.mk-props { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 8px 0 0; }
.mk-props dt { color: var(--mk-muted); }
.mk-props dd { margin: 0; font-family: var(--mk-mono); font-size: 12px; overflow-wrap: anywhere; }
.mk-muted { color: var(--mk-muted); }

kbd, code {
    font-family: var(--mk-mono);
    font-size: 11.5px;
    background: var(--mk-panel-2);
    border: 1px solid var(--mk-border);
    border-radius: 4px;
    padding: 0 4px;
}

/* ── Riga di comando ────────────────────────────────────────── */
.mk-command {
    background: #191921;
    border-top: 1px solid var(--mk-border);
    font-family: var(--mk-mono);
    font-size: 12.5px;
}

.mk-history {
    height: 68px;
    padding: 4px 10px 0;
    overflow: hidden;
    color: var(--mk-muted);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.mk-history div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 16px; }

.mk-prompt-row { display: flex; align-items: center; gap: 8px; padding: 4px 10px 6px; }
.mk-prompt { white-space: nowrap; color: #fff; }

.mk-input {
    flex: 1;
    min-width: 80px;
    height: 26px;
    padding: 0 8px;
    border: 1px solid var(--mk-border);
    border-radius: 4px;
    background: var(--mk-bg);
    color: #fff;
    font: inherit;
}

.mk-input:focus { outline: none; border-color: var(--mk-accent); }

/* ── Barra di stato ─────────────────────────────────────────── */
.mk-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    background: var(--mk-panel);
    border-top: 1px solid var(--mk-border);
    font-size: 12px;
    min-width: 0;
    overflow: hidden;
}

.mk-coords {
    font-family: var(--mk-mono);
    min-width: 210px;
    white-space: nowrap;
}

.mk-toggle {
    height: 22px;
    padding: 0 8px;
    border: 1px solid var(--mk-border);
    border-radius: 4px;
    background: transparent;
    color: var(--mk-muted);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .4px;
    cursor: pointer;
}

.mk-toggle.on { color: #fff; border-color: var(--mk-on); background: rgba(90, 210, 120, .15); }
.mk-status .mk-muted { white-space: nowrap; }

/* ── Schermi stretti: pannello laterale nascosto, strumenti solo icona ── */
@media (max-width: 900px) {
    .mk-body { grid-template-columns: 52px 1fr; }
    .mk-side { display: none; }
    .mk-tool span { display: none; }
    .mk-btn { padding: 0 7px; }
    .mk-menubar { gap: 6px; overflow-x: auto; }
    .mk-menu-group { padding-left: 6px; }
}

/* ── Caricamento e errori (dal modello Blazor) ──────────────── */
.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--mk-border);
    stroke-width: .6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--mk-accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto .2rem;
}

.loading-progress-text:after { content: var(--blazor-load-percentage-text, "Caricamento"); }

#blazor-error-ui {
    background: #5a1e1e;
    color: #fff;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .3);
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui a { color: #fff; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
