/* Rename dialog */
.rename-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.rename-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  width: 100%;
  max-width: 400px;
  animation: fadeIn 0.2s ease;
}

.rename-dialog h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.rename-dialog input {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.rename-dialog input:focus {
  outline: none;
  border-color: var(--accent);
}

.rename-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Delete confirmation */
.delete-dialog p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Tool Modal */
.tool-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.tool-modal-content {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

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

.tool-modal-header button {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
}

.tool-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.tool-modal-body pre {
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
}

/* Variable Config Modal */
.config-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.config-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.config-modal-content {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.config-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 1rem;
}

.config-app-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.config-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.25rem;
}

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

.config-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.config-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.config-label .required {
  color: #ef4444;
}

.config-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.config-desc a {
  color: var(--accent);
}

.config-input {
  padding: 0.625rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.config-input:focus {
  border-color: var(--accent);
}

.config-input.error {
  border-color: #ef4444;
}

.config-input::placeholder {
  color: var(--text-muted);
}

.config-modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* Profile Modal - Clean Professional Design */
.profile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.profile-modal {
  display: flex;
  width: 100%;
  max-width: 580px;
  height: auto;
  max-height: 520px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  animation: fadeIn 0.2s ease;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

.profile-sidebar {
  width: 130px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.profile-tab {
  padding: 0.625rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.profile-tab:hover {
  color: var(--text-secondary);
}

.profile-tab.active {
  background: var(--bg-hover);
  color: var(--text);
}

.profile-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.profile-header h2 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.close-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
}

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

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

.profile-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.15s ease;
}

/* Account Tab */
.profile-user {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.avatar-lg {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-details h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.125rem;
  letter-spacing: -0.01em;
}

.user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.plan-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.plan-badge {
  padding: 0.125rem 0.5rem;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.reset-text {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.info-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.info-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.info-icon svg {
  width: 16px;
  height: 16px;
}

.info-content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.info-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.info-value {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.upgrade-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.upgrade-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.upgrade-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.upgrade-desc {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.logout-btn {
  width: 100%;
  margin-top: 1.25rem;
  color: var(--text-muted);
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
}

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

.logout-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

/* General Tab - Settings */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

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

.setting-item.column {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
}

.setting-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.8125rem;
  color: var(--text);
}

.setting-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.setting-icon svg {
  width: 16px;
  height: 16px;
}

.setting-text {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.setting-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.setting-select {
  padding: 0.375rem 0.625rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.75rem;
  cursor: pointer;
  min-width: 100px;
}

.setting-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Toggle */
.toggle {
  position: relative;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s;
  position: relative;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.2s;
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
  background: white;
}

/* Keywords */
.keywords-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.chip-remove:hover {
  color: #ef4444;
}

.chip-remove svg {
  width: 12px;
  height: 12px;
}

.keyword-add {
  display: flex;
  gap: 0.5rem;
}

.keyword-input {
  flex: 1;
  padding: 0.375rem 0.625rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.75rem;
}

.keyword-input:focus {
  outline: none;
  border-color: var(--accent);
}

.keyword-input::placeholder {
  color: var(--text-muted);
}

/* Agents Tab */
.empty-agents {
  text-align: center;
  padding: 2rem 1rem;
}

.empty-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.empty-icon svg {
  width: 20px;
  height: 20px;
}

.empty-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.empty-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 240px;
  margin: 0 auto;
  line-height: 1.5;
}

#add-agents-btn {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

#add-agents-btn svg {
  width: 14px;
  height: 14px;
}

/* Responsive */
@media (max-width: 540px) {
  .profile-modal {
    flex-direction: column;
    height: 85vh;
    max-height: none;
  }
  
  .profile-sidebar {
    width: 100%;
    flex-direction: row;
    padding: 0.5rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .profile-tab {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    padding: 0.5rem;
  }
  
  .setting-item:not(.column) {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .setting-select {
    width: 100%;
  }
  
  .upgrade-card {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }
  
  .upgrade-text {
    align-items: center;
  }
}


