/* ══════════════════════════════════════════════════════
   SMM Intelligence · Dashboard Design System v2
   Dark Analytics · ui-ux-pro-max guidelines
   ══════════════════════════════════════════════════════ */

/* ─── DESIGN TOKENS ─── */
:root {
  /* Backgrounds — layered depth */
  --bg:     #07090f;
  --panel:  #0c1018;
  --panel2: #101520;
  --panel3: #141a26;
  --panel4: #1a2130;

  /* Borders */
  --border:  rgba(255,255,255,0.09);
  --border2: rgba(255,255,255,0.18);

  /* Accent palette — more vivid */
  --green:  #34d399;   /* emerald-400 */
  --blue:   #60a5fa;   /* blue-400    */
  --purple: #a78bfa;   /* violet-400  */
  --orange: #fb923c;   /* orange-400  */
  --gold:   #fbbf24;   /* amber-400   */
  --red:    #f87171;   /* red-400     */
  --pink:   #f472b6;   /* pink-400    */
  --cyan:   #22d3ee;   /* cyan-400    */

  /* Text */
  --text:   #e8edf5;
  --muted:  rgba(148,163,184,0.80);   /* slate-400 */

  /* Typography scale */
  --fs-xs:  11px;
  --fs-sm:  13px;
  --fs-md:  15px;
  --fs-lg:  18px;
  --fs-xl:  22px;
  --fs-kpi: 34px;

  /* Radius */
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   18px;
  --r-pill: 100px;
}

/* ─── BASE ─── */
body {
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ─── HEADER ─── */
header {
  height: 62px;
  padding: 0 32px;
  background: rgba(7,9,15,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.h-logo {
  font-size: 18px;
  letter-spacing: 0.5px;
  color: var(--text);
}

.h-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.h-time {
  font-size: 12px;
}

.btn-sm {
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border2);
  transition: all 0.18s ease;
}

.btn-sm:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  transform: translateY(-1px);
}

/* ─── SECTION LABEL ─── */
.section-label {
  font-size: var(--fs-xs);
  letter-spacing: 1.8px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ─── KPI CARDS ─── */
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 22px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.kpi:hover {
  border-color: var(--border2);
  box-shadow: 0 4px 32px rgba(0,0,0,0.35);
}

.kpi::before {
  height: 3px;
  border-radius: 0 0 3px 3px;
}

/* Glow under accent line */
.kpi::after {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: var(--kcolor, var(--green));
  filter: blur(6px);
  opacity: 0.5;
}

.kpi-lbl {
  font-size: var(--fs-xs);
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 10px;
}

.kpi-val {
  font-size: var(--fs-kpi);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-sub {
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.5;
}

.kpi-delta {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  margin-top: 8px;
}

.delta-up {
  background: rgba(52,211,153,0.12);
  color: var(--green);
  border: 1px solid rgba(52,211,153,0.2);
}

.delta-down {
  background: rgba(248,113,113,0.12);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.2);
}

.delta-neutral {
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ─── CARDS ─── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--border2);
}

.card-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.3;
}

.card-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

.card-body {
  padding: 22px;
}

/* ─── TABLES ─── */
.ctable th {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 11px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

.ctable td {
  font-size: 13.5px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
}

.ctable tr:hover td {
  background: rgba(255,255,255,0.025);
}

.val, .val-cell {
  font-size: 14px;
  font-weight: 600;
}

/* ─── AI CARD ─── */
.ai-head {
  padding: 20px 26px;
}

.ai-out {
  font-size: 14.5px;
  line-height: 1.85;
  padding: 26px;
}

.ai-run {
  font-size: 13.5px;
  padding: 11px 24px;
  border-radius: var(--r-md);
  letter-spacing: 0.01em;
}

/* ─── POSTS ─── */
.post-text {
  font-size: 13px;
  line-height: 1.65;
  color: rgba(232,237,245,0.78);
}

.post-stat {
  font-size: 11.5px;
}

.post-date {
  font-size: 11px;
}

/* ─── COMMENT ─── */
.comment-item {
  font-size: 13px;
  line-height: 1.65;
  padding: 13px 16px;
  border-radius: var(--r-md);
}

.comment-group {
  font-size: 10.5px;
}

/* ─── COMPETITOR CARDS ─── */
.comp-name {
  font-size: 16px;
  font-weight: 700;
}

.comp-handle {
  font-size: 12px;
}

.comp-metric-val {
  font-size: 20px;
  font-weight: 700;
}

.comp-metric-lbl {
  font-size: 10px;
  letter-spacing: 1px;
}

/* ─── LIVE BADGE ─── */
.live-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 11px;
  letter-spacing: 0.8px;
}

