/* ============================================================
   VIEW INSIGHTS PRO — style.css v3.3
   Mobile-first. Bottom sheet on phones, centered modal on
   tablet/desktop. Dark glassmorphism theme.
   ============================================================ */

/* ---- RESET & TOKENS ---------------------------------------- */
.vip-button-wrap *,
.vip-overlay * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --vip-bg:         #0f1428;
  --vip-surface:    #16213e;
  --vip-surface2:   #1a2547;
  --vip-surface3:   #1e2d56;
  --vip-accent:     #4bc0c0;
  --vip-accent2:    #36a2eb;
  --vip-text:       #e8eaf6;
  --vip-muted:      rgba(232,234,246,.55);
  --vip-border:     rgba(75,192,192,.18);
  --vip-border2:    rgba(255,255,255,.07);
  --vip-radius:     16px;
  --vip-radius-sm:  10px;
  --vip-radius-xs:  6px;
  --vip-transition: 0.22s cubic-bezier(.16,1,.3,1);
  --vip-font:       -apple-system,'Segoe UI',Helvetica,Arial,sans-serif;
  --vip-font-ku:    'Noto Sans Arabic','Segoe UI',sans-serif;
}

/* ============================================================
   BUTTON
   ============================================================ */
.vip-button-wrap {
  display: flex;
  justify-content: center;
  margin: 24px 0;
  font-family: var(--vip-font);
}

.vip-insights-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--vip-surface) 0%, var(--vip-surface2) 100%);
  border: 1px solid var(--vip-border);
  border-radius: 50px;
  color: var(--vip-text);
  font-family: var(--vip-font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform var(--vip-transition), box-shadow var(--vip-transition), border-color var(--vip-transition);
  min-height: 48px;
  -webkit-user-select: none;
  user-select: none;
}
.vip-insights-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(75,192,192,.08) 0%, rgba(54,162,235,.08) 100%);
  opacity: 0;
  transition: opacity var(--vip-transition);
}
.vip-insights-btn:hover::before,
.vip-insights-btn:focus-visible::before { opacity: 1; }
.vip-insights-btn:hover,
.vip-insights-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(75,192,192,.25);
  border-color: rgba(75,192,192,.45);
  outline: none;
}
.vip-insights-btn:active { transform: translateY(0); }

/* Button icon */
.vip-btn-icon {
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.vip-chart-icon,
.vip-eye-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: opacity .4s, transform .4s;
}
.vip-eye-icon { opacity: 0; transform: scale(.7); }
.vip-insights-btn:hover .vip-chart-icon { opacity: 0; transform: scale(.7); }
.vip-insights-btn:hover .vip-eye-icon   { opacity: 1; transform: scale(1);  }

/* Pulse dot */
.vip-pulse-dot {
  position: absolute;
  top: 2px; right: 2px;
  width: 7px; height: 7px;
  background: #4bc0c0;
  border-radius: 50%;
}
.vip-pulse-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid #4bc0c0;
  animation: vip-pulse 2s ease-out infinite;
}
@keyframes vip-pulse {
  0%   { opacity: .9; transform: scale(1);   }
  100% { opacity: 0;  transform: scale(2.2); }
}

/* Button text */
.vip-btn-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.vip-btn-ku {
  display: none;
  direction: rtl;
  font-family: var(--vip-font-ku);
  font-size: 12px;
  color: var(--vip-muted);
}

/* Button count badge */
.vip-btn-count {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 3px 8px;
  background: rgba(75,192,192,.13);
  border: 1px solid rgba(75,192,192,.22);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--vip-accent);
  line-height: 1.35;
  white-space: nowrap;
}
.vip-count-ku {
  display: none;
  direction: rtl;
  font-family: var(--vip-font-ku);
  color: var(--vip-muted);
  font-size: 10px;
}

/* ============================================================
   OVERLAY BACKDROP
   ============================================================ */
