/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #2563eb;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --error-color: #ef4444;
  --warning-color: #f59e0b;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --border-color: #e2e8f0;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Container Layout */
.container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 300px;
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.sidebar-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  overflow-y: auto;
}

.sidebar-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* Conversation Controls */
.conversation-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.conversations-list {
  max-height: 200px;
  overflow-y: auto;
}

.conversation-item {
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.conversation-item:hover {
  background: var(--bg-secondary);
  transform: translateX(2px);
}

.conversation-item-name {
  font-weight: 500;
  display: block;
}

.conversation-item-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Status Display */
.status-display {
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  padding: 0.75rem;
}

.status-item {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  font-size: 0.875rem;
}

.status-label {
  color: var(--text-secondary);
}

/* Tools List */
.tools-list {
  max-height: 150px;
  overflow-y: auto;
}

.tool-item {
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.tool-name {
  font-weight: 500;
}

.tool-description {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

/* Connection Status */
.connection-status {
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin-top: auto;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--secondary-color);
}

.status-indicator.connected {
  background: var(--success-color);
}

.status-indicator.connecting {
  background: var(--warning-color);
  animation: pulse 2s infinite;
}

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

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 1.5rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* Chat Container */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg-secondary);
}

/* Welcome Message */
.welcome-message {
  text-align: center;
  max-width: 600px;
  margin: 4rem auto;
}

.welcome-message h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.welcome-message p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.quick-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.quick-action {
  padding: 0.75rem 1.5rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-action:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Messages */
.message {
  max-width: 800px;
  margin: 1rem auto;
  display: flex;
  gap: 1rem;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: var(--secondary-color);
}

.message-content {
  flex: 1;
  background: var(--bg-primary);
  padding: 1rem;
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.message.user .message-content {
  background: var(--primary-color);
  color: white;
}

.message-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.message.user .message-meta {
  color: rgba(255, 255, 255, 0.8);
}

/* System Messages */
.system-message {
  max-width: 800px;
  margin: 1rem auto;
  padding: 0.75rem 1rem;
  background: var(--bg-tertiary);
  border-left: 3px solid var(--primary-color);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.system-message.error {
  border-left-color: var(--error-color);
  background: #fef2f2;
  color: #991b1b;
}

.system-message.success {
  border-left-color: var(--success-color);
  background: #f0fdf4;
  color: #166534;
}

/* Approval Container */
.approval-container {
  max-width: 800px;
  margin: 1rem auto;
  padding: 1rem;
  background: #fef3c7;
  border: 2px solid var(--warning-color);
  border-radius: 0.5rem;
  animation: slideIn 0.3s ease-out;
}

.approval-message {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: #92400e;
}

.approval-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.approval-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s;
}

.approval-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Typing Indicator */
.typing-indicator {
  max-width: 800px;
  margin: 0 auto 1rem;
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--secondary-color);
  border-radius: 50%;
  display: inline-block;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
}

/* Input Container */
.input-container {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 1rem;
}

.chat-form {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
}

.message-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  max-height: 150px;
}

.message-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

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

.btn-primary:hover {
  background: #1d4ed8;
}

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

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

.btn-icon {
  padding: 0.5rem;
  background: transparent;
  color: var(--text-secondary);
}

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

.btn-send {
  background: var(--primary-color);
  color: white;
  padding: 0.75rem 1.5rem;
}

.btn-send:hover {
  background: #1d4ed8;
}

.btn-send:disabled {
  background: var(--secondary-color);
  cursor: not-allowed;
}

.icon {
  font-size: 1.125rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 500px;
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-body label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.modal-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 1rem;
}

.modal-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .chat-header h1 {
    font-size: 1.25rem;
  }

  .message {
    margin: 0.75rem 1rem;
  }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--secondary-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Additional Styles for New Features */

/* Button Block */
.btn-block {
  width: 100%;
  justify-content: center;
  margin-bottom: 0.5rem;
}

/* Modal Large */
.modal-large {
  max-width: 700px;
}

/* Aliases List */
.aliases-list {
  max-height: 150px;
  overflow-y: auto;
  margin-top: 0.5rem;
}

.alias-item {
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alias-item-info {
  flex: 1;
}

.alias-item-name {
  font-weight: 500;
  color: var(--primary-color);
}

.alias-item-command {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

.alias-item-actions {
  display: flex;
  gap: 0.25rem;
}

.btn-small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* Alias Form */
.alias-form,
.alias-list {
  margin-bottom: 1.5rem;
}

.alias-form h4,
.alias-list h4 {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

/* Conversation Item with Delete */
.conversation-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conversation-item-info {
  flex: 1;
  cursor: pointer;
}

.conversation-item-delete {
  padding: 0.25rem 0.5rem;
  background: var(--error-color);
  color: white;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.conversation-item-delete:hover {
  opacity: 1;
}

/* Server Item */
.server-item {
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

.server-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.server-name {
  font-weight: 600;
  font-size: 1.125rem;
}

.server-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.server-badge.connected {
  background: var(--success-color);
  color: white;
}

.server-badge.disconnected {
  background: var(--error-color);
  color: white;
}

.server-tools {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Help Content */
.help-content {
  max-height: 500px;
  overflow-y: auto;
}

.help-content h4 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1.125rem;
  color: var(--primary-color);
}

.help-content h4:first-child {
  margin-top: 0;
}

.help-content ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.help-content li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.help-content p {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

/* Delete Confirmation in Conversations */
.conversation-item:hover .conversation-item-delete {
  opacity: 0.9;
}
