/*
  Plan canvas panel styles — KHÔNG scoped (global).
  Dùng chung cho YardCanvasHost và các component con tách ra (Layer Manager, Inspector, Dialog…).
  Blazor CSS isolation chỉ scope theo component; markup con không nhận YardCanvasHost.razor.css.
*/

.map-overlay {
    background: rgba(255, 255, 255, 0.84);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(195, 204, 214, 0.88);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    position: absolute;
    z-index: 3;
    pointer-events: auto;
}

.chip {
    background: #eef5ff;
    border: 1px solid #8db9eb;
    border-radius: 999px;
    color: #174f86;
    cursor: pointer;
    min-height: 1.85rem;
    padding: 0.2rem 0.7rem;
}

.chip-secondary {
    background: #ffffff;
    border-color: #c3ccd6;
    color: #334155;
}

.hint {
    color: #586575;
    font-size: 0.9rem;
}

.map-empty-state,
.inspector-panel {
    padding: 0.75rem;
}

.plan-layer-manager {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    left: 1rem;
    max-height: calc(100% - 2rem);
    overflow: auto;
    top: 1rem;
    width: min(360px, calc(100% - 2rem));
}

.plan-layer-manager.is-docked {
    position: relative;
    inset: auto;
    top: auto;
    left: auto;
    width: 100%;
    max-height: none;
    height: 100%;
    overflow: auto;
    padding: 0.65rem 0.75rem;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.plan-layer-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.plan-layer-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.plan-layer-item {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.55rem;
}

.plan-layer-item.is-hidden {
    background: rgba(248, 250, 252, 0.94);
    opacity: 0.72;
}

.plan-layer-item.is-effective {
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.16);
}

.plan-layer-item header {
    align-items: center;
    display: grid;
    gap: 0.45rem;
    grid-template-columns: auto 1fr auto;
}

.plan-layer-item-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.plan-layer-item-text strong,
.plan-layer-item-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-layer-item-text small {
    color: #647386;
}

.plan-layer-order {
    color: #647386;
    font-size: 0.74rem;
    font-weight: 700;
    min-width: 2rem;
    text-align: right;
}

.plan-layer-metrics {
    color: #647386;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.76rem;
}

.map-empty-state {
    bottom: 1rem;
    left: 1rem;
    max-width: min(320px, calc(100% - 2rem));
}

.design-hint {
    top: 12px;
    left: 12px;
    max-width: min(420px, calc(100% - 24px));
    padding: 0.65rem 0.85rem;
}

.design-hint .empty-state {
    margin: 0;
}

.design-context-toolbar {
    top: 92px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    max-width: min(720px, calc(100% - 24px));
}

.design-context-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.design-context-meta strong,
.design-context-meta span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.design-context-meta strong {
    color: #24303d;
}

.design-context-meta span {
    color: #647386;
    font-size: 0.76rem;
}

.design-context-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.design-rotate-group {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem;
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 8px;
    background: rgba(239, 246, 255, 0.9);
}

.design-rotate-btn {
    min-width: 2.1rem;
    padding-left: 0.45rem;
    padding-right: 0.45rem;
    font-size: 1rem;
    line-height: 1;
}

.design-rotate-angle {
    min-width: 2.6rem;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: #1d4ed8;
    font-variant-numeric: tabular-nums;
}

.design-properties-panel,
.design-selection-state,
.design-placement-state {
    right: 12px;
    top: 12px;
    width: min(340px, calc(100% - 24px));
}

.design-properties-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: calc(100% - 24px);
    overflow: auto;
    padding: 0.75rem;
}

.design-selection-state {
    padding: 0.75rem;
}

.design-placement-state {
    padding: 0.75rem;
}

.design-block-modal {
    max-width: min(980px, calc(100vw - 32px));
    width: 100%;
}

.design-form {
    gap: 0.75rem;
}

.design-editor-layout {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: minmax(0, 1.2fr) minmax(20rem, 1fr);
}

.design-preview-panel,
.design-form-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.design-preview-surface {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(238, 245, 255, 0.98)),
        linear-gradient(90deg, rgba(23, 79, 134, 0.04), rgba(23, 79, 134, 0.04));
    border: 1px solid #d6dee8;
    border-radius: 12px;
    min-height: 18rem;
    overflow: auto;
    padding: 0.75rem;
}

.design-preview-svg {
    display: block;
    height: auto;
    min-width: 100%;
    width: 100%;
}

.design-preview-title {
    fill: #174f86;
    font-size: 18px;
    font-weight: 700;
}

.design-preview-meta,
.design-preview-label {
    fill: #5c6c7b;
    font-size: 12px;
    font-weight: 600;
}

.design-preview-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.design-preview-hint {
    margin: 0;
}

.design-form-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: 1fr 1fr;
}

.design-form-grid label {
    color: #29313a;
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    gap: 0.25rem;
}

