/* UI components - Legend, panels, toggles, search, focus mode */

/* Legend */
.legend {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: white;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    font-size: 12px;
}

.legend h3 {
    font-size: 11px;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.legend-section { margin-bottom: 12px; }
.legend-section:last-child { margin-bottom: 0; }

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.legend-box {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid;
}

/* Info panel */
.info-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 280px;
    max-height: calc(100vh - 90px);
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    display: none;
}

.info-panel.visible {
    display: flex;
    flex-direction: column;
}

.info-panel-header {
    padding: 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-panel-title { font-size: 16px; font-weight: 600; }

.info-panel-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
}

.info-panel-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.info-row { margin-bottom: 8px; }
.info-label { font-size: 11px; color: #666; text-transform: uppercase; }
.info-value { font-size: 13px; color: #333; }

.info-connections {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.info-connection {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 12px;
}

.info-connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Clickable connection-type filter rows in the legend */
.legend-item.legend-filter {
    cursor: pointer;
    user-select: none;
    padding: 2px 4px;
    margin: 0 -4px 4px;
    border-radius: 4px;
    transition: background 0.15s, opacity 0.15s;
}

.legend-item.legend-filter:hover { background: #f3f4f6; }
.legend-item.legend-filter.inactive { opacity: 0.4; }
.legend-item.legend-filter.inactive .legend-line { filter: grayscale(0.6); }

/* Export button */
.export-btn {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    background: #4caf50;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.export-btn:hover { background: #43a047; }
.export-btn:disabled { background: #9e9e9e; cursor: wait; }

/* Search button */
.search-btn {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-btn:hover { background: rgba(255,255,255,0.2); }

/* Search panel */
.search-panel {
    position: fixed;
    top: 70px;
    right: 320px;
    width: 280px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    display: none;
    max-height: calc(100vh - 100px);
    overflow: hidden;
}

.search-panel.visible {
    display: flex;
    flex-direction: column;
}

.search-panel-header {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-panel-title { font-size: 14px; font-weight: 600; flex: 1; }

#search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

#search-input:focus { outline: none; border-color: #1a237e; }

.search-panel-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
}

.search-results { overflow-y: auto; max-height: 400px; }

.search-results-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 12px;
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.search-result-item:hover { background: #f5f7fa; }
.search-result-item:last-child { border-bottom: none; }
.search-result-name { font-weight: 600; font-size: 13px; color: #1a237e; }
.search-result-purpose { font-size: 11px; color: #666; margin-top: 2px; }
.search-result-region { font-size: 10px; color: #999; margin-top: 2px; }

/* Server action buttons (info panel - pinned to the top so they're always visible) */
.info-actions {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
}

.info-actions:empty {
    display: none;
}

.info-actions .center-btn {
    flex: 1 1 0;
    margin-top: 0;
    min-width: 0;
    padding: 8px 4px;
    font-size: 11px;
    white-space: nowrap;
}

/* Restore-hidden floating panel (shares position with info panel) */
.restore-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 99;
    padding: 12px;
    display: none;
}

.restore-panel.visible { display: block; }

.restore-btn {
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.restore-btn:hover { background: #f57c00; }

.center-btn {
    width: 100%;
    padding: 8px;
    margin-top: 12px;
    background: #1a237e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.center-btn:hover { background: #283593; }

/* Focus mode button */
.focus-btn {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.focus-btn:hover:not(:disabled) { background: rgba(255,255,255,0.2); }
.focus-btn.active { background: #ff9800; border-color: #ff9800; }
.focus-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Focus mode indicator */
.focus-mode-indicator {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff9800;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 1000;
    display: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.focus-mode-indicator.visible { display: block; }

/* Container info in info panel */
.container-info-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.container-info-title {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.container-dep-list { font-size: 10px; color: #666; }
.container-dep-list li { margin-bottom: 4px; }
.container-dep-list .dep-type { font-size: 9px; color: #999; margin-left: 4px; }

/* Zoom indicator */
.zoom-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 24px;
    font-weight: 600;
    padding: 16px 28px;
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-out;
    z-index: 1000;
}

.zoom-indicator.visible {
    opacity: 1;
}

/* YAML Editor Panel */
.editor-panel {
    position: fixed;
    top: 70px;
    left: 16px;
    bottom: 16px;
    width: 560px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    z-index: 200;
    display: none;
}

.editor-panel.visible {
    display: flex;
    flex-direction: column;
}

.editor-panel-header {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.editor-panel-title {
    font-size: 14px;
    font-weight: 600;
}

.editor-panel-close {
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: #555;
    cursor: pointer;
    padding: 0 6px;
}

.editor-panel-toolbar {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.editor-toolbar-btn {
    border: 1px solid #d1d5db;
    background: #f9fafb;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    color: #1f2937;
}

.editor-toolbar-btn:hover {
    background: #f3f4f6;
}

.editor-toolbar-btn.primary {
    background: #2563eb;
    color: white;
    border-color: #1d4ed8;
}

.editor-toolbar-btn.primary:hover {
    background: #1d4ed8;
}

.editor-toolbar-btn.danger {
    border-color: #fca5a5;
    color: #b91c1c;
}

.editor-toolbar-btn.danger:hover {
    background: #fef2f2;
}

#editor-file-input {
    display: none;
}

.editor-panel-status {
    padding: 4px 12px;
    font-size: 12px;
    min-height: 18px;
    color: #4b5563;
    border-bottom: 1px solid transparent;
}

.editor-panel-status.ok {
    color: #047857;
}

.editor-panel-status.error {
    color: #b91c1c;
    background: #fef2f2;
    border-bottom-color: #fecaca;
    white-space: pre-wrap;
}

.editor-panel-body {
    flex: 1;
    overflow: hidden;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
}

#editor-host {
    flex: 1;
    min-height: 0;
    height: 100%;
}

#editor-host .CodeMirror {
    height: 100%;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.editor-line-flash {
    background: #fef3c7;
}

/* show-hint addon defaults to z-index: 10, which loses to the editor panel
   at z-index: 200 — the menu would render behind the panel. Float it above. */
.CodeMirror-hints {
    z-index: 300;
}

.editor-panel-issues {
    padding: 8px 10px;
    max-height: 140px;
    overflow-y: auto;
    border-bottom: 1px solid #e5e7eb;
}

.editor-panel-issues-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.editor-panel-issues.has-issues .editor-panel-issues-header {
    color: #b91c1c;
}

.editor-panel-issues-count {
    background: #e5e7eb;
    color: #4b5563;
    border-radius: 9999px;
    padding: 1px 8px;
    font-size: 10px;
    font-weight: 700;
}

.editor-panel-issues.has-issues .editor-panel-issues-count {
    background: #fee2e2;
    color: #b91c1c;
}

.editor-panel-issues-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.editor-panel-issues-empty {
    color: #9ca3af;
    font-size: 12px;
    padding: 2px 0;
}

.editor-panel-issue {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
    gap: 8px;
    align-items: baseline;
    padding: 4px 6px;
    border-radius: 4px;
    border-left: 3px solid #fca5a5;
    background: #fef2f2;
    font-size: 11px;
    line-height: 1.3;
}

.editor-panel-issue.editor-panel-issue-parse {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.editor-panel-issue.clickable {
    cursor: pointer;
}

.editor-panel-issue.clickable:hover {
    background: #fee2e2;
}

.editor-issue-path {
    color: #4b5563;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-issue-msg {
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-issue-line {
    color: #6b7280;
    font-size: 10px;
}

.editor-panel-saved {
    padding: 8px 10px;
    max-height: 160px;
    overflow-y: auto;
}

.editor-panel-saved-header {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.editor-panel-saved-row {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid #f3f4f6;
}

.editor-panel-saved-row:last-child {
    border-bottom: none;
}

.editor-saved-name {
    flex: 1;
    font-size: 12px;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-saved-load {
    border: 1px solid #d1d5db;
    background: #f9fafb;
    border-radius: 4px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 11px;
}

.editor-saved-load:hover {
    background: #eef2ff;
}

.editor-saved-delete {
    border: 1px solid transparent;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 6px;
    border-radius: 4px;
}

.editor-saved-delete:hover {
    color: #b91c1c;
    background: #fef2f2;
}

.editor-panel-saved-empty {
    color: #9ca3af;
    font-size: 12px;
    padding: 4px 0;
}
