:root {
    /* Clean Minimalist Light Theme */
    --bg-color: #fafafa;
    --text-color: #111111;
    --text-muted: #666666;
    --border-color: #eaeaea;
    --border-hover: #cccccc;
    --primary-color: #000000;
    --primary-hover: #333333;
    --primary-text: #ffffff;
    --surface-color: #ffffff;
    --drag-over-bg: #f5f5f5;
    --danger-color: #e00;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --radius: 6px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    padding: 2rem 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    margin-bottom: 2rem;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    letter-spacing: -0.02em;
}

header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.input-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .input-section {
        grid-template-columns: 1fr 1fr;
    }
}

.drop-zone {
    background-color: var(--surface-color);
    border: 1px dashed var(--border-hover);
    border-radius: var(--radius);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary-color);
    background-color: var(--drag-over-bg);
}

.drop-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
}

.hidden-input {
    display: none;
}

.paste-zone {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.paste-zone label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.paste-zone textarea {
    flex-grow: 1;
    min-height: 120px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.875rem;
    resize: vertical;
    margin-bottom: 1rem;
    background-color: var(--surface-color);
    color: var(--text-color);
}

.paste-zone textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    font-family: var(--font-family);
}

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

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

.btn-secondary {
    background-color: var(--surface-color);
    color: var(--text-color);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: var(--drag-over-bg);
    border-color: var(--border-hover);
}

.actions-section {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    justify-content: flex-end;
}

.hidden {
    display: none !important;
}

/* Table Styles */
.table-container {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

th, td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

th {
    background-color: var(--bg-color);
    font-weight: 500;
    color: var(--text-muted);
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
}

th::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
}

th.draggable {
    cursor: grab;
}

th.draggable:active {
    cursor: grabbing;
}

th.dragging {
    opacity: 0.5;
    background-color: var(--drag-over-bg);
}

th.drag-over {
    border-left: 2px solid var(--primary-color);
}

/* Row Drag and Drop & Row Actions */
tr.dragging-row {
    opacity: 0.5;
    background-color: var(--drag-over-bg);
}
tr.drag-over-row {
    border-top: 2px solid var(--primary-color);
}
.row-actions {
    width: 60px;
    text-align: center;
    white-space: nowrap;
}
.row-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    user-select: none;
    margin-right: 8px;
}
.row-drag-handle.disabled {
    cursor: not-allowed;
    opacity: 0.3;
}
.row-drag-handle:active:not(.disabled) {
    cursor: grabbing;
}
.btn-delete-row {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 0.875rem;
    opacity: 0.5;
    transition: opacity 0.2s;
    padding: 0;
}
tr:hover .btn-delete-row {
    opacity: 1;
}
.btn-delete-row:hover {
    font-weight: bold;
}

tbody tr:hover {
    background-color: var(--drag-over-bg);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
}
.pagination-controls span {
    font-size: 0.875rem;
    color: var(--text-muted);
}
.pagination-controls button {
    padding: 0.5rem 1rem;
}
.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Dark Theme */
:root[data-theme="dark"] {
    --bg-color: #000000;
    --text-color: #ededed;
    --text-muted: #a3a3a3;
    --border-color: #333333;
    --border-hover: #555555;
    --primary-color: #ffffff;
    --primary-hover: #cccccc;
    --primary-text: #000000;
    --surface-color: #111111;
    --drag-over-bg: #1a1a1a;
    --danger-color: #ff5555;
}

/* Header updates */
.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    position: absolute;
    right: 0;
    color: var(--text-color);
}

/* Toolbar */
.actions-section {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* SQL Console */
.sql-section {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.sql-section label {
    font-weight: 500;
}

.sql-section code {
    background-color: var(--bg-color);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
}

.CodeMirror {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: monospace;
    height: 120px !important;
    font-size: 14px;
}

.sql-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.sql-error {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.toolbar {
    display: flex;
    gap: 0.5rem;
}

.button-group {
    display: flex;
    gap: 1rem;
}

.form-control {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--surface-color);
    color: var(--text-color);
    font-family: var(--font-family);
    font-size: 0.875rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Header UI Elements */
.th-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.th-text {
    flex-grow: 1;
    cursor: pointer;
}

.th-text:hover {
    text-decoration: underline;
}

.btn-delete-col {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity 0.2s;
    padding: 0 4px;
}

th:hover .btn-delete-col {
    opacity: 1;
}

.btn-delete-col:hover {
    opacity: 1;
    font-weight: bold;
}

/* Inline Editing */
td.editing {
    padding: 0;
}

td input.edit-input {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 0.75rem 1rem;
    border: 2px solid var(--primary-color);
    border-radius: 0;
    background-color: var(--surface-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: inherit;
    outline: none;
    margin: 0;
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--surface-color);
    color: var(--text-color);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-body h3 {
    margin: 1rem 0 0.5rem 0;
    font-size: 1.1rem;
}

.modal-body ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.modal-body pre {
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: monospace;
}

.btn-insert-col, .btn-insert-row {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity 0.2s, font-weight 0.2s, transform 0.2s;
    padding: 0 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

th:hover .btn-insert-col, tr:hover .btn-insert-row {
    opacity: 1;
}

.btn-insert-col:hover, .btn-insert-row:hover {
    transform: scale(1.2);
}

/* Custom Dialog Additions */
.custom-dialog {
    max-width: 400px;
    padding: 2rem;
}

.custom-dialog h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.custom-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}
