/* Application Landscape Graph Builder Styles */
.landscape-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
}



.landscape-canvas-wrapper {
    flex: 1;
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.canvas-toolbar {
    padding: 10px 16px;
    background-color: var(--color-bg-base);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.canvas-info {
    font-family: var(--font-mono);
    font-weight: 600;
}

.canvas-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--color-primary-accent);
}

.landscape-canvas {
    flex: 1;
    padding: var(--grid-gap-base);
    overflow-x: auto;
    overflow-y: auto;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
    min-height: 500px;
    background-image: radial-gradient(var(--color-border) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Interactive Diagram Canvas Mode */
.landscape-diagram-canvas {
    flex: 1;
    position: relative;
    overflow: auto;
    min-height: 650px;
    min-width: 1000px;
    background-color: #ffffff;
    background-image: radial-gradient(#cbd5e1 1.5px, transparent 1.5px);
    background-size: 20px 20px;
    user-select: none;
}

.diagram-stage {
    position: relative;
    min-width: 1400px;
    min-height: 900px;
    transform-origin: 0 0;
    transition: transform 0.15s ease;
}

.diagram-domain-node {
    position: absolute;
    background-color: #ffffff;
    border: 2px solid #000000;
    border-radius: var(--border-radius-sm);
    padding: 0;
    box-sizing: border-box;
    z-index: 10;
}


/* Embedded Domain Title on Top Border Line */
.diagram-domain-title-wrap {
    position: absolute;
    top: -11px;
    left: 14px;
    background-color: #ffffff;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    color: inherit;
    cursor: move;
    user-select: none;
    z-index: 15;
    white-space: nowrap;
}


.diagram-domain-body {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}


.diagram-app-node {
    position: absolute;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius-sm);
    padding: 8px 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.06);
    cursor: move;
    width: 256px;
    height: 96px;
    box-sizing: border-box;
    z-index: 100 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    transition: box-shadow 0.15s ease;
}




.diagram-app-node:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.diagram-app-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--color-primary-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.diagram-app-desc {
    font-size: 0.78rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
}





.domain-resize-handle {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 10px;
    height: 10px;
    cursor: se-resize;
    background-color: #475569;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.diagram-domain-node:hover .domain-resize-handle {
    opacity: 0.7;
}

.domain-resize-handle:hover {
    opacity: 1;
    background-color: var(--color-primary-accent);
}




/* Domain Container Bounding Box */
.domain-box {
    background-color: var(--color-bg-surface);
    border: 2px dashed var(--color-secondary-accent);
    border-radius: var(--border-radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s ease;
    position: relative;
}

.landscape-canvas > .domain-box {
    min-width: 320px;
    max-width: 400px;
    flex-shrink: 0;
}

.domain-box.collapsed {
    gap: 0;
    padding-bottom: 10px;
}

.domain-box.collapsed > .subdomain-grid,
.domain-box.collapsed > .apps-grid {
    display: none !important;
}

.domain-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    user-select: none;
}

.domain-box.collapsed .domain-header {
    border-bottom: none;
    padding-bottom: 0;
}

.chevron-icon {
    transition: transform 0.2s ease;
}

.chevron-icon.collapsed {
    transform: rotate(-90deg);
}

.domain-count-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    margin-left: 4px;
}

.domain-title-group {

    display: flex;
    align-items: center;
    gap: 8px;
}

.domain-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary-accent);
}

.domain-badge {
    font-size: 0.72rem;
    font-weight: 700;
    background-color: rgba(61, 90, 128, 0.12);
    color: var(--color-primary-accent);
    padding: 2px 7px;
    border-radius: 12px;
    font-family: var(--font-mono);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
}


.domain-actions {
    display: flex;
    gap: 4px;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.domain-box:hover .domain-actions {
    opacity: 1;
}

.btn-icon {
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: var(--border-radius-sm);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}

.btn-icon:hover {
    background-color: var(--color-neutral-shaded);
    color: var(--color-text-primary);
}

.btn-icon-danger:hover {
    background-color: var(--color-destructive);
    color: #ffffff;
}

/* Sub-domains nested grid */
.subdomain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 4px;
}

/* Applications Container Inside Domain */
.apps-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 44px;
    padding: 6px;
    border-radius: var(--border-radius-sm);
}

.apps-grid:empty::after {
    content: 'Drop application cards here';
    display: block;
    padding: 12px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    border: 1px dashed var(--color-border);
    border-radius: var(--border-radius-sm);
}

/* Application Card */
.app-card {
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-primary-accent);
    border-radius: var(--border-radius-sm);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: grab;
    user-select: none;
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
}

.app-card:hover {
    box-shadow: 0 4px 12px rgba(61, 90, 128, 0.12);
}

.app-card:active {
    cursor: grabbing;
}

