/* ============================================================
   DarijaAI — components.css
   Reusable UI components
   ============================================================ */

/* ── Loading dots ───────────────────────────────────────────── */
.loading-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: dotBounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { background: #7c3aed; }
.loading-dots span:nth-child(2) { background: #ec4899; animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { background: #f97316; animation-delay: 0.4s; }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}

/* ── Toast notification ─────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(.16,1,.3,1), opacity 0.3s ease;
  max-width: 320px;
  text-align: center;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.toast.toast-err    { border-color: rgba(239,68,68,0.4); color: #ef4444; }
.toast.toast-ok     { border-color: rgba(34,197,94,0.4); color: #22c55e; }
.toast.toast-warn   { border-color: rgba(251,191,36,0.4); color: #fbbf24; }
.toast.toast-purple { border-color: rgba(167,139,250,0.4); color: var(--c-purple-l); }

/* ── Modal / Overlay ────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  max-width: 440px;
  width: 100%;
  position: relative;
  animation: fadeUp 0.3s ease;
}

.modal-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad-main);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

/* Bottom sheet (mobile) */
.modal-bottom {
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-bottom .modal-box {
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-width: 480px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-5);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text); }

/* ── Opt button (type/langue/tone selector) ──────────────────── */
.opt-btn {
  padding: 12px 16px;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  color: var(--text-3);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.opt-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.opt-btn.active {
  background: rgba(124,58,237,0.2);
  border-color: rgba(124,58,237,0.5);
  color: var(--text);
  box-shadow: 0 0 20px rgba(124,58,237,0.15);
}

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

/* ── Result box ─────────────────────────────────────────────── */
.result-box {
  background: rgba(124,58,237,0.06);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
}

.result-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.5), transparent);
}

.result-box.hidden { display: none !important; }

.result-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-purple-l);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}

.result-content {
  color: var(--text-2);
  line-height: 1.8;
  font-size: 14px;
  white-space: pre-wrap;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 9px 18px;
  background: var(--bg-btn);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

.action-btn.active {
  background: rgba(124,58,237,0.2);
  border-color: rgba(124,58,237,0.4);
  color: var(--c-purple-l);
}

/* ── Generate button ─────────────────────────────────────────── */
.gen-btn {
  width: 100%;
  padding: 15px;
  background: var(--grad-main);
  border: none;
  border-radius: var(--radius-lg);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-btn);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.gen-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-btn-h);
}

.gen-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.gen-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: btnShine 2.5s linear infinite;
}

@keyframes btnShine {
  0%   { left: -100%; }
  100% { left: 200%; }
}

/* ── History items ──────────────────────────────────────────── */
.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
}

.history-item::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.2), transparent);
}

.history-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.history-item.deleting {
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s ease;
}

.history-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.history-business {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

.history-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.history-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(124,58,237,0.15);
  color: var(--c-purple-l);
  font-weight: 600;
}

.history-date {
  font-size: 11px;
  color: var(--text-5);
}

.history-preview {
  font-size: 13px;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-content {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
  white-space: pre-wrap;
}

.history-content.open { display: block; }

.history-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.history-copy {
  padding: 7px 16px;
  background: var(--bg-btn);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.history-copy:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text);
}

.history-del {
  padding: 7px 16px;
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  color: #ef4444;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.history-del:hover {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.4);
}

/* ── Filter buttons ─────────────────────────────────────────── */
.filter-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.18s ease;
}

.filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--c-purple-l);
}

.filter-btn.active {
  background: rgba(124,58,237,0.15);
  border-color: rgba(167,139,250,0.5);
  color: var(--c-purple-l);
}

/* ── Upgrade toast (persistent) ─────────────────────────────── */
.upgrade-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  max-width: 320px;
  width: calc(100% - 48px);
  background: var(--bg-2);
  border: 1px solid rgba(124,58,237,0.35);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transform: translateY(120px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: none;
}

.upgrade-toast::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad-main);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.upgrade-toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Voice button ───────────────────────────────────────────── */
.voice-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  color: var(--c-purple-l);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.voice-btn:hover {
  background: rgba(124,58,237,0.25);
  border-color: rgba(167,139,250,0.5);
}

.voice-btn.recording {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.5);
  animation: pulse 1s infinite;
}

/* ── Free/premium bar ───────────────────────────────────────── */
.status-bar {
  position: relative;
  z-index: 10;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.free-bar {
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

.premium-bar {
  background: linear-gradient(90deg, rgba(251,191,36,0.08), rgba(249,115,22,0.08));
  border-bottom: 1px solid rgba(251,191,36,0.2);
  justify-content: center;
}

.free-progress {
  width: 60px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.free-progress-bar {
  height: 100%;
  background: var(--grad-main);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Pricing cards ──────────────────────────────────────────── */
.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 32px;
  position: relative;
}

.plan-card.featured {
  border-color: rgba(124,58,237,0.4);
  background: rgba(124,58,237,0.06);
}

.plan-card.featured::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad-main);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.plan-price {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--text);
}

.plan-price sup {
  font-size: 22px;
  font-weight: 700;
  vertical-align: top;
  margin-top: 10px;
  display: inline-block;
}

.plan-price .period {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-4);
  letter-spacing: 0;
}

.plan-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-3);
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.plan-feature:last-child { border-bottom: none; }

.plan-feature .check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(34,197,94,0.15);
  color: #22c55e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

/* ── FAQ accordion ──────────────────────────────────────────── */
.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-q {
  width: 100%;
  text-align: left;
  padding: 20px 0;
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: color var(--transition);
}

.faq-q:hover { color: var(--c-purple-l); }

.faq-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--c-purple-l);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.faq-item.open .faq-icon { transform: rotate(45deg); }

.faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.faq-item.open .faq-a {
  max-height: 300px;
  padding-bottom: 20px;
}

.faq-a p {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-3);
}

/* ── Mobile sticky generate bar ─────────────────────────────── */
.mobile-gen-bar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 200;
  background: var(--bg-nav-solid);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  gap: 10px;
  align-items: center;
  backdrop-filter: blur(20px);
}

.mobile-gen-preview {
  font-size: 13px;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.mobile-gen-preview.has-val { color: var(--text-2); }

@media (max-width: 640px) {
  .mobile-gen-bar { display: flex; }
  .gen-btn { display: none; }
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-4);
}

.empty-state .emoji {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  max-width: 280px;
  margin: 0 auto;
}
