/* Amia Admin Panel Styles */

:root {
    --bg-dark: #1c1b19;
    --bg-card: #26241f;
    --bg-input: #33302a;
    --text-primary: #d0ccc2;
    --text-secondary: #8a8477;
    --accent: #c9a84c;
    --accent-hover: #ddc06a;
    --success: #4ecca3;
    --warning: #ffc107;
    --danger: #dc3545;
    --info: #5ba4b5;
    --bg-header: #3a3520;
    --border-subtle: #3e3a30;

    /* Bootstrap 5 overrides */
    --bs-body-bg: #1c1b19;
    --bs-body-color: #d0ccc2;
    --bs-primary: #c9a84c;
    --bs-primary-rgb: 201, 168, 76;
    --bs-secondary: #33302a;
    --bs-secondary-rgb: 51, 48, 42;
    --bs-success: #4ecca3;
    --bs-success-rgb: 78, 204, 163;
    --bs-danger: #dc3545;
    --bs-danger-rgb: 220, 53, 69;
    --bs-warning: #ffc107;
    --bs-warning-rgb: 255, 193, 7;
    --bs-info: #5ba4b5;
    --bs-info-rgb: 91, 164, 181;
    --bs-link-color: #c9a84c;
    --bs-link-hover-color: #ddc06a;
    --bs-border-color: #3e3a30;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ========== Bootstrap component overrides ========== */

a {
    color: var(--accent);
}

a:hover {
    color: var(--accent-hover);
}

.btn-primary {
    --bs-btn-bg: #c9a84c;
    --bs-btn-border-color: #b8963e;
    --bs-btn-hover-bg: #ddc06a;
    --bs-btn-hover-border-color: #c9a84c;
    --bs-btn-active-bg: #b8963e;
    --bs-btn-active-border-color: #a88834;
    --bs-btn-disabled-bg: #7a6a3a;
    --bs-btn-disabled-border-color: #7a6a3a;
    color: #1c1b19;
}

.btn-outline-primary {
    --bs-btn-color: #c9a84c;
    --bs-btn-border-color: #c9a84c;
    --bs-btn-hover-bg: #c9a84c;
    --bs-btn-hover-border-color: #c9a84c;
    --bs-btn-hover-color: #1c1b19;
    --bs-btn-active-bg: #c9a84c;
    --bs-btn-active-color: #1c1b19;
}

.btn-outline-info {
    --bs-btn-color: #5ba4b5;
    --bs-btn-border-color: #5ba4b5;
    --bs-btn-hover-bg: #5ba4b5;
    --bs-btn-hover-border-color: #5ba4b5;
    --bs-btn-hover-color: #1c1b19;
}

.form-control, .form-select {
    background-color: var(--bg-input);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-input);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(201, 168, 76, 0.25);
}

.form-control::placeholder {
    color: var(--text-secondary);
}

.dropdown-menu {
    background-color: var(--bg-card);
    border-color: var(--border-subtle);
}

.dropdown-item {
    color: var(--text-primary);
}

.dropdown-item:hover, .dropdown-item:focus {
    background-color: var(--bg-input);
    color: var(--accent);
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
}

.login-card h1 {
    color: var(--accent);
    margin-bottom: 10px;
    font-size: 1.5rem;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.login-card h2 {
    margin-bottom: 30px;
    font-weight: 300;
}

/* Dashboard */
.dashboard {
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.dashboard-header h1 {
    color: var(--text-primary);
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Sections */
.section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--accent);
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-primary);
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.table td {
    color: var(--text-primary);
}

.table th {
    background: var(--bg-header);
    color: var(--accent);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border-subtle);
}

.table tr:hover {
    background: rgba(201, 168, 76, 0.08);
}

.table tr.running {
    border-left: 3px solid var(--success);
}

.table tr.stopped {
    border-left: 3px solid var(--danger);
}

/* State badges */
.state-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

.state-badge.running {
    background: rgba(78, 204, 163, 0.2);
    color: var(--success);
}

.state-badge.exited,
.state-badge.stopped {
    background: rgba(220, 53, 69, 0.2);
    color: var(--danger);
}

.state-badge.paused {
    background: rgba(255, 193, 7, 0.2);
    color: var(--warning);
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #3e3a30;
}

.btn-success {
    background: var(--success);
    color: #1c1b19;
}

