/* TODO: Move to tailwind */

.installed-servers-container {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 1240px) {
  .installed-servers-container {
    padding: 1rem 2rem;
  }
}

.installed-servers-header {
  margin-bottom: 30px;
}

.installed-servers-header h2 {
  margin-bottom: 10px;
  font-size: 1.8rem;
  color: #333;
}

.installed-servers-header p {
  color: #666;
  margin-bottom: 20px;
}

.loading-message {
  margin: 2rem 0;
  text-align: center;
  color: #6c757d;
}

.empty-state {
  margin: 3rem 0;
  text-align: center;
  padding: 2rem;
  background-color: #f8f9fa;
  border-radius: 8px;
  border: 1px dashed #dee2e6;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
  width: 100%;
}

.tool-card {
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  width: 100%;
  box-sizing: border-box;
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.tool-card.expanded {
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
  z-index: 10;
}

.tool-card.enabled {
  background-color: white;
  border: 1px solid #e9ecef;
}

.tool-card.disabled {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  opacity: 0.7;
}

.tool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.tool-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.tool-title {
  cursor: pointer;
  transition: color 0.2s;
}

.tool-title:hover {
  color: #0d6efd;
  text-decoration: underline;
}

.tool-status {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 28px;
}

.app-status-indicator {
  display: inline-block;
  width: 48px;
  height: 24px;
  border-radius: 12px;
  position: relative;
  transition: background-color 0.3s;
  cursor: pointer;
  vertical-align: middle;
  margin-top: 0;
  margin-bottom: 0;
}

.app-status-indicator.active {
  background-color: #34c759;
}

.app-status-indicator.inactive {
  background-color: #8e8e93;
}

.app-status-indicator::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s;
}

.app-status-indicator.active::after {
  transform: translateX(24px);
}

.tool-description {
  margin-bottom: 1.5rem;
  color: #6c757d;
  font-size: 0.9rem;
}

.tool-actions {
  display: flex;
  justify-content: center;
}

.uninstall-button {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  background-color: white;
  border: 1px solid #dee2e6;
  color: #dc3545;
  transition: all 0.2s;
}

.uninstall-button:hover {
  background-color: #fff8f8;
  border-color: #dc3545;
}

/* Server status indicator */
.server-status-indicator {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background-color: #f8f9fa;
  border-radius: 4px;
  font-size: 0.85rem;
  flex-wrap: wrap;
  cursor: pointer;
  transition: background-color 0.2s;
  justify-content: space-between;
}

.server-status-indicator:hover {
  background-color: #e9ecef;
}

.server-status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

.server-status-dot.running {
  background-color: #10b981;
}

.server-status-dot.stopped {
  background-color: #ef4444;
}

.server-status-dot.starting {
  background-color: #f59e0b; /* Amber/yellow color for starting state */
  position: relative;
  overflow: hidden;
}

.server-status-dot.error {
  background-color: #dc2626; /* Red color for error state */
}

.server-status-dot.transitioning {
  background-color: #9ca3af; /* Gray color for transitioning state */
  position: relative;
  overflow: hidden;
}

.server-status-dot.starting::after,
.server-status-dot.transitioning::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.server-status-text {
  color: #6c757d;
}

/* Expand indicator */
.expand-indicator {
  color: #000;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s;
  margin-left: auto;
}

.expand-indicator:hover {
  background-color: rgba(13, 110, 253, 0.1);
}

/* Tool details modal */
.tool-details-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.tool-details-modal {
  background-color: white;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.tool-details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid #e9ecef;
}

.tool-details-header h3 {
  margin: 0;
  font-size: 1.5rem;
}

.close-button {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6c757d;
}

.tool-details-content {
  padding: 1.5rem;
}

