/* INDEX */
:root {
  --bg-primary: #0f0f11;
  --bg-secondary: #1a1a1e;
  --bg-tertiary: #232328;
  --border-color: #2a2a30;
  --text-primary: #f0f0f0;
  --text-secondary: #a0a0a8;
  --accent-green: oklch(52.7% 0.154 150.069);
  --accent-red: oklch(50.5% 0.213 27.518);
  --accent-blue: #3b82f6;
  --input-bg: #1e1e24;
  --input-border: #33333a;
  --hover-bg: #2a2a30;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 1000;
}

#brand-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

#brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

#brand i { color: #fff; font-size: 1.25rem; }

#current-host {
    cursor: pointer;
    padding: 0.1rem 0.8rem;
    border-radius: 6px;
    background: #3c3c48;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

#current-host:hover { background: #54545e; }

#current-host-name,
#current-host-flag {
  color: white;
  margin: auto 0;
}

#current-host-address {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: auto 0;
}

#current-host.host-active #current-host-name,
#current-host.host-active #current-host-address {
  font-size: 1rem;
  font-weight: 600;
}

#connection-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  color: white;
}

#connection-toggle.green { background: var(--accent-green); }
#connection-toggle.normal { background: #3c3c48; }
#connection-toggle.waiting { background: oklch(68.1% 0.162 75.834); }
#connection-toggle:hover { background: #54545e; }

#logout-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  color: white;
  background: #3c3c48;
}
#logout-btn:hover { background: #54545e; !important; }

#btn-export-hosts:hover,
#btn-import-hosts:hover {
  background: var(--hover-bg) !important;
  border-color: #444 !important;
}

#terminal-container {
  flex: 1;
  padding: 0.75rem;
  overflow: hidden;
}

#terminal {
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-primary);
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.modal-header {
  border-bottom-color: var(--border-color);
  padding: 1rem 1.25rem;
}

.modal-title {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-body {
  padding: 1rem 1.25rem;
}

.modal-footer {
  border-top-color: var(--border-color);
  padding: 0.75rem 1.25rem;
}

.form-label {
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.form-control, .form-select {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.95rem;
}

.form-control:focus, .form-select:focus {
  background: #25252c;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.2);
  color: var(--text-primary);
}

.auth-toggle {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
  background: var(--input-bg);
  border-radius: 8px;
  padding: 0.25rem;
  width: fit-content;
}

.auth-toggle .form-check-input { display: none; }

.auth-toggle label {
  padding: 0.35rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  margin: 0;
  color: var(--text-secondary);
}

.auth-toggle input:checked + label {
  background: var(--accent-blue);
  color: white;
  font-weight: 500;
}

#private-key-container {
  background: var(--input-bg);
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.5rem;
}

#private-key {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 100px;
  width: 100%;
}

#private-key:focus { outline: none; box-shadow: none; }

#hosts-list { max-height: 450px; overflow-y: auto; }

.host-item {
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
  cursor: pointer;
}

.host-item:hover {
  border-color: var(--accent-blue);
  background: #253755;
}

.host-info {
  flex: 1;
  min-width: 0;
  padding-right: 0.75rem;
}

.host-name {
  font-weight: 900;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1rem;
}

.host-details {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  line-height: 1.4;
}

.host-details span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.host-actions {
  display: flex;
  gap: 0.3rem;
}

.btn-host-action {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
}

.btn-host-edit { background: rgb(107 127 160 / 15%); color: white }
.btn-host-edit:hover { background: rgba(59, 130, 246, 0.25); }

.btn-host-delete { background: rgb(90 7 16); color: oklch(0.88 0.09 17.47); }
.btn-host-delete:hover { background: rgb(110 9 20) }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-secondary);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.25;
}

.empty-state p { margin-bottom: 1rem; }

.btn-primary {
  background: var(--accent-blue);
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.btn-primary:hover { background: #2563eb; }

.btn-outline {
  border-color: var(--input-border);
  color: var(--text-secondary);
  padding: 0.4rem 1rem;
  border-radius: 8px;
  background: transparent;
  font-size: 0.9rem;
}

.btn-outline:hover {
  background: var(--hover-bg);
  border-color: #444;
  color: var(--text-primary);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.drag-handle {
  cursor: grab;
  color: #6c757d;
  display: flex;
  align-items: center;
}
.drag-handle:active { cursor: grabbing; }
.host-item.drag-over { 
  border-top: 2px solid #0d6efd; 
  transition: all 0.2s;
}
.host-item.dragging { 
  opacity: 0.6; 
  transform: scale(1.02); 
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #3a3a42; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a52; }

@media (max-width: 768px) {
  #topbar { flex-direction: column; align-items: stretch; padding: 0.75rem; }
  #brand-section { justify-content: space-between; }
  #current-host { align-items: flex-start; }
}


/* LOGIN */
.login-fullscreen {
  background: linear-gradient(135deg, #00b2a9 0%, #420066 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 1rem;
  width: 100%;
}
.login-card {
  background: rgba(30, 32, 48, 0.95);
  border-radius: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  backdrop-filter: blur(12px);
  border: 1px solid rgba(120, 100, 200, 0.2);
}
.login-brand-icon {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  color: white;
  font-size: 1.8rem;
}
.login-btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  padding: 0.75rem;
  font-weight: 500;
  color: white !important;
}
.login-btn-primary:hover {
  background: linear-gradient(135deg, #8299ff 0%, #9968cb 100%);
}
.login-alert {
  border-radius: 0.75rem;
  font-size: 0.9rem;
  background: rgba(220, 53, 69, 0.15);
  border-color: rgba(220, 53, 69, 0.4);
  color: #ff8a8a;
}
.login-footer-note {
  text-align: center;
  color: rgba(200, 200, 220, 0.7);
  font-size: 0.85rem;
  margin-top: 1.5rem;
}
.login-input-group-text {
  background: #25273a;
  border-color: #3a3d5a;
  color: #a0a3c0;
}
.login-form-control {
  background: #25273a;
  border-color: #3a3d5a;
  color: #e0e2f0;
}
.login-form-control::placeholder {
  color: #ffffff9a;
}
.login-form-control:focus {
  background: #2a2d42;
  border-color: #667eea;
  color: #e0e2f0;
  box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.25);
}
.login-label {
  color: #c0c3e0;
}
@media (max-width: 480px) {
  .login-card { padding: 2rem 1.5rem; }
}