/* ============================================================
   DBMS Panel — design tokens
   Palette: deep slate surface, cyan accent, engine-coded badges.
   Type: Space Grotesk (display) / Inter (UI) / JetBrains Mono (data).
   Signature element: colored "engine dot" used everywhere a database
   type appears, so the eye tracks MySQL/Postgres/Mongo/Redis/MSSQL
   content at a glance across every page.
   ============================================================ */


:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --border: #dfe3e8;
    --text: #17191c;
    --text-dim: #68707c;
    --accent: #f58220;
    --accent-dim: #ffd5b0;
    --warn: #c56b00;
    --danger: #cf2e2e;
    --ok: #15803d;

    --mysql: #2677b8;
    --postgres: #336791;
    --mongodb: #168543;
    --redis: #c43b31;
    --mssql: #8a3db8;

    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 8px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); margin: 0 0 .5rem; font-weight: 700; }
code, .mono, td.mono, .data-cell { font-family: var(--font-mono); }

/* Layout shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.25rem 1rem;
    position: relative;
    flex-shrink: 0;
}
.sidebar::before {
    content: '';
    position: absolute; top: 0; right: -1px; width: 1px; height: 100%;
    background: linear-gradient(180deg, transparent, var(--accent-dim), transparent);
    animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sidebar::before { animation: none; } }

.brand { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin-bottom: 1.5rem; display: flex; align-items: center; gap: .5rem; }
.brand-mark { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); transform: rotate(45deg); }

.nav-group { margin-bottom: 1.25rem; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); margin: 0 0 .4rem .5rem; }
.nav-link { display: block; padding: .5rem .6rem; border-radius: var(--radius); color: var(--text-dim); font-size: .88rem; font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--surface-2); color: var(--accent); }

.main { flex: 1; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: .9rem 1.5rem; border-bottom: 1px solid var(--border); background: var(--surface);
}
.breadcrumb { color: var(--text-dim); font-size: .85rem; }
.breadcrumb strong { color: var(--text); }
.content { padding: 1.5rem; max-width: 1200px; }

.user-chip { display: flex; align-items: center; gap: .6rem; font-size: .85rem; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--accent); border: 1px solid var(--border); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.card-title { font-size: .95rem; margin-bottom: 1rem; display: flex; align-items: center; justify-content: space-between; }
.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }

.stat { }
.stat .value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; }
.stat .label { color: var(--text-dim); font-size: .8rem; }

/* Engine badge — the recurring signature element */
.engine-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.engine-badge { display: inline-flex; align-items: center; font-size: .78rem; font-weight: 600; padding: .2rem .55rem; border-radius: 100px; background: var(--surface-2); border: 1px solid var(--border); }
.engine-mysql .engine-dot, .engine-mysql { color: var(--mysql); } .engine-mysql .engine-dot { background: var(--mysql); }
.engine-postgres .engine-dot, .engine-postgres { color: var(--postgres); } .engine-postgres .engine-dot { background: var(--postgres); }
.engine-mongodb .engine-dot, .engine-mongodb { color: var(--mongodb); } .engine-mongodb .engine-dot { background: var(--mongodb); }
.engine-redis .engine-dot, .engine-redis { color: var(--redis); } .engine-redis .engine-dot { background: var(--redis); }
.engine-mssql .engine-dot, .engine-mssql { color: var(--mssql); } .engine-mssql .engine-dot { background: var(--mssql); }

