:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(18, 26, 43, 0.75);
    --bg-sidebar: #0f1626;
    --bg-input: #172238;
    --bg-hover: rgba(0, 240, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(0, 240, 255, 0.3);
    
    --primary: #00f0ff;
    --primary-gradient: linear-gradient(135deg, #00f0ff, #7000ff);
    --primary-glow: rgba(0, 240, 255, 0.25);
    --accent: #7000ff;
    --success: #00ff87;
    --warning: #ffb703;
    --danger: #ff0055;

    --text-main: #f0f4f8;
    --text-muted: #8e9bb0;
    --text-code: #00f0ff;

    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.35);
    --glass-blur: blur(14px);
    --radius: 12px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-main: #f4f7fb;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-sidebar: #ffffff;
    --bg-input: #eef2f7;
    --bg-hover: rgba(112, 0, 255, 0.06);
    --border-color: rgba(0, 0, 0, 0.1);
    --border-hover: rgba(112, 0, 255, 0.3);

    --primary: #0066ff;
    --primary-gradient: linear-gradient(135deg, #0066ff, #7000ff);
    --primary-glow: rgba(0, 102, 255, 0.2);
    --accent: #7000ff;

    --text-main: #1a202c;
    --text-muted: #64748b;
    --text-code: #0055cc;

    --shadow-card: 0 10px 25px rgba(0, 0, 0, 0.08);
}

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

body, html {
    width: 100%;
    height: 100%;
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
    transition: background 0.3s ease, color 0.3s ease;
}

/* App Container */
#app {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 7, 15, 0.82);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}
.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.login-card {
    width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border-hover);
    border-radius: 20px;
    padding: 2.2rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 40px var(--primary-glow);
    backdrop-filter: var(--glass-blur);
    animation: popup 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popup {
    from { transform: scale(0.9) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.login-header {
    text-align: center;
    margin-bottom: 1.8rem;
}
.login-header .logo-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-gradient);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: #fff;
    margin-bottom: 12px;
    box-shadow: 0 8px 20px var(--primary-glow);
}
.login-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.login-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-group {
    margin-bottom: 1.2rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrapper i {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
}
.input-wrapper input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}
.input-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

.form-row {
    display: flex;
    gap: 12px;
}
.form-row .form-group {
    flex: 1;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 20px var(--primary-glow);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px var(--primary-glow);
}
.btn-primary:active {
    transform: translateY(0);
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
}
.sidebar-header {
    padding: 1.5rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.2rem;
}
.sidebar-brand i {
    color: var(--primary);
    font-size: 1.4rem;
}

.sidebar-search {
    padding: 12px 16px;
}
.sidebar-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
}
.sidebar-search input:focus {
    border-color: var(--primary);
}
.sidebar-search i {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.db-tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
}
.db-item {
    margin-bottom: 6px;
}
.db-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: var(--transition);
}
.db-header:hover, .db-header.active {
    background: var(--bg-hover);
    color: var(--primary);
}
.db-header i.arrow {
    transition: transform 0.2s ease;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.db-header.open i.arrow {
    transform: rotate(90deg);
}

.table-list {
    margin-left: 16px;
    display: none;
    padding-left: 8px;
    border-left: 1px dashed var(--border-color);
}
.table-list.open {
    display: block;
}
.table-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    margin: 2px 0;
    transition: var(--transition);
}
.table-item:hover, .table-item.active {
    background: var(--bg-hover);
    color: var(--primary);
}
.table-item .badge {
    font-size: 0.7rem;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Main Area */
.main-content {
    flex: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Navbar */
.top-navbar {
    height: 64px;
    padding: 0 1.8rem;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}
.breadcrumb span.crumb-db {
    color: var(--primary);
}
.breadcrumb span.crumb-table {
    color: var(--text-main);
}
.breadcrumb i.sep {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}
.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* Tabs */
.tabs-header {
    display: flex;
    padding: 0 1.8rem;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    gap: 6px;
    flex-shrink: 0;
}
.tab-btn {
    padding: 12px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}
.tab-btn:hover {
    color: var(--text-main);
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Tab Panels */
.tab-panel {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: none;
}
.tab-panel.active {
    display: flex;
    flex-direction: column;
}

/* Control Bar */
.control-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 12px;
}
.search-box {
    position: relative;
    width: 280px;
}
.search-box input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
}
.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.pagination-controls select {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    outline: none;
}

/* Data Table Container */
.table-wrapper {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: auto;
    box-shadow: var(--shadow-card);
    backdrop-filter: var(--glass-blur);
}
table.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}
table.custom-table th {
    position: sticky;
    top: 0;
    background: var(--bg-sidebar);
    padding: 12px 16px;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    user-select: none;
    cursor: pointer;
    white-space: nowrap;
    z-index: 5;
}
table.custom-table th:hover {
    color: var(--primary);
}
table.custom-table th i.sort-icon {
    font-size: 0.75rem;
    margin-left: 4px;
}
table.custom-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-mono);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
table.custom-table tr:hover td {
    background: var(--bg-hover);
}

/* SQL Console Panel */
.sql-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}
.sql-editor-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
textarea#sql-input {
    width: 100%;
    height: 120px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: var(--text-code);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    resize: vertical;
    outline: none;
}
textarea#sql-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}
.sql-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.quick-queries {
    display: flex;
    gap: 8px;
}
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}
.btn-sm:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Server Status Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.5rem;
}
.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.2rem;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-card);
}
.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.metric-info h4 {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}
.metric-info p {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 2px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    padding: 12px 20px;
    border-radius: 10px;
    background: var(--bg-sidebar);
    color: var(--text-main);
    border: 1px solid var(--border-hover);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}
.empty-state i {
    font-size: 3.5rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Spinner Animation for Lucide Icons */
.spin {
    animation: spin 1s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
