/* WebSSH stylesheet */

:root {
  --bg: #0d1117;
  --bg-2: #111827;
  --panel: #161b22;
  --panel-2: #1b2230;
  --border: #242c3b;
  --text: #e6ebf5;
  --muted: #8b98b0;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #f59e0b;
  --radius: 10px;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme='light'] {
  --bg: #f3f5f9;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f4f9;
  --border: #dfe5ee;
  --text: #1a2233;
  --muted: #64748b;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

.mono { font-family: var(--mono); font-size: 12.5px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.empty { text-align: center; padding: 28px 0; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 11px; color: var(--muted);
}
.badge-danger { color: var(--danger); border-color: rgba(239,68,68,.4); background: rgba(239,68,68,.08); }
.badge-ok { color: var(--ok); border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.08); }
.tag {
  display: inline-block; margin: 1px 3px 1px 0; padding: 0 8px;
  border-radius: 20px; background: var(--panel-2); border: 1px solid var(--border);
  font-size: 11px; color: var(--accent);
}

/* Layout */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(1200px 500px at 50% -10%, #16233b 0%, var(--bg) 55%); }
.auth-card {
  width: 380px; max-width: 92vw; padding: 32px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(0,0,0,.35);
  text-align: center;
}
.auth-logo {
  width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  display: grid; place-items: center; font-weight: 800; font-size: 18px; color: #fff; letter-spacing: 1px;
}
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-sub { color: var(--muted); margin: 4px 0 18px; }
.auth-alt { color: var(--muted); margin-top: 16px; font-size: 13px; }

.app-body {
  display: grid;
  grid-template-columns: 210px 1fr;
  grid-template-rows: 52px 1fr;
  grid-template-areas: 'side top' 'side main';
  height: 100vh;
}

.sidebar {
  grid-area: side;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .5px;
}
.brand-name { font-weight: 700; font-size: 15px; }
.nav { flex: 1; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--muted); font-weight: 500; font-size: 13.5px;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(59,130,246,.14); color: var(--accent); }
.nav-item span:first-child { width: 18px; text-align: center; font-size: 12px; }
.sidebar-foot { padding: 12px 16px; color: var(--muted); font-size: 11px; border-top: 1px solid var(--border); }

.topbar {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.topbar-title { font-weight: 600; font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { font-size: 13px; color: var(--muted); }
.user-chip em { font-style: normal; color: var(--accent); font-size: 11px; margin-left: 4px; text-transform: uppercase; }

.content { grid-area: main; overflow: auto; padding: 22px; }

/* Components */
.page { max-width: 1100px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 19px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card-title { margin: 0 0 12px; font-size: 14px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--panel-2); }
.conn-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 8px; }
.key-icon { margin-right: 6px; }
.row-actions { white-space: nowrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; cursor: pointer; background: var(--panel-2); color: var(--text);
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; margin-top: 16px; }

/* Forms */
.input {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-2); color: var(--text); font-size: 13.5px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.input-sm { width: auto; display: inline-block; }
textarea.input { resize: vertical; }
.field-label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.field-label .input { margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.form-grid .field-label:nth-last-child(1):only-child, .form-grid > textarea, .form-grid .full { grid-column: 1 / -1; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5,8,15,.6); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 50;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 520px; max-width: 94vw; max-height: 88vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
}
.modal h3 { margin: 0 0 16px; font-size: 17px; }
.modal-sm { width: 380px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-actions .btn-primary { min-width: 110px; }

/* Alerts / toast */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.35); color: var(--danger); }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; opacity: 0; transition: all .2s; z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-ok { border-color: rgba(34,197,94,.5); }
.toast-error { border-color: rgba(239,68,68,.5); }

/* Terminal page */
.term-wrap { height: 100%; display: flex; flex-direction: column; margin: -22px; }
.term-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.term-spacer { flex: 1; }
.quick-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.term-sessions { display: flex; gap: 4px; padding: 8px 12px 0; background: var(--panel); }
.term-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0;
  background: var(--bg-2); color: var(--muted); font-size: 12.5px; cursor: pointer;
}
.term-tab.active { color: var(--text); border-color: var(--accent); }
.term-tab-close { color: var(--muted); font-size: 10px; padding: 1px 3px; border-radius: 4px; }
.term-tab-close:hover { background: var(--danger); color: #fff; }
.term-box { flex: 1; background: #0d1117; overflow: hidden; padding: 8px 4px 4px 10px; }
.term-instance { height: 100%; }
.term-status {
  padding: 6px 14px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border); background: var(--panel);
}
.term-status.error { color: var(--danger); }

/* SFTP */
.sftp-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.file-name { font-family: var(--mono); font-size: 13px; }
.file-name a { color: var(--text); }
.file-name a:hover { color: var(--accent); }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2a3548; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 820px) {
  .app-body { grid-template-columns: 56px 1fr; }
  .brand-name, .nav-item span:last-child, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
  .page { padding: 0 4px; }
}