.server-details {
  margin-top: 1.5rem;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.server-details h4 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.server-name,
.server-status,
.tool-count {
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

.server-status .running {
  color: #10b981;
  font-weight: 600;
}

.server-status .stopped {
  color: #ef4444;
  font-weight: 600;
}

.discover-button {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background-color: #10b981;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  width: 100%;
}

.discover-button:hover {
  background-color: #059669;
}

.discover-button:disabled {
  background-color: #d1d5db;
  cursor: not-allowed;
}

.server-tools-list {
  margin-top: 1.5rem;
}

.server-tools-list h4 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.server-tools-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.server-tool-item {
  padding: 0.75rem;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  flex-direction: column;
}

.server-tool-item:last-child {
  border-bottom: none;
}

.server-tool-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.server-tool-description {
  font-size: 0.85rem;
  color: #6c757d;
}

.empty-tools-message {
  margin: 1rem 0;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 6px;
  border: 1px dashed #e9ecef;
  text-align: center;
  color: #6c757d;
  font-size: 0.9rem;
}

.tool-details-actions {
  padding: 1.5rem;
  border-top: 1px solid #e9ecef;
  display: flex;
  justify-content: center;
}

/* Configuration Button */
.config-button {
  background-color: #6c757d;
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  margin-right: 8px;
  padding: 0;
  flex-shrink: 0;
  transition: background-color 0.2s;
}

.config-button:hover {
  background-color: #5a6268;
}

.config-button svg {
  width: 14px;
  height: 14px;
}

/* Configuration Popup */
.config-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.config-popup {
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.config-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
}

.config-popup-header h3 {
  margin: 0;
  font-size: 18px;
  color: #343a40;
}

.close-popup-button {
  background: none;
  border: none;
  font-size: 24px;
  color: #6c757d;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.close-popup-button:hover {
  color: #343a40;
}

.config-popup-content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.config-popup-actions {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid #e9ecef;
  gap: 10px;
}

/* Ensure the env-vars-editor works in the popup */
.config-popup .env-vars-editor {
  display: grid;
  gap: 15px;
}

.config-popup .env-var-input-group {
  display: grid;
  gap: 5px;
}

.config-popup .env-var-input-group label {
  font-weight: bold;
  color: #495057;
}

.config-popup .env-var-input-group input {
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-family: monospace;
}

.config-popup .env-var-description {
  margin-top: 5px;
  font-size: 12px;
  color: #6c757d;
  font-style: italic;
}

/* Animation for popup */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Installed Apps Section */
.installed-apps-section {
  margin-bottom: 3rem;
}

.installed-apps-section h3 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: #333;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 0.5rem;
}

/* Servers Section */
.servers-section {
  margin-bottom: 3rem;
}

.servers-section h3 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: #333;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 0.5rem;
}

.servers-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.server-container {
  background-color: white;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.server-header {
  display: flex;
  align-items: center;
  padding: 1.25rem;
  background-color: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.server-status-badge {
  margin-right: 1rem;
}

.server-status-badge .running {
  background-color: #10b981;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.server-status-badge .stopped {
  background-color: #ef4444;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.server-tools {
  margin-top: 1rem;
  border-top: 1px solid #e9ecef;
  padding-top: 1rem;
}

.server-tools h5 {
  margin-top: 1rem;
  margin-bottom: 1rem;
  font-size: 1rem;
  color: #4b5563;
  text-align: left;
}

.server-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
  width: 100%;
}

.server-tool-card {
  background-color: #f8f9fa;
  border-radius: 6px;
  padding: 0.75rem;
  border: 1px solid #e9ecef;
  height: 100%;
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
}

.server-tool-card h6 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: #111827;
}

.server-tool-card p {
  margin: 0;
  font-size: 0.85rem;
  color: #6b7280;
  flex-grow: 1;
}

/* Server info container inside tool card */
.server-info-container {
  margin-top: 1rem;
  margin-bottom: 1rem;
  border-top: 1px solid #e9ecef;
  padding: 1rem 0.5rem;
  width: auto;
  background-color: #f8f9fa;
  border-radius: 6px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
  animation: fadeIn 0.3s ease-in-out;
}

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

