body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    color: #333;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    height: calc(100vh - 48px);
    width: 100vw;
}

.app-header {
    height: 48px;
    background-color: #0f172a;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    color: #f8fafc;
    font-weight: 600;
    font-size: 14px;
    box-sizing: border-box;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}
.app-logo {
    display: flex;
    align-items: center;
    color: #3b82f6;
    margin-right: 16px;
    gap: 8px;
}
.app-logo svg {
    width: 24px;
    height: 24px;
}
.app-logo span {
    color: #f8fafc;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.5px;
}
.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}
.header-input {
    background: #1e293b;
    border: 1px solid #334155;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
}
.header-select {
    background: #1e293b;
    border: 1px solid #334155;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    max-width: 200px;
}

.save-status {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

.header-btn {
    background-color: #3b82f6;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.editor-pane {
    width: 350px;
    background-color: #0f172a;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #1e293b;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    z-index: 20;
}

.keyword-structural {
    color: #c084fc; /* Purple */
    font-weight: 600;
}
.keyword-type {
    color: #38bdf8; /* Sky Blue */
}
.keyword-setting {
    color: #fbbf24; /* Amber */
    font-style: italic;
}

#line-numbers {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 100%;
    background-color: #0f172a;
    border-right: 1px solid #1e293b;
    color: #475569;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    padding: 10px 5px 10px 0;
    text-align: right;
    box-sizing: border-box;
    overflow: hidden;
    z-index: 5;
    user-select: none;
}

#code-editor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 10px 10px 10px 50px;
    border: 0;
    box-sizing: border-box;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    overflow: auto;
    white-space: pre;
    outline: none;
    color: #e2e8f0;
}

.editor-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.diagram-pane {
    flex: 1;
    background-color: #f1f5f9;
    position: relative;
    overflow: auto;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 20px 20px;
}

.table-node {
    width: 240px;
    background: #ffffff;
    border-radius: 12px;
    position: absolute;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: box-shadow 0.2s, transform 0.1s;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.05);
}

.table-node:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
    z-index: 100;
}

.table-node.ui-draggable-dragging {
    transition: none !important;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 1000;
}

.table-header {
    background: #1e293b;
    color: #f8fafc;
    padding: 12px 16px;
    font-weight: 600;
    cursor: grab;
    font-size: 13px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.table-row {
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #334155;
    transition: background-color 0.1s;
}

.table-row:hover {
    background-color: #f8fafc;
}

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

.row-type {
    color: #64748b;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    background-color: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.toolbar {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 10;
    display: flex;
    gap: 4px;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    padding: 6px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0,0,0,0.05);
}
.toolbar button {
    background: transparent;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #475569;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: none;
}
.toolbar button:hover {
    background: #f1f5f9;
    color: #0f172a;
}
#zoom-level {
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    min-width: 40px;
    text-align: center;
    background: transparent;
    border: none;
    box-shadow: none;
}
#diagram-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

#code-editor::-webkit-scrollbar-thumb {
    background: #334155;
}

#code-editor::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.suggestion-box {
    position: absolute;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    min-width: 150px;
    padding: 4px;
}
.suggestion-item {
    padding: 6px 10px;
    cursor: pointer;
    color: #cbd5e1;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    border-radius: 4px;
}
.suggestion-item:hover, .suggestion-item.active {
    background-color: #3b82f6;
    color: white;
}

/* Connection Styles */
.connection-group {
    cursor: pointer;
}

.conn-line {
    transition: stroke 0.2s, stroke-width 0.2s;
    pointer-events: none;
}

.connection-group:hover .conn-line,
.connection-group.selected .conn-line {
    stroke: #3b82f6 !important;
    stroke-width: 3px !important;
}

.conn-hit {
    pointer-events: stroke;
}
.connection-handle {
    width: 10px;
    height: 10px;
    background-color: #3b82f6;
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    cursor: col-resize;
    z-index: 50;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.1s;
}
.connection-handle:hover {
    transform: translate(-50%, -50%) scale(1.2);
}


.connection-handle:hover {
     transform: translate(-50%, -50%) scale(1.2);
 }

/* Login Page Styles */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100vw;
    background-color: #0f172a;
    overflow-y: auto;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background-color: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    color: #3b82f6;
    font-size: 24px;
    font-weight: 700;
    gap: 12px;
    letter-spacing: -0.5px;
}

.login-brand svg {
    width: 32px;
    height: 32px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-title {
    color: #f8fafc;
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.login-subtitle {
    color: #94a3b8;
    font-size: 14px;
    margin: 0;
}

.input-group {
    margin-bottom: 20px;
}

.input-label {
    display: block;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.input-field {
    width: 100%;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 10px 12px;
    color: #f8fafc;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.input-field:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.btn-primary {
    width: 100%;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 8px;
}

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

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 14px;
    color: #64748b;
}

.login-footer a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.login-footer a:hover {
    text-decoration: underline;
}

.error-alert {
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 24px;
    display: none;
    text-align: center;
}
