/* ================================================================
   SocialScan – Clean Light Design System
   ================================================================ */

/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg:        #f8fafc;
  --c-surface:   #ffffff;
  --c-card:      #ffffff;
  --c-border:    #e2e8f0;
  --c-border-hi: #cbd5e1;

  --c-primary:   #2563eb;
  --c-primary-2: #1d4ed8;
  --c-accent:    #3b82f6;

  --c-green:  #10b981;
  --c-yellow: #f59e0b;
  --c-red:    #ef4444;
  --c-blue:   #3b82f6;

  --c-text:     #0f172a;
  --c-text-2:   #475569;
  --c-text-3:   #64748b;

  --radius-s:  4px;
  --radius-m:  8px;
  --radius-l:  12px;
  --radius-xl: 16px;

  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

html { height: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

/* ── App Shell ───────────────────────────────────────────────── */
.app-shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: 0 0 20px;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ── Header ──────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--c-primary);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
}
.logo-name {
  font-weight: 700;
  font-size: 18px;
  color: var(--c-text);
  letter-spacing: -.3px;
}

/* Status badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 99px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--c-green);
  transition: all .2s;
}
.status-badge.scanning {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--c-primary);
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c-green);
}
.status-badge.scanning .status-dot {
  background: var(--c-primary);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(.7); }
}

/* ── Hero Strip ──────────────────────────────────────────────── */
.hero-strip {
  padding: 24px 20px 8px;
  text-align: center;
}
.hero-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.2;
  color: var(--c-text);
  margin-bottom: 8px;
}
.gradient-text {
  color: var(--c-primary);
}
.hero-sub {
  font-size: 14px;
  color: var(--c-text-2);
  line-height: 1.5;
}

/* ── Views ───────────────────────────────────────────────────── */
.view {
  flex: 1;
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeIn .3s ease;
}
@keyframes fadeIn {
  from { opacity:0; transform: translateY(8px); }
  to   { opacity:1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────────────────────
   VIEW 1 – UPLOAD
   ───────────────────────────────────────────────────────────── */

/* Upload Card */
.upload-card {
  background: var(--c-card);
  border: 2px dashed var(--c-border-hi);
  border-radius: var(--radius-l);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, background .2s;
  -webkit-tap-highlight-color: transparent;
}
.upload-card:hover,
.upload-card.dragover {
  border-color: var(--c-primary);
  background: #f8fafc;
}
.upload-card.has-file {
  border-style: solid;
  border-color: var(--c-primary);
  min-height: 220px;
}

/* Empty dropzone */
.dropzone-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  text-align: center;
  pointer-events: none;
}
.dz-icon-wrap {
  width: 56px; height: 56px;
  border-radius: var(--radius-m);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.dz-icon { width: 28px; height: 28px; color: var(--c-primary); }
.dz-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-text);
}
.dz-sub {
  font-size: 13px;
  color: var(--c-text-2);
}
.dz-browse {
  color: var(--c-primary);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dz-hint {
  font-size: 12px;
  color: var(--c-text-3);
  margin-top: 4px;
}

/* Preview state */
.dropzone-preview {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}
.preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #f1f5f9;
}
.preview-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.6) 0%, transparent 40%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 16px;
}
.preview-change {
  font-size: 12px;
  font-weight: 500;
  color: #ffffff;
  background: rgba(0,0,0,.5);
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,.2);
}

/* Platforms row */
.platforms-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.platform-tag {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text-2);
}

/* Buttons */
.btn-primary {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: var(--radius-m);
  background: var(--c-primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity .2s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover:not(:disabled) {
  opacity: .9;
}
.btn-primary:active:not(:disabled) { transform: scale(.98); }
.btn-primary:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  height: 44px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .2s, border-color .2s;
  -webkit-tap-highlight-color: transparent;
  margin-top: 4px;
}
.btn-secondary:hover { background: #f1f5f9; border-color: var(--c-border-hi); }
.btn-secondary:active { transform: scale(.98); }

/* ─────────────────────────────────────────────────────────────
   VIEW 2 – SCANNING
   ───────────────────────────────────────────────────────────── */
.scan-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-card);
}