.btn-warning {
    background: var(--warning);
    color: #1c1b19;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-outline-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.actions {
    display: flex;
    gap: 5px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 15px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
}

.form-text {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-danger {
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid var(--danger);
    color: #ff8a8a;
}

.alert-success {
    background: rgba(78, 204, 163, 0.2);
    border: 1px solid var(--success);
    color: var(--success);
}

/* Log Viewer */
.log-viewer {
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-subtle);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left h1 {
    margin: 0;
    font-size: 1.3rem;
}

.log-container {
    flex: 1;
    background: #141310;
    border-radius: 8px;
    overflow: auto;
    padding: 15px;
}

.log-content {
    margin: 0;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.log-line {
    display: block;
    padding: 2px 0;
}

.log-line.log-error {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

.log-line.log-warn {
    color: #ffc107;
    background: rgba(255, 193, 7, 0.1);
}

.log-line.log-crash {
    color: #ff0040;
    background: rgba(255, 0, 64, 0.2);
    font-weight: bold;
}

.log-footer {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Configure Page */
.configure-page {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
}

.page-header h1 {
    margin: 0;
    font-size: 1.3rem;
}

.config-form {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
}

.pattern-examples {
    margin-top: 30px;
    padding: 20px;
    background: var(--bg-input);
    border-radius: 8px;
}

.pattern-examples h3 {
    margin-top: 0;
    font-size: 1rem;
    color: var(--text-secondary);
}

.pattern-examples ul {
    margin: 0;
    padding-left: 20px;
}

.pattern-examples li {
    margin-bottom: 8px;
}

.pattern-examples code {
    background: var(--bg-dark);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    color: var(--accent);
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .table {
        font-size: 0.85rem;
    }

    .actions {
        flex-direction: column;
    }

    .image-cell {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* =============================================
   Encounters Page — Master-Detail Layout
   ============================================= */

.encounters-page {
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Instance (server) selector */
.instance-selector {
    display: flex;
    align-items: center;
    gap: 6px;
}

.instance-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    margin: 0;
}

.instance-selector select {
    min-width: 140px;
}

.encounters-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-list {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.profile-list .table tr.clickable-row {
    cursor: pointer;
    transition: background 0.15s;
}

.profile-list .table tr.clickable-row:hover {
    background: rgba(201, 168, 76, 0.08);
}

/* Search bar inside section header */
.search-bar {
    flex: 0 1 300px;
}

.search-bar input {
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

/* ===== Profile Detail Modal ===== */

/* Hide number input spinners inside the modal */
.profile-modal input[type="number"]::-webkit-inner-spin-button,
.profile-modal input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.profile-modal input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

.profile-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90vw, 960px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    z-index: 1050;
    overflow: hidden;
}

.profile-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-dark);
    flex-shrink: 0;
}

.profile-modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--accent);
}

.profile-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Section header with title + action button */
.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header-row h2 {
    margin: 0;
}

/* Inline form rows */
.inline-form .form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.inline-form .form-row .form-group {
    flex: 1;
    min-width: 140px;
}

/* Group cards */
.group-card {
    background: var(--bg-input);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.group-card-header {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    gap: 8px;
    transition: background 0.15s;
}

.group-card-header:hover {
    background: rgba(201, 168, 76, 0.08);
}

.group-card-actions {
    margin-left: auto;
}

.expand-icon {
    font-size: 0.75rem;
    color: var(--text-secondary);
    width: 16px;
    text-align: center;
}

.group-card-body {
    padding: 15px;
    border-top: 1px solid var(--border-subtle);
}

.group-card-body h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 15px 0 8px 0;
}

.group-card-body h3:first-child {
    margin-top: 0;
}

/* Compact tables inside group cards */
.table-compact th,
.table-compact td {
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Code styling inside tables */
.table code {
    background: var(--bg-dark);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.85rem;
    color: var(--accent);
}

/* Responsive: modal goes full-width on small screens */
@media (max-width: 992px) {
    .profile-modal {
        width: 96vw;
        max-height: 95vh;
    }

    .profile-list {
        max-height: none;
    }
}

/* ==================== Area Graph ==================== */

.area-graph-stats {
    margin-bottom: 12px;
}

.area-graph-stats .stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: center;
}

.area-graph-stats .stat-item {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.area-graph-stats .stat-item strong {
    color: var(--accent);
}

.area-graph-stats .stat-detail {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-left: 4px;
}

.area-graph-legend {
    display: flex;
    gap: 20px;
    padding: 8px 16px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
}

.area-graph-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.area-graph-legend .legend-swatch {
    display: inline-block;
    width: 24px;
    height: 4px;
    border-radius: 2px;
}

.area-graph-legend .legend-door {
    background-color: #5ba4b5;
}

.area-graph-legend .legend-trigger {
    background-color: #4ecca3;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 4px,
        var(--bg-card) 4px,
        var(--bg-card) 8px
    );
}

.area-graph-container {
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    overflow: hidden;
}

.area-graph-container #cy {
    background: var(--bg-dark);
}

/* ===== Area Graph Layout (graph + detail panel side by side) ===== */
.area-graph-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* ===== Area Detail Panel ===== */
.area-detail-panel {
    width: 320px;
    flex-shrink: 0;
    max-height: 690px;
    overflow-y: auto;
}

.detail-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.detail-panel-header h4 {
    margin: 0;
    color: var(--accent);
    font-size: 1.05rem;
}

.detail-field {
    margin-bottom: 10px;
}

.detail-field label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.detail-field span,
.detail-field code {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.badge-spawn {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    background: rgba(78, 204, 163, 0.15);
    color: var(--success);
    border: 1px solid rgba(78, 204, 163, 0.3);
}

.detail-connections label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.connection-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.connection-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.88rem;
}

.connection-item:last-child {
    border-bottom: none;
}

.conn-direction {
    font-weight: bold;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.conn-out { color: var(--info); }
.conn-in  { color: var(--accent); }

.conn-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.conn-type {
    font-size: 0.75rem;
    padding: 1px 6px;
    border-radius: 3px;
    flex-shrink: 0;
}

.conn-door    { background: rgba(91,164,181,0.15); color: var(--info); }
.conn-trigger { background: rgba(78,204,163,0.15); color: var(--success); }

/* ========== Region Graph Visual Editor ========== */

.region-editor {
    padding: 8px 12px 0 12px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

.region-editor__toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.region-editor__toolbar h1 {
    font-size: 1.05rem;
    margin: 0;
    margin-right: 6px;
    white-space: nowrap;
}

.region-editor__toolbar .toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.region-editor__toolbar .toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-subtle);
    margin: 0 4px;
}

.region-editor__main {
    display: flex;
    border: 1px solid var(--border-subtle);
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.region-editor__graph-wrapper {
    flex: 1;
    min-width: 300px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #1a1a1a;
}

.region-editor__graph {
    flex: 1;
    min-height: 0;
    /* Fallback if flex chain fails — ensures graph never fully collapses */
    height: calc(100vh - 200px);
}

/* ===== Resize Splitter ===== */

.region-editor__splitter {
    width: 6px;
    cursor: col-resize;
    background: var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
    position: relative;
    z-index: 10;
}

.region-editor__splitter:hover,
.region-editor__splitter.active {
    background: var(--accent);
}

.region-editor__splitter-grip {
    width: 2px;
    height: 32px;
    border-radius: 1px;
    background: rgba(255,255,255,0.2);
}

.region-editor__splitter:hover .region-editor__splitter-grip,
.region-editor__splitter.active .region-editor__splitter-grip {
    background: rgba(255,255,255,0.5);
}

/* Prevent text selection during drag */
.region-editor.resizing {
    user-select: none;
    cursor: col-resize;
}
.region-editor.resizing * {
    cursor: col-resize !important;
}

.region-editor__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.3);
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    max-height: 48px;
    overflow-y: auto;
    flex-shrink: 0;
}

.region-editor__legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.15s;
}