.server-info-container .server-header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

/* Loading indicator styles for updating servers */
.updating-servers-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 1rem;
  font-size: 0.875rem;
  color: #6b7280;
}

.updating-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid #e5e7eb;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Color tag styles - enhanced for visual appeal */
.color-tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.color-tag {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.875rem;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.color-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.color-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.server-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.add-color-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background-color: #f3f4f6;
  border: 1px dashed #d1d5db;
  cursor: pointer;
  transition: all 0.2s;
}

.add-color-button:hover {
  background-color: #e5e7eb;
}

.server-info-container .server-header {
  padding: 0;
  background-color: transparent;
  border-bottom: none;
  flex-wrap: wrap;
  gap: 10px;
}

.server-info-container .server-header h4 {
  margin: 0;
  font-size: 1.1rem;
  flex: 1;
  color: #4b5563;
}

.server-status-badge {
  display: flex;
  align-items: center;
  margin-right: 10px;
}

.server-status-badge .running {
  background-color: #10b981;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-block;
}

.server-status-badge .stopped {
  background-color: #ef4444;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-block;
}

.server-status-badge .starting {
  background-color: #f59e0b;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-block;
}

.server-status-badge .error {
  background-color: #dc2626;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-block;
}

/* Adjust the discover button for the server header */
.server-header .discover-button {
  margin-top: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  min-width: 110px;
  background-color: #10b981;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.server-header .discover-button:hover {
  background-color: #059669;
}

.server-header .discover-button:active {
  background-color: #047857;
  transform: translateY(1px);
}

/* Empty state for servers */
.servers-section .empty-state {
  margin: 1.5rem 0;
}

/* Empty tools message in server container */
.server-container .empty-tools-message {
  margin: 0;
  padding: 1.25rem;
  border: none;
  border-radius: 0;
  background-color: transparent;
}

/* Environment Variables Styles */
.env-vars-container {
  margin-top: 20px;
  padding: 15px;
  background-color: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.env-vars-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.env-vars-header h4 {
  margin: 0;
  font-size: 16px;
  color: #343a40;
}

.edit-env-vars-button {
  padding: 6px 12px;
  background-color: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.edit-env-vars-button:hover {
  background-color: #5a6268;
}

.env-vars-display {
  display: grid;
  gap: 10px;
}

.env-var-item {
  padding: 10px;
  background-color: white;
  border-radius: 4px;
  border: 1px solid #dee2e6;
}

.env-var-key {
  font-weight: bold;
  color: #495057;
  margin-bottom: 5px;
}

.env-var-value {
  font-family: monospace;
  padding: 5px;
  background-color: #f1f3f5;
  border-radius: 4px;
  word-break: break-all;
}

.env-var-description {
  margin-top: 5px;
  font-size: 12px;
  color: #6c757d;
  font-style: italic;
}

.env-vars-editor {
  display: grid;
  gap: 15px;
}

.env-var-input-group {
  display: grid;
  gap: 5px;
}

.env-var-input-group label {
  font-weight: bold;
  color: #495057;
}

.env-var-input-group input {
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-family: monospace;
}

.env-vars-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  justify-content: flex-end;
}

.save-env-vars-button {
  padding: 8px 16px;
  background-color: #0d6efd;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.save-env-vars-button:hover:not(:disabled) {
  background-color: #0b5ed7;
}

.cancel-env-vars-button {
  padding: 8px 16px;
  background-color: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.cancel-env-vars-button:hover:not(:disabled) {
  background-color: #5a6268;
}

.save-env-vars-button:disabled,
.cancel-env-vars-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Notification styles */
.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.notification {
  padding: 12px 16px;
  margin-bottom: 10px;
  border-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 300px;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.notification.success {
  background-color: #4caf50;
  color: white;
}

.notification.error {
  background-color: #f44336;
  color: white;
}

.notification.info {
  background-color: #2196f3;
  color: white;
}

.notification .close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  margin-left: 10px;
}
