/* ============================================================
   UI TOOLKIT — Shared Components for FraudKe.com
   S1-S15 UI/UX Hardening
   ============================================================ */

/* ── S4: Micro-Interactions ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes meterFill {
  from { width: 0; }
}
@keyframes rippleEffect {
  to { transform: scale(4); opacity: 0; }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease both;
}
.fade-in {
  animation: fadeIn 0.4s ease both;
}

/* Staggered card entry */
.stagger-item { opacity: 0; animation: fadeInUp 0.4s ease forwards; }
.stagger-item:nth-child(1)  { animation-delay: 0.05s; }
.stagger-item:nth-child(2)  { animation-delay: 0.1s; }
.stagger-item:nth-child(3)  { animation-delay: 0.15s; }
.stagger-item:nth-child(4)  { animation-delay: 0.2s; }
.stagger-item:nth-child(5)  { animation-delay: 0.25s; }
.stagger-item:nth-child(6)  { animation-delay: 0.3s; }
.stagger-item:nth-child(7)  { animation-delay: 0.35s; }
.stagger-item:nth-child(8)  { animation-delay: 0.4s; }
.stagger-item:nth-child(9)  { animation-delay: 0.45s; }
.stagger-item:nth-child(10) { animation-delay: 0.5s; }

/* Button ripple */
.btn { position: relative; overflow: hidden; }
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  width: 20px; height: 20px;
  transform: scale(0);
  animation: rippleEffect 0.6s linear;
  pointer-events: none;
}
.btn:active { transform: scale(0.97); }

/* Smooth collapse */
.smooth-collapse {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  opacity: 0;
}
.smooth-collapse.open {
  max-height: 2000px;
  opacity: 1;
}

