:root {
    --primary: #0984E3;
    --primary-hover: #076ebc;
    --secondary: #74B9FF;
    --secondary-hover: #58a9ff;
    --accent: #FF6B6B;
    --bg-dark: #0D1117;
    --bg-panel: #161B22;
    --bg-surface: #21262D;
    --text-main: #C9D1D9;
    --text-muted: #8B949E;
    --border: #30363D;

    --radius: 8px;
    --font-ui: 'Inter', system-ui, sans-serif;
    --font-code: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
}

h2 {
    font-size: 1rem;
    font-weight: 500;
    color: #fff;
}

button {
    font-family: var(--font-ui);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
}

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

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--text-muted);
    background-color: var(--bg-surface);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

main {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1rem;
    padding: 1rem;
}

.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-panel);
}

.badge {
    font-size: 0.75rem;
    background-color: var(--bg-surface);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: var(--secondary);
    border: 1px solid var(--border);
}

.input-panel {
    flex: 1;
    min-width: 350px;
    max-width: 500px;
}

#sql-input {
    flex: 1;
    background-color: var(--bg-dark);
    color: var(--secondary);
    font-family: var(--font-code);
    font-size: 0.9rem;
    padding: 1rem;
    border: none;
    resize: none;
    outline: none;
    line-height: 1.6;
}

.right-column {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

.diagram-panel {
    flex: 2;
}

#diagram-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background-color: var(--bg-dark);
    background-image: radial-gradient(var(--border) 1px, transparent 0);
    background-size: 20px 20px;
    padding: 2rem;
}

.analysis-panel {
    flex: 1;
}

#analysis-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
}

/* ER Diagram Nodes */
.table-node {
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 200px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    position: absolute;
    cursor: grab;
    user-select: none;
}

.table-node:active {
    cursor: grabbing;
}

.table-header {
    background-color: var(--bg-surface);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    border-top-left-radius: var(--radius);
    border-top-right-radius: var(--radius);
    font-weight: 600;
    color: var(--secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header .row-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: normal;
}

.table-columns {
    padding: 0.5rem 0;
}

.table-column {
    padding: 0.25rem 0.75rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-family: var(--font-code);
}

.table-column .col-name {
    color: var(--text-main);
}

.table-column .col-type {
    color: var(--text-muted);
}

.table-column.pk .col-name {
    color: #ffd700;
    font-weight: bold;
}

.table-column.fk .col-name {
    color: var(--secondary);
}

/* SVG Lines */
svg.connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

path.rel-line {
    fill: none;
    stroke: var(--secondary);
    stroke-width: 2;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 1s ease forwards;
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

/* Analysis Items */
.insight-item {
    background-color: var(--bg-surface);
    border-left: 3px solid var(--primary);
    padding: 0.75rem 1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 0.75rem;
}

.insight-item.warning {
    border-left-color: var(--accent);
}

.insight-item h3 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: #fff;
}

.insight-item p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.insight-item code {
    font-family: var(--font-code);
    background-color: var(--bg-dark);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    color: var(--secondary);
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
    }

    .input-panel {
        min-height: 200px;
        flex: none;
        max-width: 100%;
    }

    .diagram-panel {
        min-height: 300px;
    }
}