/**
 * Clippy Walkthrough Panel Styles
 * Provides styling for the AI-guided walkthrough feature.
 * Uses theme-system CSS variables for light/dark mode support.
 *
 * Requirements: 1.1 (visible trigger), 1.3 (loading indicator, accessible panel)
 */

/* ===== ROOT CONTAINER ===== */
.clippy-root {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 10050;
  font-family: inherit;
}

/* ===== TRIGGER BUTTON ===== */
.clippy-trigger-btn {
  width: auto;
  height: 44px;
  padding: 0 14px 0 12px;
  border-radius: 22px;
  border: none;
  background: var(--primary-gradient);
  color: var(--theme-text-inverse, #ffffff);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--theme-shadow-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.clippy-trigger-btn__icon {
  font-size: 1.15rem;
  line-height: 1;
}

.clippy-trigger-btn__label {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.clippy-trigger-btn:hover {
  transform: scale(1.08);
  box-shadow: var(--theme-shadow-lg);
}

.clippy-trigger-btn:focus-visible {
  outline: 2px solid var(--theme-border-focus, var(--brand-teal));
  outline-offset: 3px;
}

/* ===== PANEL ===== */
.clippy-panel {
  position: absolute;
  bottom: 60px;
  left: 0;
  width: 360px;
  max-height: 520px;
  background-color: var(--theme-bg-primary, #ffffff);
  border: 1px solid var(--theme-border-medium, #dee2e6);
  border-radius: 10px;
  box-shadow: var(--theme-shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.97);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.clippy-panel--open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ===== PANEL HEADER ===== */
.clippy-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--primary-gradient);
  color: var(--theme-text-inverse, #ffffff);
  flex-shrink: 0;
}

.clippy-panel__title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.clippy-panel__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--theme-text-inverse, #ffffff);
}

.clippy-panel__subtitle {
  font-size: 0.6875rem;
  opacity: 0.8;
  font-weight: 400;
}

.clippy-panel__close-btn {
  background: none;
  border: none;
  color: var(--theme-text-inverse, #ffffff);
  font-size: 1.15rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.15s ease;
}

.clippy-panel__close-btn:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.clippy-panel__close-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

/* ===== CONTENT AREA ===== */
.clippy-panel__content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--theme-text-primary, #333333);
}

/* ===== VALIDATION MESSAGE ===== */
.clippy-panel__validation {
  padding: 8px 16px;
  font-size: 0.8125rem;
  color: var(--danger, #dc3545);
  background-color: var(--theme-alert-danger-bg, #f8d7da);
  border-top: 1px solid var(--danger-border, #f5c6cb);
}

/* ===== LOADING INDICATOR ===== */
.clippy-panel__loading {
  padding: 16px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--theme-text-secondary, #555555);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.clippy-panel__loading::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid var(--theme-border-light, #e0e0e0);
  border-top-color: var(--brand-teal, #1f5f7a);
  border-radius: 50%;
  animation: clippy-spin 0.8s linear infinite;
}

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

/* ===== INPUT AREA ===== */
.clippy-panel__input-area {
  display: flex;
  gap: 8px;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--theme-border-light, #e0e0e0);
  flex-shrink: 0;
  align-items: center;
}

.clippy-panel__question-input {
  flex: 1;
  border: 1px solid var(--theme-form-border, #ced4da);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--theme-text-primary, #333333);
  background-color: var(--theme-form-bg, #ffffff);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.clippy-panel__question-input::placeholder {
  color: var(--theme-text-muted, #6c757d);
}

.clippy-panel__question-input:focus {
  border-color: var(--theme-form-focus-border, var(--brand-teal));
  box-shadow: var(--theme-shadow-focus);
}

.clippy-panel__question-input:disabled {
  background-color: var(--theme-form-disabled-bg, #f1f3f4);
  cursor: not-allowed;
}

.clippy-panel__submit-btn {
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--primary-gradient);
  color: var(--theme-text-inverse, #ffffff);
  transition: opacity 0.15s ease;
  white-space: nowrap;
}

.clippy-panel__submit-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.clippy-panel__submit-btn:focus-visible {
  outline: 2px solid var(--theme-border-focus, var(--brand-teal));
  outline-offset: 2px;
}

.clippy-panel__submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== FEEDBACK AREA ===== */
.clippy-panel__feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--theme-border-light, #e0e0e0);
  flex-shrink: 0;
}

.clippy-panel__feedback-prompt {
  font-size: 0.8125rem;
  color: var(--theme-text-secondary, #555555);
}

.clippy-panel__feedback-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--theme-border-medium, #dee2e6);
  border-radius: 50%;
  background-color: var(--theme-bg-secondary, #f8f9fa);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.clippy-panel__feedback-btn:hover {
  background-color: var(--theme-bg-tertiary, #e9ecef);
  border-color: var(--theme-border-dark, #ced4da);
}

.clippy-panel__feedback-btn:focus-visible {
  outline: 2px solid var(--theme-border-focus, var(--brand-teal));
  outline-offset: 2px;
}

.clippy-panel__feedback-btn--up:hover {
  border-color: var(--success, #28a745);
  background-color: var(--theme-alert-success-bg);
}

.clippy-panel__feedback-btn--down:hover {
  border-color: var(--danger, #dc3545);
  background-color: var(--theme-alert-danger-bg);
}

.clippy-panel__feedback-thanks {
  font-size: 0.8125rem;
  color: var(--brand-teal, #1f5f7a);
  font-weight: 500;
}

/* ===== FALLBACK CONTENT ===== */
.clippy-panel__fallback {
  padding: 4px 0;
}

.clippy-panel__fallback-text {
  margin: 0 0 10px;
  color: var(--theme-text-primary, #333333);
}

.clippy-panel__suggested-page,
.clippy-panel__help-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--theme-text-link, var(--brand-teal));
  text-decoration: underline;
  cursor: pointer;
}

.clippy-panel__suggested-page:hover,
.clippy-panel__help-link:hover {
  color: var(--theme-text-link-hover, var(--brand-teal-dark));
}

/* ===== TEXT LIST FALLBACK ===== */
.clippy-panel__text-list-fallback {
  padding: 4px 0;
}

.clippy-panel__text-list-heading {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  color: var(--theme-text-secondary, #555555);
}

.clippy-panel__step-list {
  margin: 0;
  padding-left: 22px;
}

.clippy-panel__step-item {
  margin-bottom: 10px;
  line-height: 1.45;
}

.clippy-panel__step-title {
  color: var(--theme-text-primary, #333333);
}

.clippy-panel__step-description {
  color: var(--theme-text-secondary, #555555);
}

/* ===== STREAMING INDICATOR ===== */
.clippy-panel__streaming-indicator {
  padding: 10px 16px;
  font-size: 0.8125rem;
  color: var(--theme-text-secondary, #555555);
  display: flex;
  align-items: center;
  gap: 8px;
}

.clippy-panel__streaming-indicator::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: var(--brand-teal, #1f5f7a);
  border-radius: 50%;
  animation: clippy-pulse 1.2s ease-in-out infinite;
}

@keyframes clippy-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ===== STREAMING TEXT ===== */
.clippy-panel__streaming-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ===== QUESTION SUGGESTIONS ===== */
.clippy-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.clippy-suggestions__item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--theme-border-medium, #dee2e6);
  border-radius: 8px;
  background-color: var(--theme-bg-secondary, #f8f9fa);
  color: var(--theme-text-primary, #333333);
  font-size: 0.8125rem;
  font-family: inherit;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.clippy-suggestions__item:hover {
  background-color: var(--theme-bg-tertiary, #e9ecef);
  border-color: var(--brand-teal, #1f5f7a);
}

.clippy-suggestions__item:focus-visible {
  outline: 2px solid var(--theme-border-focus, var(--brand-teal));
  outline-offset: 2px;
}

.clippy-suggestions__item:active {
  box-shadow: var(--theme-shadow-sm);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .clippy-root {
    bottom: 16px;
    left: 16px;
  }

  .clippy-trigger-btn__label {
    display: none;
  }

  .clippy-trigger-btn {
    width: 44px;
    padding: 0;
    border-radius: 50%;
  }

  .clippy-panel {
    width: calc(100vw - 32px);
    max-height: 70vh;
    left: 0;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  .clippy-panel,
  .clippy-trigger-btn,
  .clippy-panel__loading::before,
  .clippy-panel__streaming-indicator::after {
    transition: none;
    animation: none;
  }
}

@media (prefers-contrast: high) {
  .clippy-panel {
    border-width: 2px;
  }

  .clippy-panel__feedback-btn {
    border-width: 2px;
  }
}