.region-editor__legend-item:hover {
    background: rgba(255,255,255,0.06);
}

.region-editor__legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
}

/* ===== Overlay Panel (inside graph wrapper) ===== */

.region-overlay-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 90%;
    background: var(--bg-card);
    border-left: 2px solid var(--accent);
    z-index: 500;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.4);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    pointer-events: none;
}

.region-overlay-panel--open {
    transform: translateX(0);
    pointer-events: auto;
}

.region-overlay-panel .region-editor__panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-header);
    flex-shrink: 0;
}

.region-overlay-panel .region-editor__panel-header h3 {
    margin: 0;
    font-size: 1rem;
}

.region-overlay-panel .region-editor__panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
}

.region-overlay-panel .region-editor__panel-footer {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
    justify-content: flex-end;
}

/* ===== Side Panel (legacy, unused) ===== */

.region-editor__panel {
    width: 340px;
    min-width: 260px;
    max-width: 600px;
    background: var(--bg-card);
    border-left: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.region-editor__panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-header);
    flex-shrink: 0;
}

.region-editor__panel-header h3 {
    margin: 0;
    font-size: 1rem;
}

.region-editor__panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
}

.region-editor__panel-footer {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
    justify-content: flex-end;
}

/* ===== Panel Sections ===== */

