/* ============================================================
   Database Schema Designer — Styles
   Premium dark canvas UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --primary: #6366F1;
    --primary-light: #818CF8;
    --secondary: #10B981;
    --accent: #F59E0B;
    --bg: #0B0E14;
    --bg-elevated: #141821;
    --bg-surface: #1E2330;
    --bg-card: #1A1F2C;
    --bg-hover: #272D3D;
    --text-primary: #E8ECF4;
    --text-secondary: #8B95A8;
    --text-muted: #555F73;
    --border: #2A3040;
    --border-light: #363F54;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 20px rgba(0, 0, 0, .4);
    --transition: 200ms ease;
    --font: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --schema-blue: #3B82F6;
    --schema-green: #10B981;
    --schema-purple: #8B5CF6;
    --schema-orange: #F97316;
    --schema-pink: #EC4899;
    --schema-teal: #14B8A6;
}

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

html,
body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    overflow: hidden;
}

/* --- Layout --- */
.app-layout {
    display: flex;
    height: 100vh;
}

/* --- Toolbar --- */
.toolbar {
    width: 52px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 4px;
    flex-shrink: 0;
    z-index: 10;
}

.tool-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.tool-btn:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

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

.tool-divider {
    width: 28px;
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

/* --- Canvas --- */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--bg);
    cursor: default;
}

.canvas-container.panning {
    cursor: grab;
}

.canvas-container.panning:active {
    cursor: grabbing;
}

.canvas-grid {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle, var(--border) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}

.canvas-world {
    position: absolute;
    transform-origin: 0 0;
}

/* --- Table Entity --- */
.entity-table {
    position: absolute;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: move;
    user-select: none;
}

.entity-header {
    padding: 8px 12px;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: .85rem;
}

.entity-columns {
    padding: 0;
}

.col-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: .8rem;
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
}

.col-row:hover {
    background: rgba(255, 255, 255, .03);
}

.col-icon {
    font-size: .7rem;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.col-name {
    flex: 1;
}

.col-type {
    color: var(--text-muted);
    font-size: .7rem;
}

.entity-add-col {
    display: block;
    width: 100%;
    padding: 6px 12px;
    border: none;
    border-top: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: .75rem;
    cursor: pointer;
    text-align: left;
    border-radius: 0 0 var(--radius) var(--radius);
}

.entity-add-col:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* --- Relationship Lines --- */
.relationship-line {
    stroke: var(--text-muted);
    stroke-width: 1.5;
    fill: none;
}

.relationship-arrow {
    fill: var(--text-muted);
}

/* --- Side Panel --- */
.side-panel {
    width: 280px;
    background: var(--bg-elevated);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.side-panel.hidden {
    display: none;
}

.panel-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.panel-label {
    font-size: .7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.panel-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: .85rem;
    outline: none;
    margin-bottom: 6px;
}

.panel-input:focus {
    border-color: var(--primary);
}

select.panel-input {
    appearance: none;
    cursor: pointer;
}

.panel-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    margin-bottom: 4px;
}

.panel-checkbox input {
    accent-color: var(--primary);
}

.panel-btn {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: .8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 4px;
}

.panel-btn:hover {
    background: var(--bg-hover);
}

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

/* --- Export Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
}

.modal-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
    max-height: 60vh;
}

.modal-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.export-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.export-tab {
    padding: 8px 14px;
    border: none;
    background: none;
    font-family: var(--font);
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

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

.export-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.export-code {
    font-family: var(--font-mono);
    font-size: .8rem;
    line-height: 1.6;
    white-space: pre;
    color: var(--text-primary);
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: .85rem;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition);
    z-index: 200;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    .side-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
    }

    .toolbar {
        width: 44px;
    }
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}