.app-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.app-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.app-name {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--color-text-primary);
    line-height: 1.25;
}

.app-desc {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.35;
}

.app-actions {
    display: flex;
    gap: 2px;
}

/* Tag Pill Container & Badges */
.app-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 2px;
}

.tag-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    background-color: var(--color-bg-base);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* Corner Ribbon / Accent Badge */
.app-corner-accent {
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 22px 22px 0;
    border-color: transparent var(--corner-color, var(--color-primary-accent)) transparent transparent;
    pointer-events: none;
    z-index: 10;
}

/* Bottom Right Badge for Style Type 'badge' */
.app-bottom-right-badge {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 2px 6px;
    border-radius: 6px;
    background-color: var(--badge-bg-color, #000082);
    color: var(--badge-text-color, #ffffff);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

/* Diagram App Node Swap Target Indicator */
.diagram-app-node.swap-hover-target {
    border: 2px dashed #3b82f6 !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.35), 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    transform: scale(1.02);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    z-index: 150 !important;
}

.diagram-app-node.swap-hover-target::after {
    content: "⇄ Swap";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #3b82f6;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    z-index: 160;
}


/* Color Swatch Buttons & Template Active Indicators */
.color-swatch-btn {

    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}

.color-swatch-btn:hover {
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    z-index: 2;
}

.color-swatch-btn.active {
    transform: scale(1.15);
    box-shadow: 0 0 0 2px var(--color-primary-accent, #3b82f6), 0 2px 5px rgba(0, 0, 0, 0.3);
    z-index: 2;
}




/* Tag Rules Configuration Table */
.tag-rules-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.tag-rules-table th,
.tag-rules-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.tag-rules-table th {
    background-color: var(--color-bg-base);
    font-weight: 600;
    color: var(--color-text-muted);
}

/* Navbar View Mode Toggle Control (identical to DB Sketcher) */
.module-navbar-actions .view-mode-toggle {
    display: inline-flex;
    align-items: center;
    height: 32px !important;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: 2px;
    box-sizing: border-box !important;
}

.module-navbar-actions .btn-view-mode {
    height: 26px !important;
    line-height: 26px !important;
    font-size: 0.75rem !important;
    padding: 0 10px !important;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    border-radius: var(--border-radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.module-navbar-actions .btn-view-mode:hover {
    color: var(--color-text-main);
}

.module-navbar-actions .btn-view-mode.active {
    background: #ffffff;
    color: var(--color-primary-accent);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Visual Diagram Groups */
.diagram-group-node {
    position: absolute;
    border: none;
    box-sizing: border-box;
    z-index: 500; /* Above applications (100) and domain boxes (10-30) */
    pointer-events: none; /* Allow clicks to pass through to underlying apps & domains */
}

.diagram-group-title-wrap {
    position: absolute;
    top: -9px;
    left: 10px;
    background-color: #ffffff;
    padding: 0 4px;
    border-radius: 2px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #94a3b8;
    cursor: move;
    user-select: none;
    z-index: 515;
    white-space: nowrap;
    pointer-events: auto;
}


.group-title-actions {
    display: inline-flex;
    gap: 4px;
    margin-left: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.diagram-group-title-wrap:hover .group-title-actions {
    opacity: 1;
}

.group-vertex-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: #94a3b8;
    border: 1px solid #475569;
    border-radius: 50%;
    cursor: move;
    transform: translate(-50%, -50%);
    z-index: 525;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: auto;
}



.diagram-group-node:hover .group-vertex-handle,
.group-vertex-handle:hover {
    opacity: 1;
}

.group-vertex-handle:hover {
    transform: translate(-50%, -50%) scale(1.4);
    background-color: var(--color-primary-accent);
}

.group-edge-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #ffffff;
    border: 1.5px dashed #94a3b8;
    border-radius: 50%;
    cursor: copy;
    transform: translate(-50%, -50%);
    z-index: 520;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
    pointer-events: auto;
}

.diagram-group-node:hover .group-edge-handle {
    opacity: 0.7;
}

.group-edge-handle:hover {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.3);
    border-color: var(--color-primary-accent);
    color: var(--color-primary-accent);
}


.diagram-group-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

/* Custom Multi-Select Dropdown Component */
.custom-multiselect {
    position: relative;
    width: 100%;
}

.multiselect-trigger {
    width: 100%;
    height: 38px;
    padding: 6px 12px;
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--color-text-main);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.multiselect-trigger:hover,
.multiselect-trigger:focus {
    border-color: var(--color-primary-accent);
}

#multiselect-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.multiselect-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 1050;
    padding: 6px;
    max-height: 220px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.multiselect-actions {
    display: flex;
    justify-content: space-between;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

.btn-text-sm {
    background: none;
    border: none;
    padding: 2px 6px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-primary-accent);
    cursor: pointer;
    border-radius: 3px;
}

.btn-text-sm:hover {
    background-color: rgba(61, 90, 128, 0.08);
}

.multiselect-options {
    overflow-y: auto;
    max-height: 170px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.multiselect-option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    font-size: 0.82rem;
    color: var(--color-text-main);
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.12s ease;
}

.multiselect-option-item:hover {
    background-color: var(--color-bg-hover, #f1f5f9);
}

/* Description & Legend Elements on Diagram Canvas */
.diagram-desc-node,
.diagram-legend-node {
    position: absolute;
    background: #ffffff;
    border: 1px solid var(--color-border, #cbd5e1);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 12px;
    z-index: 105;
    cursor: move;
    user-select: none;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.diagram-desc-node:hover,
.diagram-legend-node:hover {
    border-color: var(--color-primary-accent, #3b82f6);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

/* Description Node Details */
.desc-node-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text-main, #0f172a);
    margin-bottom: 2px;
    line-height: 1.3;
}

.desc-node-subtitle {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--color-primary-accent, #3b82f6);
    margin-bottom: 8px;
}

.desc-node-body {
    font-size: 0.78rem;
    color: var(--color-text-muted, #475569);
    line-height: 1.45;
    overflow: auto;
    flex: 1;
}

/* Description Node Size Presets (small, medium, large, huge) */
.diagram-desc-node.desc-size-small {
    padding: 12px;
}
.diagram-desc-node.desc-size-small .desc-node-title { font-size: 1rem; margin-bottom: 2px; }
.diagram-desc-node.desc-size-small .desc-node-subtitle { font-size: 0.8rem; margin-bottom: 8px; }
.diagram-desc-node.desc-size-small .desc-node-body { font-size: 0.78rem; line-height: 1.45; }

.diagram-desc-node.desc-size-medium {
    padding: 24px;
    border-radius: 12px;
}
.diagram-desc-node.desc-size-medium .desc-node-title { font-size: 2rem; margin-bottom: 4px; }
.diagram-desc-node.desc-size-medium .desc-node-subtitle { font-size: 1.6rem; margin-bottom: 16px; }
.diagram-desc-node.desc-size-medium .desc-node-body { font-size: 1.56rem; line-height: 1.5; }
.diagram-desc-node.desc-size-medium .btn-node-action { width: 32px; height: 32px; }
.diagram-desc-node.desc-size-medium .btn-node-action svg { width: 16px; height: 16px; }

.diagram-desc-node.desc-size-large {
    padding: 48px;
    border-radius: 18px;
}
.diagram-desc-node.desc-size-large .desc-node-title { font-size: 4rem; margin-bottom: 8px; }
.diagram-desc-node.desc-size-large .desc-node-subtitle { font-size: 3.2rem; margin-bottom: 32px; }
.diagram-desc-node.desc-size-large .desc-node-body { font-size: 3.12rem; line-height: 1.55; }
.diagram-desc-node.desc-size-large .btn-node-action { width: 56px; height: 56px; border-radius: 8px; }
.diagram-desc-node.desc-size-large .btn-node-action svg { width: 28px; height: 28px; }

.diagram-desc-node.desc-size-huge {
    padding: 96px;
    border-radius: 32px;
}
.diagram-desc-node.desc-size-huge .desc-node-title { font-size: 8rem; margin-bottom: 16px; }
.diagram-desc-node.desc-size-huge .desc-node-subtitle { font-size: 6.4rem; margin-bottom: 64px; }
.diagram-desc-node.desc-size-huge .desc-node-body { font-size: 6.24rem; line-height: 1.6; }
.diagram-desc-node.desc-size-huge .btn-node-action { width: 112px; height: 112px; border-radius: 16px; }
.diagram-desc-node.desc-size-huge .btn-node-action svg { width: 56px; height: 56px; }


/* Node Header & Action Buttons */
.node-action-bar {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.diagram-desc-node:hover .node-action-bar,
.diagram-legend-node:hover .node-action-bar {
    opacity: 1;
}

.btn-node-action {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
    transition: all 0.12s ease;
}

.btn-node-action:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-node-action.btn-node-delete:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fca5a5;
}

/* Legend Node Details */
.legend-node-header {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--color-text-main, #0f172a);
    padding-bottom: 6px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
}

.legend-node-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
}

.legend-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--color-text-main, #1e293b);
}

.legend-item-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.diagram-node-resize-handle {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 12px;
    height: 12px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, #94a3b8 50%);
    border-bottom-right-radius: 6px;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.diagram-desc-node:hover .diagram-node-resize-handle,
.diagram-legend-node:hover .diagram-node-resize-handle {
    opacity: 1;
}


.multiselect-option-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--color-primary-accent);
    cursor: pointer;
}

.rule-val-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 6px;
    background-color: rgba(0, 0, 0, 0.06);
    border-radius: 3px;
    margin: 1px;
}