.design-form-grid input,
.design-form-grid select {
    border: 1px solid #b8c2cc;
    border-radius: 6px;
    min-height: 2rem;
    padding: 0.25rem 0.45rem;
}

.design-properties-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.design-schema-section {
    gap: 0.65rem;
}

.schema-mode-switch {
    display: flex;
    gap: 0.35rem;
}

.schema-columns {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: 1fr;
}

.schema-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-radius: 8px;
    padding: 0.55rem;
}

.schema-card strong {
    display: block;
    margin-bottom: 0.45rem;
}

.schema-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 9.5rem;
    overflow: auto;
}

.schema-row {
    align-items: center;
    display: grid;
    gap: 0.45rem;
    grid-template-columns: 4.2rem 1fr;
}

.schema-row span {
    color: #647386;
    font-size: 0.76rem;
    font-weight: 700;
}

.schema-row input {
    border: 1px solid #b8c2cc;
    border-radius: 6px;
    min-height: 1.9rem;
    padding: 0.2rem 0.45rem;
}

.status-pill {
    background: rgba(244, 247, 251, 0.96);
    border: 1px solid #d6dee8;
    border-radius: 999px;
    color: #475569;
    font-size: 0.76rem;
    padding: 0.18rem 0.55rem;
    white-space: nowrap;
}

.status-pill-text {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 720px) {
    .plan-layer-manager {
        left: 12px;
        max-height: min(40vh, 24rem);
        right: 12px;
        top: 12px;
        width: auto;
    }

    .design-editor-layout {
        grid-template-columns: 1fr;
    }

    .design-hint {
        right: 12px;
        max-width: none;
    }

    .design-context-toolbar {
        top: 104px;
        left: 12px;
        right: 12px;
        max-width: none;
        flex-direction: column;
        align-items: stretch;
    }

    .design-context-meta strong,
    .design-context-meta span {
        white-space: normal;
    }

    .design-properties-panel,
    .design-selection-state,
    .design-placement-state {
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 12px;
        width: auto;
    }

    .design-properties-panel {
        max-height: 48vh;
    }

    .design-form-grid {
        grid-template-columns: 1fr;
    }
}

.inspector-panel {
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow: auto;
    right: 1rem;
    top: 1rem;
    width: min(320px, calc(100% - 2rem));
}

.inspector-header {
    align-items: flex-start;
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
}

.inspector-header h3,
.section-heading h4 {
    font-size: 0.92rem;
    margin: 0;
}

.selection-count-badge {
    background: #eef5ff;
    border: 1px solid #bfd6f2;
    border-radius: 999px;
    color: #174f86;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}

.scan-mode-hint {
    margin: 0;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    font-size: 0.78rem;
    line-height: 1.35;
}

.overlay-section,
.layer-list,
.group-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.section-heading {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.section-heading span {
    color: #647386;
    font-size: 0.72rem;
}

.empty-state {
    color: #6a7685;
    margin: 0;
}

.group-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-left-width: 4px;
    border-radius: 8px;
    padding: 0.55rem;
}

.group-card header,
.plan-node header,
.layer-card header {
    align-items: center;
    display: grid;
    gap: 0.45rem;
    grid-template-columns: auto 1fr auto;
}

.group-card header small,
.plan-node small {
    color: #647386;
    display: block;
}

.group-card header b {
    background: #f4f7fb;
    border-radius: 999px;
    color: #174f86;
    min-width: 2rem;
    padding: 0.1rem 0.4rem;
    text-align: center;
}

.group-metrics {
    color: #647386;
    display: flex;
    flex-direction: column;
    font-size: 0.76rem;
    gap: 0.15rem;
    margin-top: 0.35rem;
}

.group-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
}

.resolution-panel {
    gap: 0.65rem;
}

.resolution-summary-card,
.resolution-entry {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-radius: 8px;
    padding: 0.6rem;
}

.resolution-summary-card header,
.resolution-entry header {
    align-items: center;
    display: flex;
    gap: 0.45rem;
    justify-content: space-between;
}

.resolution-summary-card p,
.resolution-entry p {
    color: #647386;
    font-size: 0.78rem;
    margin: 0.35rem 0 0;
}

.resolution-summary-metrics {
    color: #647386;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.76rem;
    margin-top: 0.45rem;
}

.resolution-trace-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.resolution-entry-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.resolution-entry-text strong,
.resolution-entry-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resolution-entry-text small {
    color: #647386;
}

.resolution-entry.is-effective {
    background: #eff6ff;
    border-color: rgba(37, 99, 235, 0.38);
}

.resolution-entry.is-hidden {
    border-style: dashed;
    opacity: 0.72;
}

.resolution-entry.is-conflict {
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.18);
}

.add-plan-button,
.add-overlap-button,
.view-slots-button {
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    min-height: 1.75rem;
    padding: 0.15rem 0.55rem;
}

.add-plan-button {
    background: #174f86;
    color: #ffffff;
}

