/* CSS Variables & Blue Minimal Theme */
:root {
    --bg-main: #090d16;
    --bg-card: #0f172a;
    --bg-card-hover: #1e293b;
    --bg-header: rgba(9, 13, 22, 0.85);
    --border-color: rgba(56, 189, 248, 0.15);
    --border-color-light: rgba(56, 189, 248, 0.3);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-blue: #38bdf8;
    --accent-blue-hover: #0284c7;
    --accent-blue-dark: #1d4ed8;
    
    --key-primary: #fbbf24;
    --key-unique: #34d399;
    --key-index: #818cf8;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.2);
    
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-code: 'Fira Code', monospace;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color-light);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

.spin {
    animation: spin 1.2s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Login Modal */
.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 13, 22, 0.88);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color-light);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    padding: 36px 32px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

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

.icon-circle {
    width: 64px;
    height: 64px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid var(--accent-blue);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--accent-blue);
    margin-bottom: 16px;
}

.login-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.login-header .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
}

.login-form input {
    width: 100%;
    padding: 12px 42px 12px 14px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 15px;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.btn-icon-inside {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.error-msg {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid #f43f5e;
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #0284c7, var(--accent-blue));
    border: none;
    border-radius: var(--radius-sm);
    color: #ffffff;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.link-home {
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.link-home:hover {
    color: var(--accent-blue);
}

/* Dashboard View */
.dashboard-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header Navbar */
.navbar {
    background: var(--bg-header);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    height: 56px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 22px;
    color: var(--accent-blue);
}

.brand-text {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-text .title {
    font-weight: 700;
    font-size: 17px;
}

.badge-readonly {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-home {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-home:hover {
    background: var(--accent-blue);
    color: #ffffff;
}

.btn-action {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover {
    color: var(--accent-blue);
}

.btn-logout {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #f43f5e;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: #f43f5e;
    color: #ffffff;
}

/* App Body Layout */
.app-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-search {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

.sidebar-search:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.db-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.db-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.db-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.db-item.active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-blue);
}

.table-list {
    padding-left: 24px;
}

.table-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.table-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.table-item.active {
    color: var(--accent-blue);
    font-weight: 600;
}

.badge-rowcount {
    font-size: 10px;
    background: var(--bg-main);
    padding: 1px 6px;
    border-radius: 8px;
    color: var(--text-muted);
    font-family: var(--font-code);
}

/* Main Panel */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-main);
}

.panel-header {
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.db-path {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.crumb-db {
    color: var(--accent-blue);
}

.crumb-sep {
    color: var(--text-muted);
    font-size: 11px;
}

.crumb-table {
    color: var(--text-primary);
}

/* Tab Nav */
.tab-nav {
    display: flex;
    gap: 6px;
    background: var(--bg-main);
    padding: 3px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn.active {
    background: var(--accent-blue);
    color: #ffffff;
}

/* Panel Body & Tabs */
.panel-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.tab-content {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.search-box {
    position: relative;
    width: 260px;
}

.search-box i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 13px;
}

.search-box input {
    width: 100%;
    padding: 6px 12px 6px 30px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
}

.page-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.select-limit {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.btn-page {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Data Table Grid */
.table-scroll-container {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.data-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.data-grid th {
    position: sticky;
    top: 0;
    background: #0f172a;
    color: var(--accent-blue);
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color-light);
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    z-index: 10;
}

.data-grid td {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(56, 189, 248, 0.08);
    color: var(--text-primary);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: var(--font-code);
}

.data-grid tr:hover td {
    background: var(--bg-card-hover);
}

.key-pri { color: var(--key-primary); font-weight: 700; }
.key-uni { color: var(--key-unique); font-weight: 700; }
.key-mul { color: var(--key-index); }

/* Query Runner */
.query-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
}

.query-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.sql-textarea {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--accent-blue);
    font-family: var(--font-code);
    font-size: 13px;
    padding: 10px;
}

.sql-textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.btn-run {
    background: var(--accent-blue);
    color: #ffffff;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-run:hover {
    background: var(--accent-blue-hover);
}

/* Footer */
.footer {
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-header);
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.footer code {
    font-family: var(--font-code);
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent-blue);
}