.panel-section {
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
    background: rgba(255,255,255,0.015);
}

.panel-section__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.panel-section__header strong {
    font-size: 0.9rem;
}

.panel-section .form-group {
    margin-bottom: 8px;
}

.panel-section .form-group:last-child {
    margin-bottom: 0;
}

.panel-section .form-group label {
    font-size: 0.82rem;
    margin-bottom: 3px;
    display: block;
    color: var(--text-secondary);
}

/* ===== POI Card ===== */

.poi-card {
    border: 1px dashed var(--border-subtle);
    border-radius: 4px;
    padding: 8px;
    margin-top: 6px;
    background: rgba(255,255,255,0.01);
}

.poi-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.poi-card__fields {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.poi-card__fields .form-group {
    flex: 1;
    min-width: 120px;
}

/* ===== Context Menu ===== */

.region-context-menu {
    position: absolute;
    z-index: 9999;
    min-width: 180px;
    background: #2a2825;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 4px 0;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    font-size: 0.88rem;
}

.region-context-menu__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.1s;
    white-space: nowrap;
    user-select: none;
}

.region-context-menu__item:hover {
    background: rgba(201, 168, 76, 0.15);
}

.region-context-menu__item--danger {
    color: var(--danger);
}

.region-context-menu__item--danger:hover {
    background: rgba(220, 53, 69, 0.15);
}

.region-context-menu__divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

.region-context-menu__submenu-arrow {
    margin-left: 10px;
    font-size: 0.7rem;
    opacity: 0.5;
}

/* ===== Sub-menu (Assign to region) ===== */

.region-context-submenu {
    position: absolute;
    left: 100%;
    top: -4px;
    min-width: 160px;
    background: #2a2825;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 4px 0;
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
    max-height: 280px;
    overflow-y: auto;
}

.region-context-submenu__item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: background 0.1s;
    white-space: nowrap;
}

.region-context-submenu__item:hover {
    background: rgba(201, 168, 76, 0.15);
}

