/**
 * HelpCentre - Components Stylesheet
 * Refined UI components for the Sanctuary design system
 */

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  text-decoration: none;
  user-select: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Button Sizes */
.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
}

.btn-lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-base);
}

.btn-icon {
  padding: var(--space-3);
  aspect-ratio: 1;
}

.btn-icon.btn-sm { padding: var(--space-2); }
.btn-icon.btn-lg { padding: var(--space-4); }

.btn-full { width: 100%; }

/* Primary Button - Teal gradient */
.btn-primary {
  background: linear-gradient(135deg, var(--teal-600) 0%, var(--teal-700) 100%);
  color: white;
  border: none;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--teal-500) 0%, var(--teal-600) 100%);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.1);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-xs);
}

/* Secondary Button */
.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  background-color: var(--bg-muted);
  border-color: var(--border-strong);
}

/* Ghost Button */
.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
}

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

/* Danger Button */
.btn-danger {
  background: linear-gradient(135deg, var(--rose-500) 0%, var(--rose-600) 100%);
  color: white;
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--rose-400) 0%, var(--rose-500) 100%);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Success Button */
.btn-success {
  background: linear-gradient(135deg, var(--emerald-500) 0%, var(--emerald-600) 100%);
  color: white;
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn-success:hover {
  background: linear-gradient(135deg, var(--emerald-400) 0%, var(--emerald-500) 100%);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Button with loader */
.btn .spinner {
  width: 1em;
  height: 1em;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-hover {
  transition: all var(--duration-normal) var(--ease-out);
}

.card-hover:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-muted);
  background-color: var(--bg-subtle);
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.card-title svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--primary);
}

.card-link {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--primary);
  transition: color var(--duration-fast);
}

.card-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

.card-body {
  padding: var(--space-6);
}

.card-body-table {
  padding: 0;
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-muted);
  background-color: var(--bg-subtle);
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  margin-bottom: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
}

.form-label-required::after {
  content: ' *';
  color: var(--error);
}

.form-hint {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.form-error {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--error);
}

/* Input, Select, Textarea */
.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) var(--ease-out);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background-color: var(--bg-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Input Error State */
.form-input.is-error,
.form-select.is-error,
.form-textarea.is-error {
  border-color: var(--error);
}

.form-input.is-error:focus,
.form-select.is-error:focus {
  box-shadow: 0 0 0 3px var(--error-bg);
}

/* Input Sizes */
.form-input-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
}

.form-input-lg {
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-lg);
}

/* Select */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2378716c' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right var(--space-3) center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: var(--space-10);
}

/* Textarea */
.form-textarea {
  min-height: 120px;
  resize: vertical;
}

/* Checkbox & Radio */
.form-checkbox,
.form-radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.form-checkbox input,
.form-radio input {
  width: 1.125rem;
  height: 1.125rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-label input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
}

/* ============================================
   Badges
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  line-height: 1.5;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-default {
  background-color: var(--bg-muted);
  color: var(--text-secondary);
}

.badge-primary {
  background-color: var(--primary-light);
  color: var(--primary);
}

.badge-success {
  background-color: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background-color: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background-color: var(--error-bg);
  color: var(--error);
}

.badge-info {
  background-color: var(--info-bg);
  color: var(--info);
}

/* Risk Level Badges */
.badge-risk-low {
  background-color: var(--risk-low-bg);
  color: var(--risk-low-text);
}

.badge-risk-medium {
  background-color: var(--risk-medium-bg);
  color: var(--risk-medium-text);
}

.badge-risk-high {
  background-color: var(--risk-high-bg);
  color: var(--risk-high-text);
}

.badge-risk-critical {
  background-color: var(--risk-critical-bg);
  color: var(--risk-critical-text);
}

/* Shorthand risk badge aliases */
.badge-low {
  background-color: var(--risk-low-bg);
  color: var(--risk-low-text);
}

.badge-medium {
  background-color: var(--risk-medium-bg);
  color: var(--risk-medium-text);
}

.badge-high {
  background-color: var(--risk-high-bg);
  color: var(--risk-high-text);
}

.badge-critical {
  background-color: var(--risk-critical-bg);
  color: var(--risk-critical-text);
}