.vip-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(5,8,20,.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;          /* bottom-sheet on mobile */
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .32s ease;
  font-family: var(--vip-font);
}
.vip-overlay[hidden] { display: none !important; }
.vip-overlay.vip-open {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   MODAL — MOBILE (bottom sheet)
   ============================================================ */
.vip-modal {
  width: 100%;
  max-height: 92dvh;
  max-height: 92vh;
  background: var(--vip-surface);
  border-radius: var(--vip-radius) var(--vip-radius) 0 0;
  border: 1px solid var(--vip-border);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(100%);
  transition: transform .38s cubic-bezier(.16,1,.3,1);
  will-change: transform;
  position: relative;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.vip-overlay.vip-open .vip-modal {
  transform: translateY(0);
}

/* Drag handle */
.vip-drag-handle {
  width: 44px;
  height: 4px;
  background: rgba(255,255,255,.18);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

/* ============================================================
   MODAL HEADER
   ============================================================ */
.vip-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--vip-border2);
  flex-shrink: 0;
}
.vip-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.vip-modal-icon { font-size: 20px; flex-shrink: 0; }
.vip-modal-heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--vip-text);
  line-height: 1.2;
}
.vip-modal-subtitle {
  font-size: 11px;
  color: var(--vip-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}
.vip-close-btn {
  width: 36px; height: 36px;
  min-width: 36px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--vip-border2);
  border-radius: 50%;
  color: var(--vip-muted);
  font-size: 14px;
  cursor: pointer;
  transition: background var(--vip-transition), color var(--vip-transition);
  flex-shrink: 0;
}
.vip-close-btn:hover,
.vip-close-btn:focus-visible {
  background: rgba(255,255,255,.12);
  color: var(--vip-text);
  outline: 2px solid var(--vip-accent);
  outline-offset: 2px;
}

/* ============================================================
   MODAL BODY — scrollable
   ============================================================ */
.vip-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 16px 20px;
}
.vip-modal-body::-webkit-scrollbar { width: 4px; }
.vip-modal-body::-webkit-scrollbar-track { background: transparent; }
.vip-modal-body::-webkit-scrollbar-thumb {
  background: rgba(75,192,192,.3);
  border-radius: 2px;
}

/* ============================================================
   LOADING
   ============================================================ */
.vip-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 20px;
  color: var(--vip-muted);
  font-size: 13px;
}
.vip-spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(75,192,192,.15);
  border-top-color: var(--vip-accent);
  border-radius: 50%;
  animation: vip-spin .8s linear infinite;
}
@keyframes vip-spin { to { transform: rotate(360deg); } }

/* ============================================================
   BILINGUAL — language spans
   ============================================================ */
.vip-lang-en { display: block; }
.vip-lang-ku {
  display: none;
  direction: rtl;
  font-family: var(--vip-font-ku);
}

/* ============================================================
   KPI STRIP
   ============================================================ */
.vip-kpi-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.vip-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px 12px;
  background: var(--vip-surface2);
  border: 1px solid var(--vip-border2);
  border-radius: var(--vip-radius-sm);
  text-align: center;
}
.vip-kpi-icon { font-size: 18px; }
.vip-kpi-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--vip-accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -.01em;
}
.vip-kpi-date { font-size: 11px; }
.vip-kpi-lbl {
  font-size: 10px;
  color: var(--vip-muted);
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.vip-kpi-lbl .vip-lang-ku {
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
}

/* ============================================================
   CHARTS ROW — stacked on mobile
   ============================================================ */
.vip-charts-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}
.vip-chart-box {
  background: var(--vip-surface2);
  border: 1px solid var(--vip-border2);
  border-radius: var(--vip-radius-sm);
  padding: 14px 14px 12px;
}
.vip-chart-full { margin-bottom: 12px; }
.vip-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--vip-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 12px;
}
.vip-chart-title .vip-lang-ku {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
}
.vip-chart-box canvas {
  max-height: 200px;
  width: 100% !important;
}
.vip-chart-full canvas { max-height: 160px; }

/* ============================================================
   TOP CITIES
   ============================================================ */
