/* PI Infrastructure Knowledge Base — Light Engineering Theme */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f6f8fa;
    --bg-tertiary: #eef1f5;
    --bg-card: #ffffff;
    --border: #d1d9e0;
    --border-accent: #0969da;
    --text-primary: #1f2328;
    --text-secondary: #59636e;
    --text-muted: #818b98;
    --accent-blue: #0969da;
    --accent-green: #1a7f37;
    --accent-red: #d1242f;
    --accent-amber: #9a6700;
    --accent-purple: #8250df;
    --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Helvetica, Arial, sans-serif;
    --radius: 8px;
    --transition: 0.2s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
}

.header-content {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.header-badge {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* Tabs */
.tabs {
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
    padding: 0 24px;
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
}

.tab {
    font-family: var(--sans);
    font-size: 14px;
    color: var(--text-secondary);
    background: none;
    border: none;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-blue);
}

/* Main content */
main {
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
    padding: 24px;
    flex: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Search */
.search-container {
    margin-bottom: 16px;
}

#search-input {
    width: 100%;
    font-family: var(--sans);
    font-size: 16px;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}

#search-input:focus {
    border-color: var(--accent-blue);
}

#search-input::placeholder {
    color: var(--text-muted);
}

/* Chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.chip {
    font-family: var(--sans);
    font-size: 13px;
    color: var(--accent-blue);
    background: rgba(9, 105, 218, 0.08);
    border: 1px solid rgba(9, 105, 218, 0.3);
    border-radius: 20px;
    padding: 6px 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.chip:hover {
    background: rgba(9, 105, 218, 0.15);
    border-color: var(--accent-blue);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state .subtle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Search results */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
    animation: slideIn 0.3s ease;
    box-shadow: 0 1px 3px rgba(31, 35, 40, 0.08);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    cursor: pointer;
    transition: background var(--transition);
}

.result-header:hover {
    background: var(--bg-tertiary);
}

.result-title {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
}

.severity-badge {
    font-family: var(--mono);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.severity-badge.critical { background: rgba(209, 36, 47, 0.1); color: var(--accent-red); }
.severity-badge.high { background: rgba(154, 103, 0, 0.1); color: var(--accent-amber); }
.severity-badge.medium { background: rgba(9, 105, 218, 0.1); color: var(--accent-blue); }
.severity-badge.low { background: rgba(26, 127, 55, 0.1); color: var(--accent-green); }

.category-badge {
    font-family: var(--mono);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(130, 80, 223, 0.1);
    color: var(--accent-purple);
}

.expand-icon {
    color: var(--text-muted);
    transition: transform var(--transition);
    font-size: 12px;
}

.result-card.expanded .expand-icon {
    transform: rotate(90deg);
}

.result-body {
    display: none;
    padding: 0 18px 18px;
    border-top: 1px solid var(--border);
}

.result-card.expanded .result-body {
    display: block;
}

.result-body h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-blue);
    margin: 16px 0 8px;
}

.result-body p, .result-body li {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.result-body ol, .result-body ul {
    padding-left: 20px;
}

.result-body li {
    margin-bottom: 4px;
}

.result-body code {
    font-family: var(--mono);
    font-size: 13px;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-blue);
}

/* Detection controls */
.detection-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

#scenario-select {
    flex: 1;
    font-family: var(--sans);
    font-size: 14px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
}

#scenario-select:focus {
    border-color: var(--accent-blue);
}

#run-detection {
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 24px;
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: opacity var(--transition);
    white-space: nowrap;
}

#run-detection:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#run-detection:not(:disabled):hover {
    opacity: 0.9;
}

/* Task list (detection steps) */
.task-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.task-item {
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.3s ease;
}

.task-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    transition: all 0.3s ease;
}

.task-item.active .task-header {
    background: rgba(9, 105, 218, 0.06);
}

.task-item.done .task-header {
    background: transparent;
}

/* Status indicator */
.task-status {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: all 0.3s ease;
}

.task-status.pending {
    border: 2px solid var(--border);
    background: transparent;
}

.task-status.running {
    border: 2px solid var(--accent-blue);
    background: transparent;
    animation: pulse 1.2s ease-in-out infinite;
}

.task-status.running::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-blue);
    animation: spin-dot 1s linear infinite;
}

@keyframes pulse {
    0%, 100% { border-color: var(--accent-blue); }
    50% { border-color: rgba(9, 105, 218, 0.3); }
}

@keyframes spin-dot {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

.task-status.completed {
    border: 2px solid var(--accent-green);
    background: var(--accent-green);
}

.task-status.completed::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 6px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.task-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.task-item.active .task-label {
    color: var(--text-primary);
    font-weight: 600;
}

.task-item.done .task-label {
    color: var(--text-primary);
}

/* Task body (content revealed on completion) */
.task-body {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
    padding: 0 16px;
}

.task-body.visible {
    max-height: 600px;
    opacity: 1;
    padding: 0 16px 16px 48px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.task-body pre {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    background: var(--bg-tertiary);
    padding: 12px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.task-body .data-key {
    color: var(--text-muted);
}

.task-body .data-value {
    color: var(--text-primary);
}

.task-body .data-value.bad {
    color: var(--accent-red);
}

.task-body .data-value.good {
    color: var(--accent-green);
}

.task-body .triggered {
    color: var(--accent-red);
    font-weight: 700;
}

.task-body .severity-text {
    text-transform: uppercase;
    font-weight: 700;
}

.task-body .severity-text.critical { color: var(--accent-red); }
.task-body .severity-text.high { color: var(--accent-amber); }

/* Resolution in detection */
.resolution-content h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-blue);
    margin: 12px 0 8px;
}

.resolution-content h2:first-child {
    margin-top: 0;
}

.resolution-content p, .resolution-content li {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.resolution-content ol, .resolution-content ul {
    padding-left: 20px;
}

.resolution-content li {
    margin-bottom: 4px;
}

.resolution-content code {
    font-family: var(--mono);
    font-size: 13px;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-blue);
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 12px 24px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.separator {
    margin: 0 8px;
    opacity: 0.4;
}

/* Responsive */
@media (max-width: 640px) {
    header { padding: 12px 16px; }
    main { padding: 16px; }
    .tabs { padding: 0 16px; }
    .header-content { flex-wrap: wrap; }
    .detection-controls { flex-direction: column; }
    .chips { gap: 6px; }
    .chip { font-size: 12px; padding: 5px 10px; }
}