.badge-unknown {
  background-color: var(--bg-muted);
  color: var(--text-tertiary);
}

/* ============================================
   Alerts
   ============================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
}

.alert-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}

.alert-success {
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.alert-warning {
  background-color: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning);
}

.alert-error {
  background-color: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error);
}

.alert-info {
  background-color: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info);
}

/* ============================================
   Tables
   ============================================ */
.table {
  width: 100%;
  font-size: var(--text-sm);
}

.table th,
.table td {
  padding: var(--space-4) var(--space-5);
  text-align: left;
  vertical-align: middle;
}

.table th {
  font-family: var(--font-display);
  font-weight: var(--font-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-default);
}

.table td {
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-muted);
}

.table tbody tr {
  transition: background-color var(--duration-fast);
}

.table tbody tr:hover {
  background-color: var(--bg-subtle);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-link {
  color: var(--text-link);
  font-weight: var(--font-medium);
}

.table-link:hover {
  text-decoration: underline;
}

/* ============================================
   Modal
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: var(--z-modal);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(28, 25, 23, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  background-color: var(--bg-surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  animation: fadeInUp var(--duration-normal) var(--ease-out);
}

.modal-sm { max-width: 400px; }
.modal-lg { max-width: 700px; }
.modal-xl { max-width: 900px; }

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

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-lg);
  color: var(--text-tertiary);
  font-size: var(--text-2xl);
  cursor: pointer;
  transition: all var(--duration-fast);
}

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

.modal-body {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-muted);
  background-color: var(--bg-subtle);
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
}

/* ============================================
   Avatar
   ============================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--teal-100) 0%, var(--teal-200) 100%);
  color: var(--teal-700);
  font-family: var(--font-display);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs { width: 1.5rem; height: 1.5rem; font-size: 0.625rem; }
.avatar-sm { width: 2rem; height: 2rem; font-size: var(--text-xs); }
.avatar-lg { width: 3.5rem; height: 3.5rem; font-size: var(--text-lg); }
.avatar-xl { width: 4.5rem; height: 4.5rem; font-size: var(--text-xl); }

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--teal-500) 0%, var(--teal-600) 100%);
  color: white;
  font-family: var(--font-display);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  max-width: 400px;
  animation: slideInRight var(--duration-normal) var(--ease-out);
}

.toast-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}

.toast-content { flex: 1; min-width: 0; }

.toast-title {
  font-family: var(--font-display);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }

.toast-error { border-left: 4px solid var(--error); }
.toast-error .toast-icon { color: var(--error); }

.toast-warning { border-left: 4px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }

/* ============================================
   Spinner / Loading
   ============================================ */
.spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border-default);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

.spinner-sm { width: 1rem; height: 1rem; }
.spinner-lg { width: 2rem; height: 2rem; border-width: 3px; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--bg-subtle) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
}

.empty-state-icon {
  width: 4rem;
  height: 4rem;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 400px;
  margin-bottom: var(--space-6);
}

.list-item-empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ============================================
   Links
   ============================================ */
.link-primary {
  color: var(--primary);
  font-weight: var(--font-medium);
  transition: color var(--duration-fast);
}

.link-primary:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ============================================
   Divider
   ============================================ */
.divider {
  height: 1px;
  background-color: var(--border-muted);
  margin: var(--space-4) 0;
}

/* ============================================
   Progress Bar
   ============================================ */
.progress {
  height: 0.5rem;
  background-color: var(--bg-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-500) 0%, var(--teal-600) 100%);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
}

/* ============================================
   Dropdown
   ============================================ */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: var(--z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--duration-fast) var(--ease-out);
}

.dropdown.is-open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(var(--space-2));
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color var(--duration-fast);
}

.dropdown-item:hover {
  background-color: var(--bg-muted);
}

.dropdown-divider {
  height: 1px;
  background-color: var(--border-muted);
  margin: var(--space-2) 0;
}

/* ============================================
   Additional Badge Variants
   ============================================ */
.badge-secondary {
  background-color: var(--bg-muted);
  color: var(--text-secondary);
}

/* ============================================
   Form Select Sizes
   ============================================ */
.form-select-sm {
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
}
