/* MySQL Viewer Modern Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Fira+Code:wght@400;500&display=swap');

:root, [data-theme="dark"] {
    --bg-main: #0b0f19;
    --bg-surface: #111827;
    --bg-card: #1f2937;
    --bg-card-hover: #374151;
    --border-color: #374151;
    --border-focus: #6366f1;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);
    
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;

    --sidebar-width: 280px;
    --header-height: 64px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #f1f5f9;
    --bg-card-hover: #e2e8f0;
    --border-color: #cbd5e1;
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.lucide {
    width: 1.15rem;
    height: 1.15rem;
    vertical-align: middle;
    display: inline-block;
    stroke-width: 2px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* App Layout */
#app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
}

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

.sidebar-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.05));
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
}

.brand-icon {
    font-size: 1.4rem;
}

.search-box {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

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

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

.db-item {
    margin-bottom: 6px;
}

.db-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: background-color 0.2s;
}

.db-header:hover {
    background-color: var(--bg-card);
}

.db-header.active {
    background: var(--primary-light);
    color: var(--primary);
}

.db-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.table-list {
    margin-left: 14px;
    margin-top: 4px;
    padding-left: 8px;
    border-left: 2px solid var(--border-color);
    display: none;
}

.db-item.open .table-list {
    display: block;
}

.table-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

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

.table-item.active {
    background-color: var(--primary);
    color: #fff;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

/* Top Navigation Bar */
.top-nav {
    height: var(--header-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.current-path {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 600;
}

.path-sep {
    color: var(--text-dim);
}

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

/* View Tabs */
.tabs-bar {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    padding: 0 24px;
    gap: 8px;
}

.tab-btn {
    padding: 12px 18px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Content Body */
.content-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    position: relative;
}

/* Toolbar Controls */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Buttons */
.btn {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    transition: all 0.2s;
    outline: none;
}

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

.btn-secondary {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover {
    background-color: var(--bg-card-hover);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    background-color: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.775rem;
}

/* Data Table Grid */
.table-container {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: auto;
    box-shadow: var(--shadow-md);
    max-height: calc(100vh - 240px);
}

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

.data-table th {
    background-color: var(--bg-card);
    color: var(--text-main);
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
    user-select: none;
}

.data-table th.sortable {
    cursor: pointer;
}

.data-table th.sortable:hover {
    background-color: var(--bg-card-hover);
}

.data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background-color 0.15s;
}

.data-table tbody tr:hover {
    background-color: rgba(99, 102, 241, 0.05);
}

/* Cell Types & Badges */
.null-cell {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.8rem;
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pk { background-color: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }
.badge-uni { background-color: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.badge-mul { background-color: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.4); }
.badge-type { background-color: rgba(139, 92, 246, 0.15); color: #c084fc; font-family: 'Fira Code', monospace; }

/* Pagination Controls */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding: 12px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.page-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* SQL Console */
.sql-console-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sql-editor-wrapper {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.sql-textarea {
    width: 100%;
    height: 160px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: #a5b4fc;
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    padding: 14px;
    resize: vertical;
    outline: none;
}

.sql-textarea:focus {
    border-color: var(--primary);
}

.preset-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
}

.preset-btn:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

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

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
}

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

/* Notification Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-card);
    border-left: 4px solid var(--primary);
    color: var(--text-main);
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease;
}

.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-success { border-left-color: var(--success); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