.region-context-submenu__swatch {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ===== Region list mini-table ===== */

.region-list-item {
    display: flex;
    align-items: center;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s;
    gap: 8px;
    margin-bottom: 4px;
}

.region-list-item:hover {
    background: rgba(255,255,255,0.04);
    border-color: var(--border-subtle);
}

.region-list-item--active {
    background: rgba(201, 168, 76, 0.1);
    border-color: var(--accent);
}

.region-list-item__swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

.region-list-item__info {
    flex: 1;
    min-width: 0;
}

.region-list-item__name {
    font-size: 0.9rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.region-list-item__tag {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.region-list-item__count {
    font-size: 0.78rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* ===== Inline delete confirm ===== */

.inline-confirm {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 6px;
    margin-top: 8px;
}

.inline-confirm span {
    font-size: 0.85rem;
    flex: 1;
}

/* ===== Alerts inside editor ===== */

.region-editor .alert {
    margin: 8px 16px;
    flex-shrink: 0;
}

/* ===== Graph info overlay ===== */

.graph-info-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 10px;
    background: rgba(0,0,0,0.35);
    font-size: 0.78rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.graph-info-bar span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========== Definition Tag Picker ========== */

.def-tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
}

.def-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    background: rgba(201,168,76,0.18);
    border: 1px solid rgba(201,168,76,0.35);
    border-radius: 4px;
    font-size: 0.78rem;
    color: #e8d9a0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.def-tag-chip-remove {
    background: none;
    border: none;
    color: #c9a84c;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.def-tag-chip-remove:hover {
    opacity: 1;
    color: #ff6b6b;
}

.def-tag-picker {
    position: relative;
}

.def-tag-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: #1c1b19;
    border: 1px solid var(--border-subtle);
    border-top: none;
    border-radius: 0 0 6px 6px;
    z-index: 600;
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.def-tag-dropdown-item {
    display: flex;
    flex-direction: column;
    padding: 5px 10px;
    cursor: pointer;
    transition: background 0.1s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.def-tag-dropdown-item:last-child {
    border-bottom: none;
}
.def-tag-dropdown-item:hover {
    background: rgba(201,168,76,0.12);
}

.def-tag-dropdown-tag {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.def-tag-dropdown-info {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.def-tag-dropdown-more {
    padding: 6px 10px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

.def-tag-dropdown-empty {
    padding: 8px 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

/* ========== PwEngine Dependency Graph ========== */

.dep-graph-editor {
    padding: 8px 12px 0 12px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    box-sizing: border-box;
    overflow: hidden;
}

.dep-graph-editor__toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.dep-graph-editor__toolbar h1 {
    font-size: 1.05rem;
    margin: 0;
    margin-right: 6px;
    white-space: nowrap;
}

.dep-graph-editor__toolbar .toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dep-graph-editor__main {
    display: flex;
    border: 1px solid var(--border-subtle);
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.dep-graph-editor__graph-wrapper {
    flex: 1;
    min-width: 300px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #1a1a2e;
}

.dep-graph-editor__stats-bar {
    display: flex;
    gap: 12px;
    padding: 4px 12px;
    background: rgba(0,0,0,0.4);
    font-size: 0.78rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.dep-graph-editor__graph {
    flex: 1;
    min-height: 0;
    /* Fallback if flex chain fails */
    height: calc(100vh - 200px);
    background: #1a1a2e;
}

.dep-graph-editor__loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.dep-graph-editor__legend {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0,0,0,0.75);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.72rem;
    color: var(--text-secondary);
    z-index: 10;
    pointer-events: none;
}

.dep-graph-editor__legend .legend-title {
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.dep-graph-editor__legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.dep-graph-editor__legend .legend-shape {
    display: inline-block;
    width: 14px;
    text-align: center;
    font-size: 0.68rem;
}

.dep-graph-editor__legend .legend-line {
    display: inline-block;
    width: 20px;
    height: 0;
    border-top: 2px solid;
}

.dep-graph-editor__detail-panel {
    width: 360px;
    min-width: 280px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.dep-graph-editor__detail-panel .detail-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.dep-graph-editor__detail-panel .detail-header h5 {
    margin: 0;
    font-size: 0.95rem;
}

.dep-graph-editor__detail-panel .detail-body {
    padding: 10px 12px;
}

.dep-graph-editor__detail-panel .detail-field {
    margin-bottom: 10px;
}

.dep-graph-editor__detail-panel .detail-field label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dep-graph-editor__detail-panel .detail-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.dep-graph-editor__detail-panel .detail-edge-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

.dep-graph-editor__detail-panel .detail-edge-list li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.dep-graph-editor__detail-panel .edge-type {
    font-size: 0.68rem;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
}

.edge-type--inherits { background: rgba(91,164,181,0.2); color: #5ba4b5; }
.edge-type--implements { background: rgba(78,204,163,0.2); color: #4ecca3; }
.edge-type--constructordep { background: rgba(245,130,49,0.2); color: #f58231; }
.edge-type--fielddep { background: rgba(136,136,136,0.2); color: #999; }

.dep-graph-editor__detail-panel .edge-target {
    cursor: pointer;
    color: var(--accent);
}

.dep-graph-editor__detail-panel .edge-target:hover {
    text-decoration: underline;
}

.dep-graph-editor__detail-panel .edge-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* ========== SearchableSelect Typeahead ========== */

.searchable-select {
    flex-grow: 1;
}

.searchable-select:focus-within {
    outline: none;
}

.searchable-select__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 220px;
    overflow-y: auto;
    background: var(--bg-input, #33302a);
    border: 1px solid var(--border-subtle, #3e3a30);
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.searchable-select__item {
    padding: 5px 10px;
    font-size: 0.82rem;
    color: var(--text-primary, #d0ccc2);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.searchable-select__item:hover,
.searchable-select__item.highlighted {
    background: var(--accent, #c9a84c);
    color: var(--bg-dark, #1c1b19);
}

.searchable-select__item.text-muted {
    cursor: default;
}

.searchable-select__item.text-muted:hover {
    background: transparent;
    color: var(--text-secondary);
}

/* ========== Condition & Action Editors ========== */

.condition-editor,
.action-editor {
    min-height: 30px;
}

.condition-editor .searchable-select,
.action-editor .searchable-select {
    min-width: 0;
}
