/* ════════════════════════════════════════════════════════════
   SUAR DB Admin — CSS Design System
   ════════════════════════════════════════════════════════════ */

:root {
    --bg-dark: #0d1117;
    --bg-surface: #161b22;
    --bg-elevated: #1c2333;
    --bg-hover: #21283b;
    --border: #30363d;
    --border-light: #3d444d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-dim: #1f6feb;
    --green: #3fb950;
    --green-dim: #238636;
    --red: #f85149;
    --red-dim: #da3633;
    --yellow: #d29922;
    --purple: #bc8cff;
    --orange: #f0883e;
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

/* ═══ LOGIN ═══ */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #1a1e2e 100%);
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px;
    width: 420px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

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

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,166,255,0.15);
}

.login-error {
    background: rgba(248,81,73,0.1);
    border: 1px solid var(--red-dim);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
}

/* ═══ BUTTONS ═══ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
}

.feature-card-link {
    color: inherit;
    text-decoration: none;
}

.feature-card-link:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

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

.btn-danger {
    background: var(--red-dim);
    color: #fff;
}
.btn-danger:hover { background: var(--red); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-full { width: 100%; justify-content: center; padding: 12px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ═══ BADGES ═══ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-info { background: rgba(88,166,255,0.15); color: var(--accent); }
.badge-success { background: rgba(63,185,80,0.15); color: var(--green); }
.badge-warning { background: rgba(210,153,34,0.15); color: var(--yellow); }
.badge-danger { background: rgba(248,81,73,0.15); color: var(--red); }
.badge-purple { background: rgba(188,140,255,0.15); color: var(--purple); }

/* ═══ TOPBAR ═══ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

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

.topbar-logo { font-size: 22px; }

.topbar-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-user {
    color: var(--text-secondary);
    font-size: 13px;
    padding: 0 8px;
}

/* ═══ MAIN LAYOUT ═══ */
.main-layout {
    display: flex;
    height: calc(100vh - 52px);
}

/* ═══ SIDEBAR ═══ */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 8px;
}

.sidebar-header h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-list { padding: 0 8px 16px; }

.table-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 2px;
}

.table-item:hover { background: var(--bg-hover); }

.table-item.active {
    background: rgba(88,166,255,0.12);
    color: var(--accent);
}

.table-item-name {
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-mono);
}

.table-item-count {
    font-size: 11px;
    background: var(--bg-dark);
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--text-muted);
}

.table-item.active .table-item-count {
    background: rgba(88,166,255,0.2);
    color: var(--accent);
}

/* ═══ CONTENT ═══ */
.content {
    flex: 1;
    overflow: auto;
    padding: 24px;
}

/* ═══ WELCOME ═══ */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.welcome-icon { font-size: 64px; margin-bottom: 16px; }

.welcome-screen h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.welcome-screen > p {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 600px;
}

.feature-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
}

.feature-card span { font-size: 28px; display: block; margin-bottom: 8px; }
.feature-card strong { font-size: 13px; display: block; margin-bottom: 4px; }
.feature-card p { font-size: 11px; color: var(--text-muted); }

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

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

.toolbar-left h2 {
    font-size: 18px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    position: relative;
}

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

.search-box input:focus { outline: none; border-color: var(--accent); }
.search-icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); font-size: 13px; }

/* ═══ DATA TABLE ═══ */
.table-container {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: calc(100vh - 220px);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    background: var(--bg-elevated);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 12px;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.data-table td.cell-null {
    color: var(--text-muted);
    font-style: italic;
}

.data-table td.cell-number {
    color: var(--purple);
}

.data-table td.cell-id {
    color: var(--yellow);
    font-weight: 600;
}

.data-table .row-actions {
    display: flex;
    gap: 4px;
    white-space: nowrap;
}

.data-table .row-actions .btn {
    padding: 3px 8px;
    font-size: 11px;
}

/* ═══ PAGINATION ═══ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination .btn.active {
    background: var(--accent-dim);
    color: #fff;
}

/* ═══ SQL EDITOR ═══ */
.sql-editor {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.sql-header h2 { font-size: 16px; }

.sql-body { padding: 16px; }

#sql-input {
    width: 100%;
    min-height: 120px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 14px;
    padding: 14px;
    resize: vertical;
}

#sql-input:focus { outline: none; border-color: var(--accent); }

.sql-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.sql-hint { color: var(--text-muted); font-size: 12px; }

.sql-result {
    padding: 16px;
    border-top: 1px solid var(--border);
    max-height: 400px;
    overflow: auto;
}

/* ═══ MODALS ═══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 500px;
    max-height: 80vh;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.modal-sm { width: 400px; }

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

.modal-header h3 { font-size: 16px; }

.modal-header-danger {
    background: rgba(248,81,73,0.08);
    border-bottom-color: var(--red-dim);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

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

.text-muted { color: var(--text-muted); font-size: 13px; }

/* ═══ TOAST ═══ */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    min-width: 250px;
    box-shadow: var(--shadow);
}

.toast-success { background: var(--green-dim); color: #fff; }
.toast-error { background: var(--red-dim); color: #fff; }
.toast-info { background: var(--accent-dim); color: #fff; }

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

/* ═══ LOADING ═══ */
.loading-spinner {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
}

/* ═══ SCHEMA INFO ═══ */
.schema-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
}

.schema-pk { background: rgba(210,153,34,0.2); color: var(--yellow); }
.schema-notnull { background: rgba(248,81,73,0.15); color: var(--red); }
.schema-type { background: rgba(188,140,255,0.12); color: var(--purple); }

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
