/* ==========================================================================
   UI COMPONENTS & INTERACTIVE ELEMENTS
   Shape Consistency Lock: --radius-btn (8px) for controls, --radius-card (12px) for panels
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons & Interactive Actions (WCAG AA Contrast + No Line Wrap)
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.78rem 1.4rem;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--accent-strong);
  color: var(--text-on-accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  color: var(--text-on-accent);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-elevated);
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}

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

.btn-lg {
  padding: 0.95rem 1.75rem;
  font-size: var(--text-base);
}

.btn-sm {
  padding: 0.55rem 1rem;
  font-size: var(--text-xs);
}

/* --------------------------------------------------------------------------
   Header Controls: Theme Switcher & Language Selector
   -------------------------------------------------------------------------- */
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-btn);
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--bg-surface-elevated);
}

.theme-toggle:active {
  transform: scale(0.96);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: block;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: none;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-btn);
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: calc(var(--radius-btn) - 2px);
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.lang-btn:hover {
  color: var(--text-primary);
}

.lang-btn.active {
  background: var(--accent-strong);
  color: var(--text-on-accent);
}

/* --------------------------------------------------------------------------
   Badges & Chips (Single Accent Lock)
   -------------------------------------------------------------------------- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 0.28rem 0.65rem;
  border-radius: var(--radius-btn);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

a.tag {
  text-decoration: none;
  color: var(--text-primary);
  border-color: var(--border-strong);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
}

a.tag::after {
  content: "↗";
  font-size: 0.9em;
  opacity: 0.75;
}

a.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.tag-accent {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent-border);
}

.proof-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
}

.proof-link-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   Form Controls & Skeletal Loading States (Section 4.5 & 4.6)
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
}

.form-label {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-label .required {
  color: var(--accent);
}

.form-helper {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.8rem 1rem;
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--form-bg);
  border: 1px solid var(--form-border);
  border-radius: var(--radius-input);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
  outline: none;
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus {
  background: var(--form-focus-bg);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.form-control.error {
  border-color: var(--accent);
}

.form-error-msg {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  margin-top: 2px;
  display: none;
}

.form-group.has-error .form-error-msg {
  display: block;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237b8393' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.1em;
  padding-right: 2.5rem;
}

textarea.form-control {
  resize: vertical;
  min-height: 112px;
}

/* Skeletal Submit Loader (No circular spinner - Section 4.5) */
.form-skeleton-loader {
  display: none;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  margin-top: var(--space-4);
}

.form-skeleton-loader.active {
  display: flex;
}

.skeleton-line {
  height: 12px;
  border-radius: var(--radius-btn);
  background: linear-gradient(90deg, var(--bg-surface-elevated) 25%, var(--border-strong) 50%, var(--bg-surface-elevated) 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.2s ease-in-out infinite;
}

.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-50 { width: 50%; }

@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Success Card State */
.form-success-card {
  display: none;
  padding: var(--space-8);
  background: var(--bg-surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
}

.form-success-card.active {
  display: block;
}

.success-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-btn);
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.success-icon svg {
  width: 24px;
  height: 24px;
}

/* --------------------------------------------------------------------------
   Toast Notification
   -------------------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.8rem 1.2rem;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-btn);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  transform: translateY(80px);
  opacity: 0;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Native HTML <dialog closedby="any"> Modal System (modern-web-guidance)
   -------------------------------------------------------------------------- */
dialog.app-dialog {
  margin: auto;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  width: min(92vw, 640px);
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
}

dialog.app-dialog::backdrop {
  background-color: rgba(8, 9, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-close-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-btn);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}