.vip-cities-section { margin-bottom: 4px; }
.vip-cities-table { display: flex; flex-direction: column; gap: 8px; }
.vip-city-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--vip-surface2);
  border: 1px solid var(--vip-border2);
  border-radius: var(--vip-radius-xs);
}
.vip-city-name {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.vip-city-name > span { font-size: 13px; flex-shrink: 0; margin-top: 1px; }
.vip-city-name-inner { flex: 1; min-width: 0; }
.vip-city-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--vip-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vip-city-pct {
  display: block;
  font-size: 10px;
  color: var(--vip-muted);
  margin-top: 1px;
  white-space: nowrap;
}
/* Progress bar */
.vip-city-bar-wrap {
  margin-top: 5px;
  height: 3px;
  background: rgba(255,255,255,.07);
  border-radius: 2px;
  overflow: hidden;
}
.vip-city-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--vip-accent), var(--vip-accent2));
  border-radius: 2px;
  transition: width .7s cubic-bezier(.16,1,.3,1);
}
.vip-city-count {
  font-size: 14px;
  font-weight: 700;
  color: var(--vip-accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================================
   MODAL FOOTER
   ============================================================ */
.vip-modal-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--vip-border2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.vip-modal-footer p {
  font-size: 10px;
  color: var(--vip-muted);
  line-height: 1.5;
}
.vip-data-note { opacity: .7; font-style: italic; }

/* ============================================================
   TABLET (≥ 600px) — side-by-side charts
   ============================================================ */
@media (min-width: 600px) {
  .vip-charts-row { flex-direction: row; }
  .vip-charts-row .vip-chart-box { flex: 1 1 0; min-width: 0; }
  .vip-kpi-strip { grid-template-columns: repeat(4, 1fr); }
  .vip-chart-box canvas { max-height: 220px; }
  .vip-chart-full canvas { max-height: 180px; }
  .vip-modal-footer { flex-direction: row; justify-content: space-between; align-items: flex-start; }
}

/* ============================================================
   DESKTOP (≥ 768px) — centered modal, not bottom sheet
   ============================================================ */
@media (min-width: 768px) {
  .vip-overlay { align-items: center; }
  .vip-modal {
    width: 90%;
    max-width: 820px;
    max-height: 88vh;
    border-radius: var(--vip-radius);
    border: 1px solid var(--vip-border);
    transform: translateY(24px) scale(.97);
    transition: transform .35s cubic-bezier(.16,1,.3,1), opacity .25s ease;
    opacity: 0;
    padding-bottom: 0;
  }
  .vip-overlay.vip-open .vip-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  .vip-drag-handle { display: none; }
  .vip-modal-header { padding: 18px 22px 16px; }
  .vip-modal-body   { padding: 20px 22px 24px; }
  .vip-modal-heading { font-size: 17px; }
  .vip-modal-subtitle { max-width: 400px; font-size: 12px; }
  .vip-close-btn { width: 38px; height: 38px; }
  .vip-kpi-val { font-size: 22px; }
  .vip-chart-box canvas { max-height: 240px; }
  .vip-chart-full canvas { max-height: 200px; }
  .vip-city-label { font-size: 14px; }
  .vip-city-count { font-size: 15px; }
}

/* ============================================================
   LARGE DESKTOP (≥ 1024px)
   ============================================================ */
@media (min-width: 1024px) {
  .vip-modal { max-width: 900px; max-height: 85vh; }
  .vip-kpi-val { font-size: 24px; }
  .vip-chart-box canvas { max-height: 260px; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .vip-modal,
  .vip-overlay,
  .vip-spinner,
  .vip-city-bar,
  .vip-pulse-dot::after,
  .vip-insights-btn { animation: none !important; transition: none !important; }
  .vip-overlay.vip-open .vip-modal { transform: none; opacity: 1; }
}

/* ============================================================
   HOVER — only real pointer devices
   ============================================================ */
@media (hover: none) {
  .vip-insights-btn:hover { transform: none; box-shadow: none; }
  .vip-insights-btn:active { transform: scale(.97); }
}