.add-overlap-button {
    background: #6f42c1;
    color: #ffffff;
}

.view-slots-button {
    background: #ffffff;
    border: 1px solid #8db9eb;
    color: #174f86;
}

.plan-tree {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.plan-tree-divider {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px dashed rgba(195, 204, 214, 0.88);
}

.plan-node,
.layer-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #d6dee8;
    border-radius: 8px;
    padding: 0.55rem;
}

.child-plan-node {
    margin: 0.5rem 0 0 1rem;
}

.overlap-plan-node {
    border-left: 4px solid #6f42c1;
}

.plan-node-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.plan-node-text strong,
.plan-node-text small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-node-meta {
    color: #647386;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.76rem;
    margin-top: 0.4rem;
}

.plan-node-status {
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.12rem 0.45rem;
    white-space: nowrap;
}

.plan-node-status.is-effective {
    background: #dbeafe;
    color: #1d4ed8;
}

.plan-node-status.is-visible {
    background: #eef5ff;
    color: #174f86;
}

.plan-node-status.is-hidden {
    background: #f1f5f9;
    color: #647386;
}

.compact-layer-list h4 {
    color: #29313a;
    font-size: 0.92rem;
}

.layer-card p {
    color: #647386;
    font-size: 0.76rem;
    margin: 0.25rem 0 0;
}

.active-layer {
    background: #fff8e1;
    border-color: #ffb300;
}

.layer-card.hidden-layer {
    border-style: dashed;
    opacity: 0.72;
}

.layer-color {
    border: 1px solid #9aa7b5;
    border-radius: 50%;
    display: inline-block;
    height: 0.9rem;
    width: 0.9rem;
}

.modal-backdrop {
    align-items: center;
    background: rgba(17, 24, 39, 0.42);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 1rem;
    position: fixed;
    z-index: 20;
}

.plan-modal {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(17, 24, 39, 0.28);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    max-height: calc(100vh - 2rem);
    max-width: 720px;
    overflow: auto;
    padding: 1rem;
    width: min(720px, 100%);
}

.plan-modal header,
.plan-modal footer,
.criteria-title {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
}

.plan-modal header p,
.criteria-title span {
    color: #647386;
    font-size: 0.85rem;
    margin: 0.2rem 0 0;
}

.modal-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr 8rem 6rem;
}

.modal-grid label {
    color: #29313a;
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    gap: 0.25rem;
}

.modal-grid input,
.criteria-title select,
.criteria-row input {
    border: 1px solid #b8c2cc;
    border-radius: 4px;
    min-height: 2rem;
    padding: 0.25rem 0.45rem;
}

.criteria-panel {
    border: 1px solid #d6dee8;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
}

.inherited-criteria {
    background: #f4f7fb;
}

.inherited-criteria p {
    color: #29313a;
    margin: 0;
}

.warning-state {
    background: #fff8e1;
    border: 1px solid #ffd54f;
    border-radius: 6px;
    color: #6f4e00;
    margin: 0;
    padding: 0.55rem;
}

.criteria-row {
    align-items: center;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 2.5rem 1fr 1fr auto;
}

.criteria-row strong {
    color: #174f86;
}

.criteria-row span {
    color: #29313a;
}

.icon-button {
    background: #f4f7fb;
    border: 1px solid #c3ccd6;
    border-radius: 4px;
    cursor: pointer;
    min-height: 2rem;
    min-width: 2rem;
}

.icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.primary-button,
.secondary-button {
    border-radius: 4px;
    cursor: pointer;
    min-height: 2rem;
    padding: 0.25rem 0.85rem;
}

.primary-button {
    background: #174f86;
    border: 1px solid #174f86;
    color: #ffffff;
}

.secondary-button {
    background: #ffffff;
    border: 1px solid #b8c2cc;
    color: #29313a;
}

@media (max-width: 1200px) {
    .inspector-panel {
        width: 300px;
    }
}

@media (max-width: 960px) {
    .panel-view {
        height: auto;
        min-height: 0;
    }

    .workspace-shell {
        min-height: calc(100vh - 8rem);
    }

    .map-empty-state,
    .inspector-panel {
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
    }

    .inspector-panel {
        bottom: 0.75rem;
        max-height: 44vh;
        top: auto;
    }

    .map-empty-state {
        bottom: 0.75rem;
        max-width: none;
    }
}

@media (max-width: 720px) {
    .workspace-shell {
        min-height: calc(100vh - 7rem);
    }

    .pixi-host {
        min-height: 520px;
    }

    .toolbar-primary {
        align-items: stretch;
    }

    .toolbar-title {
        min-width: 0;
    }

    .toolbar-select {
        width: 100%;
    }

    .toolbar-select select {
        flex: 1;
        min-width: 0;
    }

    .modal-grid,
    .criteria-row {
        grid-template-columns: 1fr;
    }
}
