/* FormArea — Components */

/* ══════════════════════════════
   BASE BODY
══════════════════════════════ */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  min-height: 100vh;
}

/* ══════════════════════════════
   BUTTONS
══════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-weight: var(--fw-semi);
  font-size: var(--text-base);
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inv);
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #f0ff60;
  box-shadow: var(--glow-accent);
  transform: translateY(-2px);
}
.btn-primary:active, .btn-outline:active, .btn-ghost:active, .btn-surface:active { transform: scale(0.96) translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--border-hover);
}
.btn-outline:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-surface {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-surface:hover {
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn-sm { padding: var(--sp-2) var(--sp-4); font-size: var(--text-sm); }
.btn-lg { padding: var(--sp-4) var(--sp-8); font-size: var(--text-lg); }
.btn-xl { padding: var(--sp-5) var(--sp-10); font-size: var(--text-xl); font-weight: var(--fw-bold); }
.btn-full { width: 100%; }
.btn-icon { padding: var(--sp-3); border-radius: var(--r-md); aspect-ratio: 1; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ══════════════════════════════
   CARDS
══════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card-accent {
  border-color: var(--border-hover);
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.card-accent::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
}

/* ══════════════════════════════
   FORMS
══════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: var(--sp-2); }
.form-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  letter-spacing: 0.02em;
}
.form-input, .form-select, .form-textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  color: var(--text);
  font-size: var(--text-base);
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-select { cursor: pointer; }
.form-select option { background: var(--surface); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: var(--text-sm); color: var(--text-3); }
.form-error { font-size: var(--text-sm); color: var(--error); }

.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }

/* Radio card options */
.option-grid { display: grid; gap: var(--sp-3); }
.option-grid-2 { grid-template-columns: 1fr 1fr; }
.option-card {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.option-card:hover { border-color: var(--border-hover); }
.option-card.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.option-card input[type="radio"], .option-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.option-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}
.option-title { font-weight: var(--fw-semi); font-size: var(--text-base); }
.option-desc { font-size: var(--text-sm); color: var(--text-3); margin-top: 2px; }

/* ══════════════════════════════
   BADGES
══════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge-pro { background: var(--accent); color: var(--text-inv); }
.badge-trial { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.badge-success { background: rgba(226,255,71,.15); color: var(--accent); }
.badge-error { background: rgba(255,87,87,.15); color: var(--error); }
.badge-warning { background: rgba(255,181,71,.15); color: var(--warning); }

/* ══════════════════════════════
   STAT CARDS
══════════════════════════════ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.stat-label { font-size: var(--text-sm); color: var(--text-3); font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: var(--text-3xl); font-weight: var(--fw-extra); font-family: var(--font-head); color: var(--text); line-height: 1; }
.stat-unit { font-size: var(--text-sm); color: var(--text-2); }
.stat-accent .stat-value { color: var(--accent); }

/* ══════════════════════════════
   PAYWALL / LOCKED
══════════════════════════════ */
.locked-overlay {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
}
.locked-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 20%, var(--bg) 90%);
  z-index: 1;
  pointer-events: none;
}
.locked-content {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
}
.locked-cta {
  position: absolute;
  bottom: var(--sp-8);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  white-space: nowrap;
}
.locked-icon { font-size: 2rem; }
.locked-text { font-size: var(--text-sm); color: var(--text-2); }

/* ══════════════════════════════
   PROGRESS BAR
══════════════════════════════ */
.progress-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-full);
  transition: width 0.6s var(--ease);
}

/* ══════════════════════════════
   TABS
══════════════════════════════ */
.tab-bar {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--r-lg);
  padding: var(--sp-1);
  gap: var(--sp-1);
}
.tab-btn {
  flex: 1;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-3);
  transition: all var(--transition);
  text-align: center;
}
.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.tab-btn:hover:not(.active) { color: var(--text-2); }

/* ══════════════════════════════
   LANGUAGE TOGGLE
══════════════════════════════ */
.lang-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 2px;
  gap: 2px;
}
.lang-btn {
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: var(--text-sm);
  font-weight: var(--fw-semi);
  color: var(--text-3);
  transition: all var(--t-fast) var(--ease);
}
.lang-btn.active {
  background: var(--accent);
  color: var(--text-inv);
}
.lang-btn:hover:not(.active) { color: var(--text-2); }

/* ══════════════════════════════
   ALERTS / BANNERS
══════════════════════════════ */
.alert {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  border: 1px solid;
}
.alert-upgrade {
  background: var(--accent-dim);
  border-color: var(--border-hover);
  color: var(--text-2);
  justify-content: space-between;
}
.alert-success { background: rgba(226,255,71,.08); border-color: rgba(226,255,71,.3); color: var(--accent); }
.alert-error   { background: rgba(255,87,87,.08);  border-color: rgba(255,87,87,.3);  color: var(--error); }