/* Scan image wrap */
.scan-image-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  border-radius: var(--radius-m);
  overflow: hidden;
  background: #f1f5f9;
  border: 1px solid var(--c-border);
}
.scan-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#scanCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Progress bar */
.progress-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress-track {
  flex: 1;
  height: 8px;
  background: #f1f5f9;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--c-border);
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--c-primary);
  border-radius: 99px;
  transition: width .4s ease;
}
.progress-pct {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-primary);
  min-width: 40px;
  text-align: right;
}

/* Steps list */
.steps-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.step-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  transition: all .3s;
}
.step-icon.pending {
  border-color: #cbd5e1;
  color: var(--c-text-3);
  background: #f8fafc;
}
.step-icon.active {
  border-color: var(--c-primary);
  color: var(--c-primary);
  background: #eff6ff;
}
.step-icon.done {
  border-color: var(--c-green);
  color: #fff;
  background: var(--c-green);
}
.step-label {
  font-size: 14px;
  color: var(--c-text-2);
  font-weight: 500;
  transition: color .3s;
}
.step-item.done .step-label  { color: var(--c-text); }
.step-item.active .step-label { color: var(--c-primary); font-weight: 600; }

/* ─────────────────────────────────────────────────────────────
   VIEW 3 – RESULTS
   ───────────────────────────────────────────────────────────── */

/* Results Summary Card (horizontal) */
.results-summary-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-l);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
}
.result-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--c-border);
  flex-shrink: 0;
}
.result-summary-text { flex: 1; }
.result-score-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1;
  margin-bottom: 6px;
}
.score-val {
  font-size: 28px;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -.5px;
}
.score-pct {
  font-size: 16px;
  font-weight: 600;
  color: var(--c-text-2);
}
.score-label {
  font-size: 13px;
  color: var(--c-text-2);
  font-weight: 500;
  margin-left: 2px;
}
.result-found-label {
  font-size: 13px;
  color: var(--c-text-2);
}
.result-found-label strong { color: var(--c-text); }
.result-verified-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-green);
  flex-shrink: 0;
}

/* ── Account Cards ───────────────────────────────────────────── */
.account-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-m);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.account-card:hover {
  border-color: var(--c-primary);
}
.ac-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 18px;
}
.account-card.ig .ac-icon { background: #fdf4ff; color: #d946ef; }
.account-card.fb .ac-icon { background: #eff6ff; color: #2563eb; }
.account-card.tw .ac-icon { background: #f1f5f9; color: #0f172a; }
.account-card.tt .ac-icon { background: #f1f5f9; color: #000000; }
.account-card.li .ac-icon { background: #eff6ff; color: #0284c7; }

.ac-body { flex: 1; min-width: 0; }
.ac-platform {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-3);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.ac-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.ac-meta {
  font-size: 12px;
  color: var(--c-text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ac-meta-dot { color: var(--c-border-hi); }

/* View profile button */
.ac-btn {
  background: #f1f5f9;
  border: 1px solid var(--c-border);
  color: var(--c-text);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ac-btn:hover { background: #e2e8f0; }

/* Section divider */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}
.section-divider span {
  font-size: 12px;
  color: var(--c-text-3);
  font-weight: 500;
}

/* Search engine buttons */
.search-engines {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.engine-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-m);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background .2s, border-color .2s;
}
.engine-btn:hover {
  background: #f8fafc;
  border-color: var(--c-primary);
}
.engine-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: #f1f5f9;
}
.google-btn .engine-icon { color: #ea4335; }
.yandex-btn .engine-icon { color: #eab308; }
.tineye-btn .engine-icon { color: #3b82f6; }

.engine-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.engine-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
}
.engine-desc {
  font-size: 12px;
  color: var(--c-text-2);
}
.engine-arrow { color: var(--c-text-3); flex-shrink: 0; }

/* ── Footer ──────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 16px 20px 8px;
  margin-top: auto;
}
.user-id {
  font-size: 11px;
  color: var(--c-text-3);
  font-family: monospace;
}

/* ── Scrollbar (global) ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ── Utility ─────────────────────────────────────────────────── */
img { display: block; }

/* ── Safe-area for Telegram ──────────────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .app-header { padding-top: max(18px, env(safe-area-inset-top)); }
  .app-shell  { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}