/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:         #0f1117;
    --bg-card:    #1a1d27;
    --bg-input:   #12151e;
    --border:     #2a2d3a;
    --border-focus: #4f6ef7;
    --accent:     #4f6ef7;
    --accent-hover: #3d5ce5;
    --danger:     #e05252;
    --danger-hover: #c93f3f;
    --success:    #3ecf8e;
    --text:       #e8eaf0;
    --text-muted: #6b7280;
    --text-dim:   #9ca3af;
    --mono:       'JetBrains Mono', monospace;
    --sans:       'Inter', sans-serif;
    --radius:     8px;
    --radius-lg:  12px;
    --shadow:     0 4px 24px rgba(0,0,0,0.4);
}

html { font-size: 15px; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navbar ───────────────────────────────────────────── */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    letter-spacing: -0.3px;
}
.nav-brand:hover { text-decoration: none; color: var(--accent); }
.nav-brand svg { color: var(--accent); }

.nav-links { display: flex; align-items: center; gap: 0.25rem; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-muted);
    transition: all 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--text); background: rgba(79,110,247,0.12); }
.nav-logout { color: var(--danger); }
.nav-logout:hover { background: rgba(224,82,82,0.1); color: var(--danger); }

/* ── Container ────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}
.container-sm { max-width: 680px; }

/* ── Page Header ──────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
}

.page-sub {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.2rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--text-dim); }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--sans);
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); text-decoration: none; }

.btn-full { width: 100%; justify-content: center; padding: 0.65rem 1rem; }

/* Row action buttons */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 500;
    transition: all 0.15s;
}
.btn-edit { background: rgba(79,110,247,0.15); color: #7b9cf9; }
.btn-edit:hover { background: rgba(79,110,247,0.28); color: #fff; text-decoration: none; }
.btn-delete { background: rgba(224,82,82,0.12); color: #e05252; margin-left: 0.3rem; }
.btn-delete:hover { background: rgba(224,82,82,0.25); color: #fff; text-decoration: none; }

/* ── Alerts ───────────────────────────────────────────── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    border-left: 3px solid;
}
.alert-error   { background: rgba(224,82,82,0.1);  border-color: var(--danger);  color: #f87171; }
.alert-success { background: rgba(62,207,142,0.1); border-color: var(--success); color: var(--success); }

/* ── Table Grid (index cards) ─────────────────────────── */
.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.table-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem 1.1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all 0.18s;
    color: var(--text);
}
.table-card:hover {
    border-color: var(--accent);
    background: rgba(79,110,247,0.06);
    transform: translateY(-1px);
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(79,110,247,0.15);
}

.table-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(79,110,247,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.table-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.table-card-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-card-rows {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.table-card-arrow { color: var(--text-muted); flex-shrink: 0; }

/* ── Data Table ───────────────────────────────────────── */
.table-scroll {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

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

.data-table thead {
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.data-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(42,45,58,0.6);
    color: var(--text);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--mono);
    font-size: 0.82rem;
}

.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }

.action-col { white-space: nowrap; width: 130px; }

.null-badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: rgba(107,114,128,0.15);
    border-radius: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--mono);
}

/* ── Pagination ───────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.page-btn {
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.875rem;
}
.page-btn:hover { border-color: var(--accent); text-decoration: none; }

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

/* ── Form Card ────────────────────────────────────────── */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 0.45rem;
    font-family: var(--mono);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 0.85rem;
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--mono);
    transition: border-color 0.15s;
    outline: none;
}
.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(79,110,247,0.12);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }
.form-group textarea { resize: vertical; min-height: 90px; }

.input-disabled {
    opacity: 0.45;
    cursor: not-allowed !important;
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: var(--sans);
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-pk   { background: rgba(255,200,50,0.15); color: #f0c040; }
.badge-auto { background: rgba(62,207,142,0.12); color: var(--success); }

.field-type    { font-size: 0.7rem; color: var(--text-muted); font-family: var(--mono); }
.field-nullable{ font-size: 0.7rem; color: #a0aec0; font-style: italic; font-family: var(--sans); }
.field-note    { display: block; margin-top: 0.3rem; font-size: 0.78rem; color: var(--text-muted); font-family: var(--sans); }

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

/* ── Login Page ───────────────────────────────────────── */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-wrap { width: 100%; max-width: 380px; }

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(79,110,247,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    color: var(--accent);
}

.login-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    margin-bottom: 0.35rem;
}

.login-sub {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.login-card .form-group { text-align: left; }

/* ── Utility ──────────────────────────────────────────── */
.mono { font-family: var(--mono); }
.text-muted { color: var(--text-muted); font-size: 0.85rem; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 4rem 2rem;
    color: var(--text-muted);
    text-align: center;
}
.empty-state svg { opacity: 0.35; }
.empty-state p { font-size: 0.95rem; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 640px) {
    .nav-inner { padding: 0 1rem; }
    .container { padding: 1.25rem 1rem; }
    .page-header { flex-direction: column; }
    .form-card { padding: 1.25rem; }
    .table-grid { grid-template-columns: 1fr; }
}
