/* Core Styling Matrix for MZ-Nexus - Scroll Layout Fixed */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    height: 100vh;
    background-color: #0e0e11;
    color: #e4e4e7;
    font-family: 'Consolas', 'JetBrains Mono', monospace;
    overflow: hidden;
}

/* Sidebar - FIX: overflow-y must be 'auto' here, not overridden by inline style */
.sidebar {
    display: flex;
    flex-direction: column;
    width: 320px;
    background: #121214;
    border-right: 1px solid #2a2a30;
    padding: 20px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto; /* FIX: was 'hidden' as inline style in index.html, blocking scroll */
    z-index: 200;
}

.drop-zone {
    border: 2px dashed #3f3f46;
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    color: #a1a1aa;
    font-size: 0.9rem;
    margin-bottom: 20px;
    transition: all 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.drop-zone-active {
    border-color: #3b82f6 !important;
    background-color: rgba(59, 130, 246, 0.1) !important;
    color: #3b82f6 !important;
}

.sidebar-label {
    font-size: 0.8rem;
    font-weight: bold;
    color: #71717a;
    text-transform: uppercase;
    margin-bottom: 10px;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.plugin-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1;
    overflow-y: visible;
}

.plugin-list-placeholder {
    text-align: center;
    margin-top: 20px;
    color: #52525b;
    font-size: 0.85rem;
    border: 1px dashed #3f3f46;
    padding: 10px;
    border-radius: 6px;
}

.plugin-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background-color: #1a1a1e;
    border: 1px solid #2a2a30;
    border-radius: 6px;
    border-left: 4px solid #3f3f46;
}

.drag-handle {
    color: #4b5563;
    cursor: grab;
    flex-shrink: 0;
}

.plugin-name {
    flex-grow: 1;
    font-size: 0.85rem;
    word-break: break-all;
}

/* Main Content */
.main-content {
    margin-left: 320px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #0e0e11;
    position: relative;
}

/* Top Bar */
.top-bar {
    height: 60px;
    border-bottom: 1px solid #2a2a30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    flex-shrink: 0;
}

.top-bar-brand {
    font-weight: bold;
    font-size: 1.1rem;
    color: #e4e4e7;
}

.top-bar-brand span {
    color: #71717a;
    font-weight: normal;
    font-size: 0.9rem;
    margin-left: 10px;
}

.top-bar-stats {
    display: flex;
    gap: 15px;
}

.stat-badge {
    background: #1a1a1e;
    border: 1px solid #2a2a30;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #a1a1aa;
}

.stat-badge.status-alert {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #f87171;
}

/* Tabs - FIX: tab active state managed purely through CSS classes, no conflicting inline border styles */
.tabs {
    display: flex;
    gap: 20px;
    padding: 20px 30px 0;
    border-bottom: 1px solid #2a2a30;
    flex-shrink: 0;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #a1a1aa;
    padding: 10px 0;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    transition: color 0.15s ease, border-color 0.15s ease;
    margin-bottom: -1px; /* Overlap the tabs border-bottom for connected look */
}

.tab-btn:hover {
    color: #e4e4e7;
}

/* FIX: Active tab style fully in CSS — no inline border overrides in HTML */
.tab-btn.active {
    color: #3b82f6;
    border-bottom: 2px solid #3b82f6;
}

/* Main view panel */
.view-panel {
    padding: 30px;
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 90px;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 40px;
    margin-top: 15vh;
}

.welcome-message h3 {
    color: #f4f4f5;
    font-size: 1.8rem;
    margin-bottom: 12px;
    font-weight: 700;
}

.welcome-message p {
    color: #a1a1aa;
    font-size: 1rem;
    line-height: 1.6;
    margin: 8px 0;
}

/* Resolution / Alert Cards */
.resolution-center {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.alert-card {
    background: #18181b;
    border: 1px solid #3f3f46;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 0;
}

.alert-card h4 {
    margin-top: 0;
    font-size: 1rem;
    margin-bottom: 8px;
}

.alert-card p {
    color: #e4e4e7;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.alert-card.alert-critical {
    border-left: 4px solid #ef4444;
}

.alert-card.alert-warning {
    border-left: 4px solid #f59e0b;
}

.impact-text {
    color: #a1a1aa;
    background: #121214;
    padding: 10px 12px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 0.9rem;
    border-left: 2px solid #52525b;
}

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.btn-fix {
    font-family: inherit;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    background-color: #27272a;
    color: #e4e4e7;
    border: 1px solid #3f3f46;
}

.btn-premium {
    font-family: inherit;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    background: #3b82f6;
    color: white;
    border: none;
    font-weight: bold;
}

.btn-premium:hover {
    background: #2563eb;
}

/* Bottom Bar */
.bottom-bar {
    padding: 0 30px;
    border-top: 1px solid #2a2a30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    background: #0e0e11;
    position: fixed;
    bottom: 0;
    right: 0;
    width: calc(100% - 320px);
    height: 70px;
    z-index: 100;
}

.bottom-bar-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.btn {
    font-family: inherit;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.btn-secondary {
    background: transparent;
    border-color: #3f3f46;
    color: #e4e4e7;
}

.btn-secondary:hover {
    background: #1a1a1e;
}

.btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* Reset button — danger-adjacent but understated so it doesn't dominate */
.btn-reset {
    background: transparent;
    border-color: #7f1d1d;
    color: #f87171;
}

.btn-reset:hover {
    background: #450a0a;
}

.footer-links {
    font-size: 0.82rem;
    color: #71717a;
    white-space: nowrap;
}

.footer-links a.link-issue {
    color: #3b82f6;
    text-decoration: none;
    font-weight: bold;
}

.footer-links a.link-coffee {
    color: #10b981;
    text-decoration: none;
    font-weight: bold;
}

.footer-links .divider {
    margin: 0 10px;
    color: #3f3f46;
}

/* Success text */
.success-text {
    color: #34d399;
    font-weight: bold;
}

/* Loading indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #a1a1aa;
    font-size: 0.95rem;
    padding: 30px;
}

.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #3f3f46;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Conflict Map */
.conflict-map-container {
    background: #16161a;
    border: 1px solid #2a2a30;
    padding: 20px;
    border-radius: 8px;
    height: 100%;
}

.conflict-map-container h4 {
    color: #3b82f6;
    margin-bottom: 8px;
}

.conflict-map-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    font-size: 0.85rem;
    color: #a1a1aa;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
    vertical-align: middle;
}

.conflict-map-canvas {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 280px);
}

.conflict-node {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin: 4px;
    border: 1px solid;
    white-space: nowrap;
}

.conflict-node.node-core {
    background: #1e3a8a33;
    border-color: #3b82f6;
    color: #93c5fd;
}

.conflict-node.node-conflict {
    background: #450a0a33;
    border-color: #ef4444;
    color: #f87171;
}

.conflict-node.node-safe {
    background: #05201133;
    border-color: #34d399;
    color: #6ee7b7;
}

.conflict-map-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 0;
    border-bottom: 1px solid #1f1f24;
}

.conflict-map-row:last-child {
    border-bottom: none;
}

.conflict-map-arrow {
    color: #52525b;
    margin: 0 6px;
    font-size: 0.8rem;
}

/* Database audit */
.db-alert-card {
    background: #1c1917;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

.db-alert-card h4 {
    color: #ef4444;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

code {
    background: #121214;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    color: #f87171;
}