/* AI Assistant Styles - Luxury Redesign */
/* Elegant, minimal design with emerald/gold theme */

.ai-assistant-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  background: var(--primary-color);
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(46, 139, 87, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  transition: all 0.3s ease, opacity 0.3s ease;
  z-index: 999;
}

.ai-assistant-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(46, 139, 87, 0.35);
  background: var(--secondary-color);
}

.ai-assistant-toggle.active {
  background: var(--secondary-color);
}

.ai-assistant-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 420px;
  min-width: 320px;
  max-width: 90vw;
  height: 720px;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 16px 16px 0 0;
  box-shadow: -4px 0 24px rgba(10, 29, 31, 0.12);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 998;
  display: flex;
  flex-direction: column;
}

/* Minimized state - collapses to thin line */
.ai-assistant-panel.minimized {
  height: 50px;
  cursor: pointer;
  overflow: hidden;
}

.ai-assistant-panel.minimized .ai-assistant-tabs,
.ai-assistant-panel.minimized .ai-assistant-content,
.ai-assistant-panel.minimized .ai-resize-handle {
  display: none;
}

.ai-assistant-panel.minimized .ai-assistant-header {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark, #5a67d8));
  color: white;
  cursor: pointer;
  border-radius: 16px 16px 0 0;
}

.ai-assistant-panel.minimized .ai-assistant-title {
  color: white;
  font-weight: 600;
}

.ai-assistant-panel.minimized .ai-minimize-btn,
.ai-assistant-panel.minimized .ai-close-btn {
  color: white;
  background: rgba(255, 255, 255, 0.15);
}

.ai-assistant-panel.minimized .ai-minimize-btn:hover,
.ai-assistant-panel.minimized .ai-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.ai-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 100%;
  cursor: ew-resize;
  background: transparent;
  z-index: 999;
  transition: background 0.2s;
}

.ai-resize-handle:hover,
.ai-resize-handle.resizing {
  background: linear-gradient(90deg, var(--primary-color) 0%, transparent 100%);
}

.ai-resize-handle::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 40px;
  background: var(--border-color);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.2s;
}

.ai-resize-handle:hover::before,
.ai-resize-handle.resizing::before {
  opacity: 1;
}

.ai-assistant-panel.open {
  transform: translateY(0);
}

/* Slim, elegant header */
.ai-assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  border-radius: 16px 16px 0 0;
}

.ai-assistant-title {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dark);
}

.ai-assistant-title i {
  color: var(--primary-color);
  font-size: 1.125rem;
}

.ai-header-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ai-minimize-btn,
.ai-close-btn {
  background: transparent;
  border: none;
  color: var(--text-light);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 1rem;
}

.ai-close-btn {
  font-size: 1.25rem;
}

.ai-minimize-btn:hover,
.ai-close-btn:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

/* Slim tabs with more spacing */
.ai-assistant-tabs {
  display: flex;
  background: var(--white);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1rem;
  gap: 0.5rem;
}

.ai-tab {
  flex: 1;
  padding: 0.625rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-light);
  transition: all 0.2s;
  letter-spacing: -0.01em;
}

.ai-tab:hover {
  color: var(--text-dark);
}

.ai-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* More whitespace in content area */
.ai-assistant-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.75rem 1.5rem;
  background: var(--white);
}

.ai-tab-content {
  display: none;
}

.ai-tab-content.active {
  display: block;
}

/* Slim command buttons with more spacing */
.ai-command-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem;
  margin-bottom: 2rem;
}

.ai-command-btn {
  padding: 0.625rem 0.875rem;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-dark);
  transition: all 0.2s;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.ai-command-btn:hover {
  background: var(--bg-light);
  border-color: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(46, 139, 87, 0.08);
}

.ai-command-btn i {
  font-size: 1.125rem;
  color: var(--primary-color);
}

/* Cleaner input areas */
.ai-input-area {
  margin-top: 1.5rem;
}

.ai-input-area label {
  display: block;
  margin-bottom: 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}

.ai-input-area textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
  transition: all 0.2s;
  background: var(--white);
}

.ai-input-area textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.08);
}

/* Slim, elegant process button */
.ai-process-btn {
  width: 100%;
  padding: 0.75rem 1.5rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1.25rem;
  transition: all 0.2s;
  letter-spacing: -0.01em;
}

.ai-process-btn:hover:not(:disabled) {
  background: var(--secondary-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(46, 139, 87, 0.2);
}

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

/* Cleaner result area */
.ai-result-area {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  display: none;
}

.ai-result-area.visible {
  display: block;
}

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

.ai-result-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}

.ai-copy-btn {
  padding: 0.375rem 0.75rem;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--text-dark);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.ai-copy-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.ai-save-btn {
  padding: 0.375rem 0.75rem;
  background: var(--primary-color);
  border: 1px solid var(--primary-color);
  border-radius: 6px;
  font-size: 0.75rem;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  display: none; /* Hidden by default, shown after generation */
  align-items: center;
  gap: 0.375rem;
}