/* ══════════════════════════════
   SKELETON LOADING
══════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ══════════════════════════════
   AVATAR
══════════════════════════════ */
.avatar {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: var(--accent-dim2);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-bold);
  font-size: var(--text-sm);
  color: var(--accent);
  flex-shrink: 0;
  font-family: var(--font-head);
}

/* ══════════════════════════════
   DIVIDER
══════════════════════════════ */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-6) 0;
}
.divider-text {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  color: var(--text-3);
  font-size: var(--text-sm);
  margin: var(--sp-6) 0;
}
.divider-text::before, .divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ══════════════════════════════
   MODAL
══════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  animation: fadeIn var(--t-normal) var(--ease);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  max-width: 480px;
  width: 100%;
  animation: slideUp var(--t-normal) var(--ease);
}
.modal-title { font-family: var(--font-head); font-size: var(--text-2xl); font-weight: var(--fw-bold); margin-bottom: var(--sp-2); }
.modal-subtitle { color: var(--text-2); margin-bottom: var(--sp-6); }

/* ══════════════════════════════
   ANIMATIONS
══════════════════════════════ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes popUpBounce { 0% { opacity: 0; transform: scale(0.85); } 60% { opacity: 1; transform: scale(1.03); } 100% { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes dotBlink {
  0%, 20% { opacity: 0; } 50% { opacity: 1; } 80%, 100% { opacity: 0; }
}

.animate-fade { animation: fadeIn var(--t-normal) var(--ease); }
.animate-slide-up { animation: slideUp var(--t-normal) var(--ease); }
.animate-slide-in { animation: slideIn var(--t-normal) var(--ease); }
.animate-pop-up { animation: popUpBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.spinner { animation: spin 1s linear infinite; }

/* Staggered children */
.stagger-children > * { animation: slideUp var(--t-slow) var(--ease) both; }
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }

/* ══════════════════════════════
   UTILITY
══════════════════════════════ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.gap-8 { gap: var(--sp-8); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-4); }
.text-center { text-align: center; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-muted { color: var(--text-3); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: var(--fw-bold); }
.font-semi { font-weight: var(--fw-semi); }
.font-head { font-family: var(--font-head); }
.w-full { width: 100%; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.p-4 { padding: var(--sp-4); }
.p-6 { padding: var(--sp-6); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */
@media (max-width: 768px) {
  .input-row { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .option-grid-2 { grid-template-columns: 1fr; }
  .hide-mobile { display: none !important; }
}
@media (max-width: 480px) {
  .btn-xl { padding: var(--sp-4) var(--sp-6); font-size: var(--text-base); }
}

/* =========================
   GLOBAL CHAT WIDGET
========================= */
.chat-widget-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}

.chat-widget-container.open {
  pointer-events: auto;
}

/* Floating Action Button (FAB) */
.chat-widget-fab {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--primary);
  color: #111;
  border: none;
  box-shadow: 0 4px 20px rgba(184, 255, 34, 0.4);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: auto;
}

.chat-widget-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(184, 255, 34, 0.6);
}

.chat-widget-container.open .chat-widget-fab {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  transform: scale(0.9);
}

/* Tooltip (Cloud) */
.chat-widget-tooltip {
  position: absolute;
  bottom: 10px;
  right: 80px;
  background: rgba(255, 255, 255, 0.95);
  color: #111;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  pointer-events: none;
  opacity: 0;
  transform-origin: right center;
}

.chat-widget-tooltip.bounce-animation {
  animation: tooltipBounce 4s infinite cubic-bezier(0.36, 0, 0.66, -0.56);
  opacity: 1;
}

.tooltip-arrow {
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid rgba(255, 255, 255, 0.95);
}

@keyframes tooltipBounce {
  0%, 100% { transform: translateX(0) scale(1); }
  50% { transform: translateX(-8px) scale(1.02); }
}

/* Chat Panel */
.chat-widget-panel {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 360px;
  height: 500px;
  max-height: 70vh;
  background: rgba(20, 20, 20, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

.chat-widget-container.open .chat-widget-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-widget-header {
  padding: 1rem;
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.chat-widget-avatar {
  width: 40px;
  height: 40px;
  background: var(--surface-3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.chat-widget-name {
  font-weight: 600;
  font-size: 1rem;
}

.chat-widget-status {
  font-size: 0.8rem;
  color: var(--primary);
}

.chat-widget-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: var(--text);
  background: transparent;
}

.chat-widget-input-area {
  padding: 1rem;
  background: rgba(255,255,255,0.03);
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 480px) {
  .chat-widget-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 80vh;
    border-radius: 24px 24px 0 0;
  }
}