/* Status pill */
.pill { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 600; padding: .2rem .55rem; border-radius: 100px; }
.pill-ok { background: rgba(63,191,127,.12); color: var(--ok); }
.pill-warn { background: rgba(245,166,35,.12); color: var(--warn); }
.pill-danger { background: rgba(229,72,77,.12); color: var(--danger); }
.pill-dim { background: var(--surface-2); color: var(--text-dim); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { text-align: left; color: var(--text-dim); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; padding: .6rem .7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

/* Forms */
label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .3rem; color: var(--text-dim); }
input, select, textarea {
    width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    padding: .55rem .65rem; border-radius: var(--radius); font-family: var(--font-body); font-size: .88rem;
}
textarea.mono, input.mono { font-family: var(--font-mono); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field { margin-bottom: 1rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.help { color: var(--text-dim); font-size: .78rem; margin-top: .3rem; }

button, .btn {
    display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
    background: var(--accent); color: #111111; border: none; font-weight: 600;
    padding: .6rem 1rem; border-radius: var(--radius); font-size: .85rem; font-family: var(--font-body);
}
button:hover, .btn:hover { opacity: .9; }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .35rem .65rem; font-size: .78rem; }

.alert { padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .87rem; border: 1px solid transparent; }
.alert-error { background: #fff1f1; border-color: #f2b8b8; color: #a51d1d; }
.alert-success { background: #ecfdf3; border-color: #a7e2bd; color: #166534; }
.alert-info { background: #fff7ed; border-color: #fed7aa; color: #9a4d08; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-dim); }
.empty-state h3 { color: var(--text); }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 30% 20%, #fff0df 0%, var(--bg) 60%); }
.login-card { width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; }

.progress-bar { height: 8px; background: var(--surface-2); border-radius: 100px; overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--accent); transition: width .3s; }

.text-dim { color: var(--text-dim); }
.flex { display: flex; align-items: center; }
.gap-sm { gap: .5rem; } .gap-md { gap: 1rem; }
.mb-0 { margin-bottom: 0; }


/* Light TCPS form refinements */
.form-card { max-width: 760px; box-shadow: 0 8px 24px rgba(17, 24, 39, .06); }
.form-actions { flex-wrap: wrap; padding-top: .25rem; }
.help-inline { color: var(--text-dim); font-size: .75rem; font-weight: 400; }
.compact-alert { padding: .65rem .8rem; }
input, select, textarea { box-shadow: inset 0 1px 2px rgba(17, 24, 39, .03); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(245,130,32,.25); border-color: var(--accent); }
button, .btn { box-shadow: 0 1px 2px rgba(17, 24, 39, .08); }
button:hover, .btn:hover { opacity: 1; filter: brightness(.97); text-decoration: none; }
.topbar { box-shadow: 0 1px 3px rgba(17,24,39,.04); }
.card { box-shadow: 0 1px 3px rgba(17,24,39,.04); }
@media (max-width: 680px) {
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .sidebar { width: 190px; }
}

/* Engine-specific server form sections */
.engine-fields[hidden], #mongo-fields[hidden], #standard-fields[hidden], #redis-db-field[hidden], #default-db-field[hidden] {
  display: none !important;
}

/* Database server workspace */
.clickable-row { cursor: pointer; }
.clickable-row:focus { outline: 2px solid rgba(245,130,32,.35); outline-offset: -2px; }
.clickable-row:hover td { background: #fff8f1; }
.server-header { display:flex; justify-content:space-between; align-items:center; padding:1rem 1.15rem; }
.server-title-line { margin-bottom:.25rem; }
.server-address { font-size:.8rem; }
.workspace-tabs { display:flex; gap:.25rem; overflow-x:auto; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:.35rem; margin-bottom:1rem; }
.workspace-tabs a, .workspace-tabs span { padding:.55rem .8rem; border-radius:6px; color:var(--text-dim); white-space:nowrap; font-size:.82rem; font-weight:600; }
.workspace-tabs a:hover { background:var(--surface-2); color:var(--text); text-decoration:none; }
.workspace-tabs a.active { background:#fff3e8; color:#b95100; }
.workspace-tabs .disabled { opacity:.45; cursor:not-allowed; }
.workspace-layout { display:grid; grid-template-columns:270px minmax(0,1fr); gap:1rem; align-items:start; }
.db-tree { position:sticky; top:1rem; max-height:calc(100vh - 155px); overflow:auto; padding:.75rem; }
.tree-heading { display:flex; justify-content:space-between; align-items:center; padding:.25rem .35rem .65rem; }
.tree-search { margin-bottom:.55rem; }
.tree-search input { padding:.45rem .55rem; }
.tree-item { display:flex; align-items:center; gap:.55rem; padding:.48rem .55rem; border-radius:6px; color:var(--text-dim); font-size:.82rem; overflow:hidden; }
.tree-item span:last-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tree-item:hover { background:var(--surface-2); color:var(--text); text-decoration:none; }
.tree-item.active { background:#fff3e8; color:#b95100; font-weight:600; }
.tree-icon { font-size:.65rem; color:var(--accent); }
.workspace-main { min-width:0; }
.server-stats .card { margin-bottom:1rem; }
.inline-create-form { display:grid; grid-template-columns:minmax(220px,480px) auto; gap:.6rem; max-width:650px; }
.definition-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0; border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; }
.definition-grid > div { display:flex; justify-content:space-between; gap:1rem; padding:.8rem .9rem; border-bottom:1px solid var(--border); }
.definition-grid > div:nth-child(odd) { border-right:1px solid var(--border); }
.definition-grid > div:nth-last-child(-n+2) { border-bottom:0; }
.definition-grid span { color:var(--text-dim); }
.database-toolbar { display:flex; justify-content:space-between; align-items:center; }
.database-toolbar h2 { margin:.1rem 0; }
.eyebrow { font-size:.7rem; color:var(--text-dim); text-transform:uppercase; letter-spacing:.08em; font-weight:700; }
.card-table { background:var(--surface); }
.table-actions { white-space:nowrap; }
.table-actions .btn + .btn { margin-left:.35rem; }
@media (max-width:900px) {
  .workspace-layout { grid-template-columns:1fr; }
  .db-tree { position:static; max-height:280px; }
  .server-header, .database-toolbar { align-items:flex-start; gap:1rem; flex-direction:column; }
  .definition-grid { grid-template-columns:1fr; }
  .definition-grid > div:nth-child(odd) { border-right:0; }
  .definition-grid > div:nth-last-child(-n+2) { border-bottom:1px solid var(--border); }
  .definition-grid > div:last-child { border-bottom:0; }
}
