/* ==========================================================================
   PHP MySQL Explorer & Viewer - Modern Glassmorphism Style
   ========================================================================== */

:root {
    --bg-base: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-elevated: #334155;
    --bg-glass: rgba(30, 41, 59, 0.85);
    
    --accent-primary: #38bdf8;
    --accent-primary-hover: #0284c7;
    --accent-secondary: #818cf8;
    --accent-success: #34d399;
    --accent-warning: #fbbf24;
    --accent-danger: #f87171;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-light: rgba(255, 255, 255, 0.15);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);
    
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
    --bg-base: #f1f5f9;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #e2e8f0;
    --bg-glass: rgba(255, 255, 255, 0.85);
    
    --accent-primary: #0284c7;
    --accent-primary-hover: #0369a1;
    --accent-secondary: #4f46e5;
    --accent-success: #10b981;
    --accent-warning: #d97706;
    --accent-danger: #ef4444;
    
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    
    --border-color: rgba(0, 0, 0, 0.1);
    --border-color-light: rgba(0, 0, 0, 0.18);
    
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 15px rgba(2, 132, 199, 0.2);
}

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

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

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    height: 60px;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
}

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

.brand-icon {
    width: 26px;
    height: 26px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.5));
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, #f8fafc 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(56, 189, 248, 0.3);
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.header-center {
    display: flex;
    align-items: center;
}

.db-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color-light);
}

.db-selector-wrapper label {
    font-weight: 600;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.server-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    background: rgba(15, 23, 42, 0.6);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-online .status-dot {
    background-color: var(--accent-success);
    box-shadow: 0 0 8px var(--accent-success);
}

.status-offline .status-dot {
    background-color: var(--accent-danger);
    box-shadow: 0 0 8px var(--accent-danger);
}

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

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

.sidebar-section {
    display: flex;
    flex-direction: column;
    padding: 12px;
}

.sidebar-section.sidebar-tables {
    flex: 1;
    border-top: 1px solid var(--border-color);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.search-box {
    margin-bottom: 8px;
}

.search-box input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    outline: none;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.sidebar-list {
    list-style: none;
    overflow-y: auto;
    max-height: 180px;
    margin: 0;
    padding: 0;
}

.table-list {
    max-height: none;
    flex: 1;
}

.sidebar-list li {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.sidebar-list li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.sidebar-list li.active {
    background: var(--accent-primary);
    color: #0f172a;
    font-weight: 600;
}

.sidebar-list li.active .badge {
    background: rgba(15, 23, 42, 0.25);
    color: #0f172a;
}

.sidebar-list .item-icon {
    margin-right: 8px;
}

.empty-msg {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.8rem;
    text-align: center;
    padding: 12px 0 !important;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-base);
    padding: 16px 20px;
}

/* Context Bar */
.context-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.context-info {
    font-size: 1.05rem;
    font-weight: 600;
}

.context-db {
    color: var(--accent-primary);
}

.context-separator {
    color: var(--text-dim);
    margin: 0 6px;
}

.context-table {
    color: var(--accent-secondary);
}

/* Tabs */
.tabs-nav {
    display: flex;
    gap: 6px;
}

.tab-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    background: var(--bg-surface-elevated);
    color: var(--accent-primary);
    border-color: var(--border-color-light);
    font-weight: 600;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

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

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

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-group {
    display: flex;
    gap: 6px;
}

.input-group input {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    width: 280px;
    outline: none;
}

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

/* Form Controls & Buttons */
.btn {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--accent-primary);
    color: #0f172a;
    font-weight: 600;
}

.btn-primary:hover {
    background: #0284c7;
    color: #ffffff;
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color-light);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.78rem;
}

.btn-icon {
    padding: 6px;
    background: var(--bg-surface-elevated);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.select-input {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    outline: none;
    font-size: 0.85rem;
}

.select-sm {
    padding: 4px 8px;
    font-size: 0.78rem;
}

/* Cards & Tables */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.card-header {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-body {
    padding: 16px;
}

.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.table-responsive {
    overflow-x: auto;
    max-height: calc(100vh - 250px);
}

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

th {
    background: var(--bg-surface-elevated);
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--accent-primary);
}

td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

tr:hover {
    background: rgba(56, 189, 248, 0.04);
}

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

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

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-indicator {
    font-size: 0.82rem;
    margin: 0 6px;
    color: var(--text-main);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-card);
}

.stat-title {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin: 4px 0;
}

.stat-desc {
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* Badges & Code */
.badge {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-pk {
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-warning);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.code-block {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    padding: 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: #e2e8f0;
    overflow-x: auto;
    white-space: pre-wrap;
}

.sql-editor {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    outline: none;
    resize: vertical;
}

.sql-editor:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Placeholder States */
.placeholder-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog {
    width: 100%;
    max-width: 420px;
    padding: 16px;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

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

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 14px 20px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-control {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    outline: none;
}

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

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-surface-elevated);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}
