:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: #30363d;
  --border-color: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-primary: #58a6ff;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-yellow: #d29922;
  --accent-orange: #db6d28;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-primary);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.status-disconnected {
  background-color: var(--text-muted);
  animation: none;
}

.status-connecting {
  background-color: var(--accent-yellow);
}

.status-connected {
  background-color: var(--accent-green);
  animation: none;
}

.status-error {
  background-color: var(--accent-red);
  animation: none;
}

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

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 320px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-normal);
}

.sidebar.collapsed {
  width: 0;
  border-right: none;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.btn-toggle:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.btn-toggle svg {
  width: 18px;
  height: 18px;
}

.sidebar.collapsed .btn-toggle {
  transform: rotate(180deg);
}

.connection-form {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.required {
  color: var(--accent-red);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group textarea {
  resize: vertical;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.password-input-wrapper {
  position: relative;
}

.password-input-wrapper input {
  padding-right: 40px;
}

.btn-toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.btn-toggle-password:hover {
  color: var(--text-primary);
}

.btn-toggle-password svg {
  width: 18px;
  height: 18px;
}

.hidden {
  display: none !important;
}

.error-message {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--accent-red);
  min-height: 1rem;
}

.checkbox-group {
  margin-bottom: 20px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  position: relative;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.form-actions {
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex: 1;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background-color: var(--accent-green);
  color: white;
}

.btn-primary:hover {
  background-color: #2ea043;
}

.btn-primary:disabled {
  background-color: var(--bg-hover);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-danger {
  background-color: var(--accent-red);
  color: white;
}

.btn-danger:hover {
  background-color: #da3633;
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

.saved-servers {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  max-height: 200px;
  overflow-y: auto;
}

.saved-servers h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.server-list {
  list-style: none;
}

.server-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.server-item:hover {
  background-color: var(--bg-hover);
}

.server-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.server-item-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.server-item-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.server-item-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.server-item-delete:hover {
  background-color: rgba(248, 81, 73, 0.2);
  color: var(--accent-red);
}

.server-item-delete svg {
  width: 14px;
  height: 14px;
}

.terminal-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.terminal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.terminal-tabs {
  display: flex;
  gap: 4px;
}

.terminal-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.terminal-tab.active {
  background-color: var(--accent-primary);
  color: white;
}

.terminal-tab svg {
  width: 14px;
  height: 14px;
}

.terminal-actions {
  display: flex;
  gap: 4px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.terminal-container {
  flex: 1;
  background-color: var(--bg-primary);
  padding: 8px;
  overflow: hidden;
  position: relative;
}

.terminal-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
}

.terminal-placeholder svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.terminal-placeholder p {
  font-size: 0.875rem;
}

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

#terminal.hidden {
  display: none;
}

.terminal-placeholder.hidden {
  display: none;
}

.notification {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: transform var(--transition-normal);
}

.notification.show {
  transform: translateX(-50%) translateY(0);
}

.notification.success {
  border-color: var(--accent-green);
}

.notification.error {
  border-color: var(--accent-red);
}

.notification.warning {
  border-color: var(--accent-yellow);
}

.notification-message {
  font-size: 0.875rem;
  color: var(--text-primary);
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.modal-content p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions .btn {
  flex: none;
  min-width: 80px;
}

.terminal-section.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 999;
}

.terminal-section.fullscreen .terminal-container {
  padding: 0;
}

.terminal-section.fullscreen .terminal-toolbar {
  background-color: var(--bg-primary);
}

@media (max-width: 768px) {
  .header {
    padding: 10px 16px;
  }

  .logo {
    font-size: 1rem;
  }

  .logo-icon {
    width: 24px;
    height: 24px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 53px;
    bottom: 0;
    z-index: 100;
    width: 100%;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }

  .sidebar:not(.collapsed) {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: 100%;
    max-width: 320px;
    transform: translateX(-100%);
  }

  .main-content {
    flex-direction: column;
  }

  .terminal-section {
    width: 100%;
  }

  .connection-status {
    font-size: 0.75rem;
    padding: 4px 8px;
  }

  .form-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 8px 12px;
  }

  .logo {
    font-size: 0.875rem;
  }

  .connection-form {
    padding: 12px;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .saved-servers {
    padding: 12px;
  }
}

.xterm {
  padding: 8px;
}

.xterm-viewport::-webkit-scrollbar {
  width: 8px;
}

.xterm-viewport::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

.xterm-viewport::-webkit-scrollbar-thumb {
  background-color: var(--bg-hover);
  border-radius: 4px;
}

.xterm-viewport::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-muted);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn.loading svg {
  animation: spin 1s linear infinite;
}

.input-error {
  border-color: var(--accent-red) !important;
}

.input-error:focus {
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.15) !important;
}
