body {
    font-family: 'Inter', sans-serif;
    background: #f8fafc;
    overflow: hidden;
}

/* Code Editor Styles */
#codeEditor {
    font-family: 'Fira Code', monospace;
    background: #1e1e1e;
    color: #d4d4d4;
    line-height: 1.6;
    letter-spacing: 0.3px;
    resize: none;
    transition: all 0.2s ease;
}

#codeEditor:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Table Styles */
.table {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: all 0.3s ease;
    overflow: hidden;
    backdrop-filter: blur(10px);
    min-width: 280px;
}

.table:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Table Header */
.font-bold.text-lg.mb-2.bg-gray-100 {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 12px 16px !important;
    margin-bottom: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: -webkit-grab;
    cursor: grab;
    user-select: none;
    transition: all 0.2s ease;
}

.font-bold.text-lg.mb-2.bg-gray-100:hover {
    background: linear-gradient(135deg, #34495e, #2980b9);
}

.font-bold.text-lg.mb-2.bg-gray-100:active {
    cursor: -webkit-grabbing !important;
    cursor: grabbing !important;
    background: linear-gradient(135deg, #2c3e50, #2980b9);
    transform: scale(0.98);
}

/* Field Styles */
[data-field] {
    padding: 10px 16px;
    margin: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: rgba(249, 250, 251, 0.5);
    border: 1px solid transparent;
}

[data-field]:hover {
    background: rgba(243, 244, 246, 0.8);
    border-color: rgba(59, 130, 246, 0.1);
}

/* Field Count Badge */
.text-xs.bg-indigo-600 {
    background: rgba(255, 255, 255, 0.2) !important;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Icons */
.fa-key {
    color: #f59e0b;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

.fa-link {
    color: #3b82f6;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

/* Field Types */
.text-gray-600 {
    color: #4b5563;
    font-size: 0.9em;
    font-family: 'Monaco', 'Consolas', monospace;
}

/* Error States */
.error-field {
    background: rgba(254, 226, 226, 0.5) !important;
    border-color: rgba(239, 68, 68, 0.2) !important;
}

.error-field:hover {
    background: rgba(254, 226, 226, 0.8) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.fa-exclamation-circle {
    color: #ef4444;
    animation: pulse 2s infinite;
}

/* Highlight Styles */
.highlight-field {
    background-color: rgba(59, 130, 246, 0.08) !important;
    /* border: 1px solid rgba(59, 130, 246, 0.2); */
}

.highlight-line {
    animation: pulse 2s infinite;
}

.leader-line {
    z-index: 1 !important;
}

/* LeaderLine container fix */
.leader-line-wrapper-div {
    overflow: visible !important;
    position: absolute !important;
    pointer-events: none !important;
    z-index: 1 !important;
}

/* Diagram Container */
#diagram {
    background-size: 25px 25px;
    background-image:
        linear-gradient(to right, rgba(226, 232, 240, 0.3) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(226, 232, 240, 0.3) 1px, transparent 1px);
    position: relative;
    box-sizing: border-box;
    min-width: 5000px;
    min-height: 4000px;
    padding: 2000px;
    cursor: default;
}

#diagram:active {
    cursor: grabbing;
}

/* Custom Scrollbar */
#diagram::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

#diagram::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
}

#diagram::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 6px;
    border: 3px solid #f1f5f9;
}

#diagram::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Make parent container scrollable */
.w-23 {
    overflow: auto;
}

/* Keep zoom controls visible */
.zoom-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
}

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

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

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

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

/* Leader Line Customization */
.leader-line {
    z-index: 10;
}

/* Layout */
.editor-container {
    width: 100%;
    background: #1e1e1e;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.editor-header {
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
    padding: 12px 16px;
    color: #d4d4d4;
}

.diagram-container {
    position: relative;
    overflow: auto;
    border-radius: 8px;
    background: white;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Add export dialog styles */
.dialog-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.dialog-overlay.show {
    display: flex;
}

.dialog {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    max-width: 24rem;
    width: 100%;
}

.dialog-option {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin: 0.5rem 0;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.dialog-option:hover {
    border-color: #3b82f6;
    background: #f8fafc;
}

.dialog-option i {
    font-size: 1.5rem;
    margin-right: 1rem;
}

/* Animation classes */
@keyframes highlight-table {
    0% {
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5);
    }

    100% {
        box-shadow: 0 0 0 2px rgba(59, 130, 246, 0);
    }
}

@keyframes highlight-text {
    0% {
        background-color: transparent;
    }

    50% {
        background-color: rgba(59, 130, 246, 0.1);
    }

    100% {
        background-color: transparent;
    }
}

.table-highlight {
    animation: highlight-table 0.8s ease-in-out;
}

.text-highlight {
    animation: highlight-text 0.8s ease-in-out;
}

/* Smooth transitions only during undo/redo */
.table-animated {
    transition: left 0.3s ease-out, top 0.3s ease-out;
}

/* Mobile Responsive Styles */
@media (max-width: 1024px) {
    #sidebar {
        overflow-y: auto;
    }

    #diagramPanel {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .table {
        min-width: 240px;
    }

    .diagram-container {
        border-radius: 0;
    }

    #bottomBar {
        flex-wrap: wrap;
        gap: 4px;
    }

    #historyStatus {
        width: 100%;
        text-align: center;
        order: -1;
    }
}

/* Bottom bar styles */
.leader-line-wrapper-div {
    overflow: visible !important;
}

/* Dark Theme Styles */
body.dark {
    background: #0f172a;
}

body.dark .w-2\/3 {
    background: linear-gradient(135deg, #1e293b, #0f172a);
}

body.dark .diagram-container {
    background: #1e293b;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
}

body.dark #diagram {
    background-color: #1e293b;
    background-image:
        linear-gradient(to right, rgba(51, 65, 85, 0.3) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(51, 65, 85, 0.3) 1px, transparent 1px);
}

body.dark .table {
    background: #334155;
    border-color: rgba(71, 85, 105, 0.5);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

body.dark .font-bold.text-lg.mb-2.bg-gray-100 {
    background: linear-gradient(135deg, #1e3a5f, #1e40af);
}

body.dark [data-field] {
    background: rgba(51, 65, 85, 0.5);
    border-color: transparent;
}

body.dark [data-field]:hover {
    background: rgba(71, 85, 105, 0.8);
}

body.dark .text-gray-600 {
    color: #94a3b8;
}

body.dark .px-4.py-2.bg-white {
    background: #334155;
    color: #e2e8f0;
}

body.dark .fa-database {
    color: #818cf8;
}

body.dark .fa-moon,
body.dark .fa-sun {
    color: #818cf8;
}

body.dark .dialog {
    background: #1e293b;
}

body.dark .dialog h2 {
    color: #f1f5f9;
}

body.dark .dialog p {
    color: #94a3b8;
}

body.dark .dialog-option {
    border-color: #334155;
}

body.dark .dialog-option:hover {
    background: #334155;
    border-color: #818cf8;
}