/* ── S1: Risk Meter ── */
.risk-meter {
  position: relative;
  width: 100%;
  height: 28px;
  background: #e5e7eb;
  border-radius: 14px;
  overflow: hidden;
  margin: 8px 0;
}
.risk-meter__fill {
  height: 100%;
  border-radius: 14px;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  min-width: 0;
}
.risk-meter__fill::after {
  content: attr(data-score);
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.risk-meter--green  .risk-meter__fill { background: linear-gradient(90deg, #10b981, #059669); }
.risk-meter--amber  .risk-meter__fill { background: linear-gradient(90deg, #f59e0b, #d97706); }
.risk-meter--red    .risk-meter__fill { background: linear-gradient(90deg, #ef4444, #dc2626); }

.risk-meter__labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #9ca3af;
  margin-top: 2px;
  padding: 0 4px;
}

/* Risk Factor Chips */
.risk-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  margin: 3px;
}
.risk-chip:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.risk-chip--danger  { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.risk-chip--warning { background: #fffbeb; color: #d97706; border-color: #fde68a; }
.risk-chip--success { background: #f0fdf4; color: #059669; border-color: #bbf7d0; }
.risk-chip--info    { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }

.risk-chip__detail {
  display: none;
  font-weight: 400;
  font-size: 0.75rem;
  margin-top: 4px;
  padding: 6px 10px;
  background: #f9fafb;
  border-radius: 8px;
  line-height: 1.4;
}
.risk-chip.expanded .risk-chip__detail { display: block; }

/* Confidence Badge */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: help;
  position: relative;
}
.confidence-badge--high   { background: #dcfce7; color: #166534; }
.confidence-badge--medium { background: #fef9c3; color: #854d0e; }
.confidence-badge--low    { background: #fee2e2; color: #991b1b; }

.confidence-badge .tooltip-text {
  visibility: hidden;
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s;
}
.confidence-badge .tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
}
.confidence-badge:hover .tooltip-text { visibility: visible; opacity: 1; }

/* Cross-Report Counter */
.cross-report-counter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  font-weight: 600;
  color: #1e40af;
}
.cross-report-counter__num {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}


/* ── S2: Wizard Stepper ── */
.wizard-progress {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 2rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.wizard-progress::before {
  content: '';
  position: absolute;
  top: 18px;
  left: 12%;
  right: 12%;
  height: 3px;
  background: #e5e7eb;
  z-index: 0;
}
.wizard-progress__track {
  position: absolute;
  top: 18px;
  left: 12%;
  height: 3px;
  background: #0d47a1;
  z-index: 1;
  transition: width 0.5s ease;
}
.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  flex: 1;
}
.wizard-step__circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.3s;
  border: 3px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.wizard-step.active .wizard-step__circle {
  background: #0d47a1;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(13,71,161,0.2);
}
.wizard-step.completed .wizard-step__circle {
  background: #059669;
  color: #fff;
}
.wizard-step__label {
  margin-top: 8px;
  font-size: 0.75rem;
  Font-weight: 600;
  color: #9ca3af;
  text-align: center;
}
.wizard-step.active .wizard-step__label,
.wizard-step.completed .wizard-step__label { color: #1e293b; }

.wizard-panel { display: none; animation: fadeIn 0.3s ease; }
.wizard-panel.active { display: block; }

.wizard-pct {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #0d47a1;
  margin-bottom: 8px;
}

/* ── S3: Evidence Upload Zone ── */
.upload-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: #f8fafc;
  position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: #0d47a1;
  background: #eff6ff;
}
.upload-zone__icon {
  font-size: 2.5rem;
  color: #94a3b8;
  margin-bottom: 0.5rem;
}
.upload-zone__text { color: #64748b; font-size: 0.9rem; }
.upload-zone__preview {
  position: relative;
  display: none;
  margin-top: 1rem;
}
.upload-zone__preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.upload-zone__preview.visible { display: block; }

.upload-progress {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 12px;
  display: none;
}
.upload-progress.visible { display: block; }
.upload-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, #0d47a1, #2563eb);
  border-radius: 3px;
  width: 0;
  transition: width 0.3s;
}

.duplicate-warning {
  display: none;
  padding: 10px 14px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 8px;
  color: #92400e;
  font-size: 0.85rem;
  margin-top: 10px;
}
.duplicate-warning.visible { display: flex; align-items: center; gap: 8px; }


/* ── S5: Dashboard Animated Counters ── */
.stat-counter {
  text-align: center;
  padding: 1.25rem;
}
.stat-counter__number {
  font-size: 2.2rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-counter__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-counter__icon {
  font-size: 1.4rem;
  margin-bottom: 8px;
}


/* ── S6: Report Timeline ── */
.report-timeline {
  position: relative;
  padding-left: 30px;
}
.report-timeline::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e5e7eb;
}
.timeline-item {
  position: relative;
  padding-bottom: 24px;
  padding-left: 20px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item__dot {
  position: absolute;
  left: -22px;
  top: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #e5e7eb;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #e5e7eb;
}
.timeline-item--active .timeline-item__dot {
  background: #0d47a1;
  box-shadow: 0 0 0 2px #0d47a1;
}
.timeline-item--completed .timeline-item__dot {
  background: #059669;
  box-shadow: 0 0 0 2px #059669;
}
.timeline-item--alert .timeline-item__dot {
  background: #f59e0b;
  box-shadow: 0 0 0 2px #f59e0b;
}
.timeline-item__title {
  font-weight: 700;
  font-size: 0.9rem;
  color: #1e293b;
}
.timeline-item__time {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 2px;
}


/* ── S7: Evidence Viewer Modal ── */
.evidence-modal .modal-dialog { max-width: 900px; }
.evidence-modal .modal-content { border-radius: 12px; border: none; }
.evidence-modal .modal-body {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  min-height: 400px;
  position: relative;
  border-radius: 0 0 12px 12px;
}
.evidence-modal img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  transition: transform 0.3s;
  cursor: zoom-in;
}
.evidence-modal img.zoomed {
  transform: scale(2);
  cursor: zoom-out;
}
.evidence-modal .btn-fullscreen {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.2s;
}
.evidence-modal .btn-fullscreen:hover { background: rgba(255,255,255,0.3); }

.watermark-overlay {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0,0,0,0.5);
  color: rgba(255,255,255,0.7);
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
}


/* ── S8: Trust Signals ── */
.trust-expandable {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.trust-expandable__header {
  padding: 14px 18px;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #334155;
  transition: background 0.2s;
}
.trust-expandable__header:hover { background: #f1f5f9; }
.trust-expandable__header i {
  transition: transform 0.3s;
}
.trust-expandable__header.open i { transform: rotate(180deg); }
.trust-expandable__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}
.trust-expandable__body.open { max-height: 600px; }
.trust-expandable__content {
  padding: 16px 18px;
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.7;
}


/* ── S9: Reporter Dashboard ── */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tier-badge--novice  { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.tier-badge--trusted { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.tier-badge--expert  { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; }

.accuracy-ring {
  position: relative;
  width: 80px;
  height: 80px;
  display: inline-block;
}
.accuracy-ring__text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.1rem;
  font-weight: 800;
  color: #1e293b;
}

.tier-upgrade-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 14px 20px;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  border-radius: 10px;
  font-weight: 600;
  z-index: 9999;
  animation: fadeInUp 0.4s ease, fadeIn 0.3s reverse 3s forwards;
  box-shadow: 0 10px 30px rgba(5,150,105,0.3);
}


/* ── S10: Appeal Status ── */
.dispute-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.appeal-status-badge {
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 700;
}
.appeal-status-badge--pending { background: #fef9c3; color: #854d0e; }
.appeal-status-badge--accepted { background: #dcfce7; color: #166534; }
.appeal-status-badge--denied { background: #fee2e2; color: #991b1b; }


/* ── S12: Skeleton Loaders ── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}
.skeleton-text { height: 14px; margin-bottom: 10px; width: 80%; }
.skeleton-title { height: 20px; margin-bottom: 14px; width: 50%; }
.skeleton-card {
  height: 120px;
  border-radius: 12px;
  margin-bottom: 16px;
}
.skeleton-circle { width: 48px; height: 48px; border-radius: 50%; }
.skeleton-stat { height: 48px; width: 100%; border-radius: 8px; }


/* ── S13: Smart Search ── */
.search-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.1);
  z-index: 100;
  display: none;
  max-height: 320px;
  overflow-y: auto;
}
.search-autocomplete.visible { display: block; }
.search-autocomplete__item {
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}
.search-autocomplete__item:hover { background: #f8fafc; }
.search-autocomplete__item:last-child { border-bottom: none; }
.search-highlight { background: #fef08a; padding: 1px 2px; border-radius: 2px; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-chip:hover { background: #dbeafe; }
.filter-chip.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.filter-chip__remove {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.1);
  font-size: 0.6rem;
  cursor: pointer;
}

.result-count {
  font-size: 0.85rem;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 12px;
}


/* ── S14: Color Hierarchy Enforcement ── */
.status-tag--danger  { color: #dc2626; }
.status-tag--warning { color: #d97706; }
.status-tag--success { color: #059669; }
.status-tag--neutral { color: #64748b; }


/* ── S15: Empty States ── */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  max-width: 400px;
  margin: 0 auto;
}
.empty-state__icon {
  font-size: 3rem;
  color: #cbd5e1;
  margin-bottom: 1rem;
}
.empty-state__title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: 0.5rem;
}
.empty-state__text {
  font-size: 0.9rem;
  color: #94a3b8;
  line-height: 1.5;
  margin-bottom: 1rem;
}
.empty-state__action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}


/* ── S11: Mobile Optimization ── */
@media (max-width: 768px) {
  .risk-meter { height: 20px; }
  .risk-meter__fill::after { font-size: 0.65rem; right: 6px; }
  .wizard-step__circle { width: 30px; height: 30px; font-size: 0.75rem; }
  .wizard-step__label { font-size: 0.65rem; }
  .stat-counter__number { font-size: 1.6rem; }
  .upload-zone { padding: 1.2rem; }
  .confidence-badge { font-size: 0.7rem; }
}

@media (max-width: 480px) {
  .wizard-progress { gap: 4px; }
  .wizard-step__label { display: none; }
  .risk-chip { font-size: 0.72rem; padding: 4px 10px; }
  .empty-state { padding: 2rem 1rem; }
}

/* Sticky mobile submit */
.mobile-sticky-submit {
  display: none;
}
@media (max-width: 768px) {
  .mobile-sticky-submit {
    display: block;
    position: fixed;
    bottom: 60px;
    left: 0;
    right: 0;
    padding: 10px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    z-index: 999;
  }
  .mobile-sticky-submit .btn { width: 100%; min-height: 44px; font-size: 1rem; }
}

/* Min tap targets */
@media (max-width: 768px) {
  .btn, .nav-link, .form-control, .form-select,
  .filter-chip, .risk-chip {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}