.ai-save-btn:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.ai-save-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.ai-view-btn {
  padding: 0.375rem 0.75rem;
  background: var(--success-color);
  border: 1px solid var(--success-color);
  border-radius: 6px;
  font-size: 0.75rem;
  color: white;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.ai-view-btn:hover {
  background: #059669;
  border-color: #059669;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.ai-result-text {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-dark);
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Minimal chat design */
.ai-chat-messages {
  min-height: 320px;
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 1.5rem;
  padding: 0.5rem 0;
}

.ai-message {
  margin-bottom: 1.25rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

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

.ai-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

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

.ai-message-bubble {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--bg-light);
  max-width: 75%;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-dark);
}

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

/* Slim chat input */
.ai-chat-input-wrapper {
  display: flex;
  gap: 0.625rem;
  padding: 1rem 1.5rem;
  background: var(--white);
  border-top: 1px solid var(--border-color);
}

.ai-chat-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--white);
  transition: all 0.2s;
}

.ai-chat-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.08);
}

.ai-chat-send-btn {
  padding: 0.75rem 1.25rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
  letter-spacing: -0.01em;
}

.ai-chat-send-btn:hover:not(:disabled) {
  background: var(--secondary-color);
  transform: translateY(-1px);
}

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

/* Generate form - slim design */
.ai-form-group {
  margin-bottom: 1.25rem;
}

.ai-form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}

.ai-form-group input,
.ai-form-group select,
.ai-form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--white);
  transition: all 0.2s;
}

.ai-form-group input:focus,
.ai-form-group select:focus,
.ai-form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.08);
}

/* Loading Spinner */
.ai-loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Dark Mode */
[data-theme="dark"] .ai-assistant-panel {
  background: var(--bg-primary);
  border-color: var(--border-color);
}

[data-theme="dark"] .ai-assistant-header {
  background: var(--bg-primary);
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .ai-assistant-content {
  background: var(--bg-primary);
}

[data-theme="dark"] .ai-assistant-tabs {
  background: var(--bg-primary);
}

[data-theme="dark"] .ai-command-btn {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}

[data-theme="dark"] .ai-input-area textarea,
[data-theme="dark"] .ai-chat-input,
[data-theme="dark"] .ai-form-group input,
[data-theme="dark"] .ai-form-group select,
[data-theme="dark"] .ai-form-group textarea {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}

[data-theme="dark"] .ai-result-area {
  background: var(--surface);
  border-color: var(--border-color);
}

[data-theme="dark"] .ai-message-bubble {
  background: var(--surface);
  color: var(--text-primary);
}

[data-theme="dark"] .ai-message.user .ai-message-bubble {
  background: var(--primary-color);
  color: white;
}

[data-theme="dark"] .ai-chat-input-wrapper {
  background: var(--bg-primary);
  border-top-color: var(--border-color);
}

[data-theme="dark"] .ai-copy-btn {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-color);
}

[data-theme="dark"] .ai-copy-btn:hover {
  background: var(--primary-color);
  color: white;
}

/* AI Suggestions Dropdown */
.ai-input-wrapper {
  position: relative;
  width: 100%;
}

/* Tags Input for Keywords */
.ai-tags-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: white;
  min-height: 42px;
  cursor: text;
}

.ai-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ai-keyword-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-color-dark, #5a67d8));
  color: white;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  animation: tagSlideIn 0.2s ease;
}

@keyframes tagSlideIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.ai-keyword-tag-remove {
  cursor: pointer;
  font-weight: bold;
  opacity: 0.8;
  transition: opacity 0.2s;
  font-size: 1rem;
  line-height: 1;
}

.ai-keyword-tag-remove:hover {
  opacity: 1;
}

.ai-tags-input input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.25rem;
  min-width: 150px;
  font-size: 0.9375rem;
}

.ai-tags-input input::placeholder {
  color: var(--text-secondary);
}

.ai-suggestions-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  margin-top: 4px;
}

.ai-suggestions-dropdown.visible {
  display: block;
}

.ai-suggestions-dropdown.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.ai-suggestion-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9375rem;
  color: var(--text-primary);
}

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

.ai-suggestion-item:hover {
  background: var(--primary-color-light, #f0f4ff);
}

.ai-suggestion-item i {
  margin-right: 0.5rem;
  color: var(--primary-color);
  font-size: 0.875rem;
}

[data-theme="dark"] .ai-suggestions-dropdown {
  background: var(--surface);
  border-color: var(--border-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ai-suggestion-item {
  color: var(--text-primary);
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .ai-suggestion-item:hover {
  background: var(--primary-color-dark, #1e3a8a);
}

/* Responsive */
@media (max-width: 768px) {
  .ai-assistant-panel {
    width: 100%;
    height: 75vh;
  }

  .ai-command-grid {
    grid-template-columns: 1fr;
  }

  .ai-assistant-toggle {
    bottom: 1rem;
    right: 1rem;
    width: 50px;
    height: 50px;
    font-size: 1.25rem;
  }
}
