:root {
    --primary: #1e4b69;
    --accent: rgb(70, 180, 200);
    --bg: #f5f7fa;
    --pk-color: #2980b9;
    --fk-color: #27ae60;
    --regular-color: #7f8c8d;
    --highlight: #f39c12;
}

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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: #333;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 900px;
    width: 100%;
}

h1 {
    color: var(--primary);
    text-align: center;
    margin-bottom: 4px;
    font-size: 1.6rem;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.diagram-area {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 40px 30px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    min-height: 340px;
}

.connector-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connector-svg line {
    stroke: var(--fk-color);
    stroke-width: 2.5;
    stroke-dasharray: 6 4;
    opacity: 0.5;
    transition: opacity 0.3s, stroke-width 0.3s, stroke 0.3s;
}

.connector-svg line.highlighted {
    opacity: 1;
    stroke-width: 4;
    stroke: var(--highlight);
    stroke-dasharray: none;
}

.connector-svg circle {
    transition: fill 0.3s, r 0.3s;
}

.tables-wrapper {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    gap: 80px;
    position: relative;
    z-index: 2;
}

.db-table {
    flex: 1;
    max-width: 320px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid #e0e0e0;
    transition: border-color 0.3s;
}

.db-table.active {
    border-color: var(--highlight);
}

.table-header {
    background: var(--primary);
    color: white;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    letter-spacing: 0.5px;
}

.table-columns {
    background: white;
}

.column-row {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    gap: 10px;
}

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

.column-row:hover {
    background: #f0f7ff;
    transform: translateX(3px);
}

.column-row.highlighted {
    background: #fff8e1;
    box-shadow: inset 4px 0 0 var(--highlight);
}

.key-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    color: white;
    flex-shrink: 0;
    min-width: 28px;
    text-align: center;
}

.key-badge.pk {
    background: var(--pk-color);
}

.key-badge.fk {
    background: var(--fk-color);
}

.column-name {
    font-weight: 600;
    color: #333;
    flex: 1;
}

.column-type {
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
}

.tooltip {
    position: fixed;
    background: var(--primary);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    max-width: 260px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    line-height: 1.4;
}

.tooltip.visible {
    opacity: 1;
}

.legend {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: #555;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
}

.pk-color {
    background: var(--pk-color);
}

.fk-color {
    background: var(--fk-color);
}

.regular-color {
    background: var(--regular-color);
}

@media (max-width: 700px) {
    .tables-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 30px;
    }

    .db-table {
        max-width: 100%;
        width: 100%;
    }

    .diagram-area {
        padding: 20px 15px;
    }

    .connector-svg {
        display: none;
    }

    .legend {
        gap: 12px;
    }
}
