@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #080810;
  --surface: #0f0f1a;
  --surface-2: #161628;
  --surface-3: #1c1c35;
  --border: #1e1e3a;
  --border-2: #2a2a4a;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.18s ease;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #4f52d9; box-shadow: 0 0 20px var(--accent-glow); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ─── INPUTS ─── */
.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input::placeholder { color: var(--text-muted); }

textarea.input { resize: vertical; min-height: 80px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }

/* ─── PASSWORD FIELD ─── */
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 40px; }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: var(--transition);
}
.password-toggle:hover { color: var(--text); }

/* ─── LOGIN PAGE ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(129,140,248,0.05) 0%, transparent 50%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}

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

.login-logo .logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-radius: 14px;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(99,102,241,0.3);
}

.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.login-form { display: flex; flex-direction: column; gap: 16px; }

.login-error {
  padding: 10px 14px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 13px;
  display: none;
}
.login-error.show { display: block; }

.login-btn {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  justify-content: center;
  margin-top: 4px;
  border-radius: var(--radius-sm);
}

/* ─── DASHBOARD ─── */
.dashboard-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.topbar-brand .brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.topbar-brand span {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

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

.server-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-dim);
}

.server-badge .dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.dashboard-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.dashboard-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.dashboard-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
.project-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  opacity: 0;
  transition: var(--transition);
}
.project-card:hover {
  border-color: var(--border-2);
  background: var(--surface-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.project-card:hover::before { opacity: 1; }

.card-top { display: flex; align-items: flex-start; gap: 14px; }

.project-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.card-meta { flex: 1; min-width: 0; }
.card-meta h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta .description {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta .modified {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.card-url {
  flex: 1;
  font-size: 11px;
  color: var(--accent-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.card-url:hover { text-decoration: underline; }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px;
  color: var(--text-muted);
  gap: 12px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── PROJECT (TERMINAL) PAGE ─── */
.project-layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.project-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.project-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.project-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.terminal-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #0a0a0f;
}

#terminal-container {
  width: 100%;
  height: 100%;
}

.xterm { height: 100% !important; }
.xterm-viewport { overflow-y: auto !important; }

/* Connection status */
.conn-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.conn-status .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.conn-status.connected { color: var(--success); border-color: rgba(34,197,94,0.2); }
.conn-status.connected .dot { background: var(--success); animation: pulse 2s infinite; }
.conn-status.disconnected { color: var(--error); border-color: rgba(239,68,68,0.2); }
.conn-status.disconnected .dot { background: var(--error); }
.conn-status.connecting .dot { background: var(--warning); animation: pulse 1s infinite; }
.conn-status.connecting { color: var(--warning); }

/* ─── INFO PANEL ─── */
.info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.info-overlay.open { opacity: 1; pointer-events: all; }

.info-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -24px 0 60px rgba(0,0,0,0.4);
}
.info-panel.open { transform: translateX(0); }

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

.info-panel-header h3 { font-size: 15px; font-weight: 600; }

.info-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: -8px;
}

.custom-fields { display: flex; flex-direction: column; gap: 10px; }

.custom-field-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.custom-field-row .input-key { width: 120px; flex-shrink: 0; }
.custom-field-row .input-val { flex: 1; }

.add-field-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
}
.add-field-btn:hover { border-color: var(--accent); color: var(--accent); }

.info-panel-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.info-panel-footer .btn { flex: 1; justify-content: center; }

.save-indicator {
  font-size: 12px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.3s;
}
.save-indicator.show { opacity: 1; }

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

.toast {
  padding: 12px 16px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: slideIn 0.2s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── ICON COLORS ─── */
.ic-0 { background: linear-gradient(135deg, #6366f1, #818cf8); }
.ic-1 { background: linear-gradient(135deg, #ec4899, #f472b6); }
.ic-2 { background: linear-gradient(135deg, #14b8a6, #2dd4bf); }
.ic-3 { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.ic-4 { background: linear-gradient(135deg, #ef4444, #f87171); }
.ic-5 { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.ic-6 { background: linear-gradient(135deg, #22c55e, #4ade80); }
.ic-7 { background: linear-gradient(135deg, #06b6d4, #22d3ee); }
