:root {
    --bg-dark: #121212;
    /* Deep Black/Gray */
    --card-bg: #1e1e24;
    /* Lighter Gray for cards */
    --primary: #3498db;
    --accent: #f1c40f;
    /* Yellow/Orange for warnings */
    --success: #27ae60;
    --danger: #e74c3c;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --border: #333;
    --radius: 6px;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    margin: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* --- Top Bar --- */
header {
    background-color: #1a1a1a;
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    flex-shrink: 0;
}

.brand {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.5px;
}

.brand i {
    color: var(--primary);
}

/* --- Main Layout --- */
.main-layout {
    height: 100vh;
    display: flex;
    overflow: hidden;
}

/* --- Sidebar (Left) --- */
.sidebar {
    width: 320px;
    background-color: #16161a;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 10;
}

/* --- Sidebar (Right) --- */
.right-sidebar {
    width: 320px;
    background-color: #16161a;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 10;
    padding: 2px;
}

.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar h3 {
    margin-top: 0;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 15px;
}

/* --- Tabs --- */
.view-tabs {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    background: #16161a;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    background: transparent;
    border: none;
    color: #888;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 4px;
    transition: 0.2s;
    display: flex;
    gap: 8px;
    align-items: center;
}

.tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: #fff;
    background: var(--primary);
}

.tab-content {
    flex: 1;
    overflow: hidden;
}

/* --- Analysis Report Styles --- */
.analysis-card {
    background: #24242e;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #444;
}

.analysis-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: bold;
}

.analysis-section-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #888;
    margin-top: 15px;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.analysis-text {
    line-height: 1.5;
    color: #ccc;
    font-size: 0.95rem;
}

.analysis-highlight {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    font-family: monospace;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.summary-table th,
.summary-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #444;
}

.summary-table th {
    color: #888;
    font-weight: normal;
}

.eval-excellent {
    color: #2ecc71;
}

.eval-good {
    color: #3498db;
}

.eval-warn {
    color: #f1c40f;
}

.eval-bad {
    color: #e74c3c;
}

/* Input Area in Sidebar */
.info-box {
    background: rgba(52, 152, 219, 0.1);
    border: 1px solid rgba(52, 152, 219, 0.3);
    color: #bde0fe;
    padding: 10px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    margin-bottom: 15px;
    line-height: 1.4;
}

.info-box code {
    display: block;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    margin-top: 5px;
    border-radius: 3px;
    color: #fff;
    font-family: monospace;
}

textarea.input-code {
    width: 100%;
    background: #0f0f10;
    border: 1px solid #333;
    color: #ccc;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    padding: 10px;
    border-radius: 4px;
    resize: vertical;
    min-height: 100px;
    margin-bottom: 10px;
    box-sizing: border-box;
    /* Fix padding issues */
}

textarea.input-code:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    margin-bottom: 10px;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    border: 1px solid #444;
    color: #aaa;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #666;
    color: #fff;
}

/* Knowledge / Analysis Section in Sidebar */
#analysis-panel {
    display: none;
}

.kb-card {
    background: #202025;
    border-left: 4px solid var(--primary);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 0 4px 4px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.kb-title {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    margin-bottom: 5px;
}

.kb-desc {
    font-size: 0.85rem;
    color: #bbb;
    margin-bottom: 12px;
    line-height: 1.4;
}

.kb-tips {
    list-style: none;
    padding: 0;
    font-size: 0.85rem;
    color: #ccc;
}

.kb-tips li {
    margin-bottom: 6px;
    position: relative;
    padding-left: 15px;
}

.kb-tips li::before {
    content: "•";
    color: var(--accent);
    position: absolute;
    left: 0;
    font-weight: bold;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-val {
    font-weight: 600;
    color: #fff;
    font-family: monospace;
}

/* --- Graph Area --- */
.graph-area {
    flex: 1;
    position: relative;
    background: #0d0d0d;
    background-image: radial-gradient(#222 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.toolbar {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 8px;
    background: rgba(30, 30, 36, 0.8);
    backdrop-filter: blur(4px);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.divider-v {
    width: 1px;
    background: #444;
    margin: 0 4px;
}

.tool-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #ccc;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.2s;
}

.tool-btn:hover {
    background: #333;
    color: #fff;
}

#viz-container {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 40px;
}

/* --- MERMAID CUSTOM CARDS (HTML Labels) --- */
/* These classes are injected into Mermaid Node Labels */

/* Container for the node */
.pg-node-outer {
    /* No bg itself, just layout container */
}

/* The actual Card */
.pg-node-card {
    background-color: #24242e;
    /* Dark slate */
    border: 1px solid #444;
    border-radius: 8px;
    /* Rounded */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    color: #fff;
    min-width: 250px;
    max-width: 320px;
    text-align: left;
    overflow: hidden;
    font-family: 'Segoe UI', sans-serif;
    transition: all 0.2s;
    position: relative;
}

/* Hover Effect */
.pg-node-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6);
    border-color: var(--primary);
    cursor: pointer;
}

