:root {
    --bg-dark: #09090b;
    --bg-card: #141417;
    --sidebar-bg: #0d0d0f;
    --border-color: #27272a;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --accent-primary: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-glow: rgba(139, 92, 246, 0.3);
    --danger: #ef4444;
    --success: #10b981;
    --header-height: 64px;
    --sidebar-width: 260px;
    --transition-speed: 0.2s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body.dark-theme {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.025em;
}

.logo-icon {
    font-size: 1.5rem;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0.75rem;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    padding: 0 0.75rem;
    letter-spacing: 0.05em;
}

.nav-list {
    list-style: none;
}

.nav-list li {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.nav-list li:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-list li.active {
    background-color: rgba(139, 92, 246, 0.1);
    color: var(--accent-primary);
    font-weight: 500;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
}

.avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-primary), #3b82f6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.user-status {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.top-header {
    height: var(--header-height);
    background-color: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 5;
}

.top-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.main-nav {
    display: flex;
    gap: 0.5rem;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all var(--transition-speed);
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--accent-primary);
    background-color: rgba(139, 92, 246, 0.1);
}

.content-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    position: relative;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.view.active {
    display: block;
}

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

/* Glassmorphism Cards */
.glass {
    background: rgba(20, 20, 23, 0.6);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.hero-card {
    padding: 3rem;
    max-width: 600px;
    margin: 4rem auto;
    text-align: center;
}

.hero-card h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.hero-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    border: 1px solid transparent;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
    box-shadow: 0 0 15px var(--accent-glow);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #27272a;
    color: var(--text-primary);
    border-color: #3f3f46;
}

.btn-secondary:hover {
    background-color: #3f3f46;
}

.btn-ghost {
    background: none;
    color: var(--text-secondary);
    border: none;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

/* Tables */
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(0, 0, 0, 0.1);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* SQL Editor */
.sql-editor-container {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.editor-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#sql-input, .code-editor {
    width: 100%;
    min-height: 200px;
    background: none;
    border: none;
    color: #e4e4e7;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    resize: vertical;
    outline: none;
}

.sql-results-container {
    margin-top: 1rem;
}

/* Functions View */
.functions-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
    height: calc(100vh - var(--header-height) - 4rem);
}

.functions-sidebar {
    padding: 1rem;
}

.function-editor-area {
    display: flex;
    flex-direction: column;
}

.code-editor {
    flex: 1;
}

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

.modal {
    width: 100%;
    max-width: 500px;
    padding: 1.5rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-body label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.modal-body input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: white;
    margin-bottom: 1rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.text-danger {
    color: var(--danger) !important;
}

.glass-input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

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