/* ─── PLAT BADGES ─── */
.plat-badge {
  font-size: 11px;
  padding: 3px 10px;
}

/* ─── SPLIT CARD ─── */
.split-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.split-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

/* ─── TABS ─── */
.tab-btn {
  font-size: 13px;
  padding: 8px 16px;
}

.tab-btn.active {
  color: var(--text);
  font-weight: 600;
}

/* ─── HEATMAP ─── */
.hm-cell {
  height: 24px;
  border-radius: 4px;
}

.hm-label {
  font-size: 10px;
  height: 24px;
}

.hm-hour {
  font-size: 9.5px;
  height: 24px;
}

/* ─── CHART OVERRIDES — applied via JS defaulting ─── */
/* Chart.js global defaults are set inline in pages,    */
/* but we add canvas styling tweaks here                */
canvas {
  border-radius: 4px;
}

/* ─── SKELETON ─── */
.sk {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: shim 1.5s infinite ease-in-out;
  border-radius: 6px;
}

@keyframes shim {
  0%   { background-position: 200% 0 }
  100% { background-position: -200% 0 }
}

/* ─── TOOLTIP (Виральные) ─── */
.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  isolation: isolate;
}
/* Тултип выходит за overflow родителя */
.tooltip-wrap:hover {
  overflow: visible;
  z-index: 10000;
}

.tooltip-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--border2);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  color: var(--muted);
  margin-left: 6px;
  transition: all 0.15s;
}

.tooltip-icon:hover {
  background: rgba(255,255,255,0.18);
  color: var(--text);
}

.tooltip-box {
  display: none;
  position: absolute;
  /* Открывается вверх, прижат к правому краю иконки */
  bottom: calc(100% + 8px);
  right: 0;
  left: auto;
  transform: none;
  background: #141a26;
  border: 1px solid rgba(96,165,250,0.28);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  width: 240px;
  white-space: normal;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0,0,0,0.55);
  /* Стрелка снизу-справа */
  pointer-events: none;
}

.tooltip-box::before {
  content: '';
  position: absolute;
  bottom: -5px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: #141a26;
  border-right: 1px solid rgba(96,165,250,0.28);
  border-bottom: 1px solid rgba(96,165,250,0.28);
  transform: rotate(45deg);
}

.tooltip-wrap:hover .tooltip-box {
  display: block;
}

/* ─── LINKS ─── */
a.post-link {
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  transition: all 0.15s;
  white-space: nowrap;
}

a.post-link:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
  border-color: var(--border2);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1200px) {
  :root { --fs-kpi: 28px }
  .kpi { padding: 18px 18px 14px }
}

@media (max-width: 768px) {
  :root { --fs-kpi: 26px }
  header { padding: 0 18px; height: 56px }
  .wrap  { padding: 16px 14px 50px }
  .card-head  { padding: 14px 16px }
  .card-body  { padding: 16px }
  .ctable td  { font-size: 12.5px; padding: 10px 12px }
}

/* ─── PERIOD FILTER ─── */
.period-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 4px;
  width: fit-content;
  margin-bottom: 20px;
}

.period-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

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

.period-btn.active {
  background: rgba(255,255,255,0.10);
  color: var(--text);
  font-weight: 600;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar       { width: 6px; height: 6px }
::-webkit-scrollbar-track { background: transparent }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22) }

/* ─── SELECTION ─── */
::selection {
  background: rgba(96,165,250,0.25);
  color: var(--text);
}