/* Selected State */
.pg-node-card.pg-selected {
    border-color: #3498db;
    /* Blue selection */
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.4), 0 8px 16px rgba(0, 0, 0, 0.6);
}

/* Text Highlights */
.txt-green {
    color: #2ecc71;
    font-weight: bold;
}

.txt-yellow {
    color: #f1c40f;
    font-weight: bold;
}

/* Icon Colors */
.icon-red {
    color: #e74c3c;
}

.icon-blue {
    color: #3498db;
}

.icon-green {
    color: #2ecc71;
}

.icon-orange {
    color: #e67e22;
}

.icon-purple {
    color: #9b59b6;
}

.icon-cyan {
    color: #1abc9c;
}

/* Header: Type + Percentage */
.pg-header {
    background-color: #2e2e38;
    /* Slightly lighter header */
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3a3a45;
}

.pg-type {
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Percentage Badges */
.pg-pct {
    background: #34495e;
    color: #ecf0f1;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
}

.pg-pct.med {
    background: var(--accent);
    color: #111;
}

.pg-pct.high {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 0 5px rgba(231, 76, 60, 0.4);
}

/* Body Content */
.pg-body {
    padding: 12px;
}

.pg-row {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
}

.pg-row span.val {
    color: #ddd;
    font-weight: 600;
    font-family: monospace;
}

/* Table Name / Alias */
.pg-relation {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #333;
    color: #8faec5;
    /* Muted blue */
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pg-relation::before {
    content: "\f1c0";
    /* Database icon */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Tags (e.g. Bad Estimate) */
.pg-tags {
    display: flex;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.pg-tag {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #444;
    color: #ccc;
    font-weight: bold;
}


.pg-tag.warn {
    background: #d35400;
    color: #fff;
}

/* --- Sidebar Details Enhancements --- */
.detail-section {
    margin-bottom: 20px;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.detail-section:last-child {
    border-bottom: none;
}

.detail-sec-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.d-label {
    color: #ccc;
}

.d-val {
    color: #fff;
    font-family: 'Consolas', monospace;
}

.d-help {
    font-size: 0.75rem;
    color: #e67e22;
    /* Warning/Help Color */
    margin-left: 8px;
    font-style: italic;
}

/* Specific Stat Row (Legacy support) */
.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #333;
}


/* --- Settings Modal & Theme --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal {
    background: #1e1e24;
    border: 1px solid #444;
    border-radius: 8px;
    width: 400px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.close-modal {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.2rem;
}

.close-modal:hover {
    color: #fff;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    color: #ccc;
    margin-bottom: 10px;
    font-weight: 600;
}

.theme-options {
    display: flex;
    gap: 10px;
}

.theme-opt {
    flex: 1;
    background: #111;
    border: 2px solid #333;
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
}

.theme-opt:hover {
    border-color: #666;
}

.theme-opt.active {
    border-color: var(--primary);
    background: #1a1a20;
}

.color-preview {
    height: 30px;
    border-radius: 4px;
    margin-bottom: 8px;
    border: 1px solid #444;
}

/* THEME: BLUE (Image 2 Style) */
body.theme-blue {
    background-color: #0b1016;
    /* Dark Blue */
    background-image: radial-gradient(#1c2a3a 1px, transparent 1px);
    background-size: 20px 20px;
}

body.theme-blue .sidebar,
body.theme-blue .right-sidebar {
    background-color: #0d131b;
    border-color: #1f2a38;
}

body.theme-blue header {
    background-color: #0f1621;
    border-color: #1f2a38;
}

body.theme-blue .pg-node-card {
    background: #131b26;
    border-color: #2c3e50;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Tooltips */
.info-icon {
    font-size: 0.75rem;
    color: #666;
    margin-left: 5px;
    cursor: help;
}


/* --- Graph Animations (Blinking) --- */
@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
        border-color: #e74c3c;
    }

    70% {
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
        border-color: #e74c3c;
    }

    100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
        border-color: #e74c3c;
    }
}

@keyframes pulse-orange {
    0% {
        box-shadow: 0 0 0 0 rgba(241, 196, 15, 0.7);
        border-color: #f1c40f;
    }

    70% {
        box-shadow: 0 0 0 10px rgba(241, 196, 15, 0);
        border-color: #f1c40f;
    }

    100% {
        box-shadow: 0 0 0 0 rgba(241, 196, 15, 0);
        border-color: #f1c40f;
    }
}

/* Apply to the inner card when the parent mermaid node has the class */
g.pulse-bad .pg-node-card {
    animation: pulse-red 2s infinite;
}

g.pulse-warn .pg-node-card {
    animation: pulse-orange 2s infinite;
}
/* --- Blinking Dot Animation --- */
.blink-dot {
    width: 10px;
    height: 10px;
    background-color: #e74c3c;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    animation: blink-red 1.5s infinite;
}

@keyframes blink-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(231, 76, 60, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}
