/* ═══════════════════════════════════════════════
   BlackTube — Industrial Terminal Aesthetic
   Fonts: Syne (UI) + DM Mono (email/code)
   ═══════════════════════════════════════════════ */

:root {
  /* Core palette */
  --bg:        #0a0a0a;
  --bg-1:      #0f0f0f;
  --bg-2:      #161616;
  --bg-3:      #202020;
  --bg-4:      #282828;

  /* Borders */
  --line:      rgba(255,255,255,0.048);
  --line-md:   rgba(255,255,255,0.082);
  --line-lg:   rgba(255,255,255,0.12);

  /* Text */
  --text:      #ebebeb;
  --text-2:    rgba(235,235,235,0.48);
  --text-3:    rgba(235,235,235,0.20);

  /* Accents */
  --accent:    #5b8def;
  --green:     #4ade98;
  --pulse:     rgba(91,141,239,0.5);

  /* Fonts */
  --ui:    'Syne', system-ui, sans-serif;
  --code:  'DM Mono', 'Cascadia Code', ui-monospace, monospace;

  --r:   5px;
  --r2:  9px;
  --pill: 100px;
}

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

html { height: 100%; }

body {
  font-family: var(--ui);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Grain texture overlay ─── */
.grain {
  pointer-events: none;
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: 999;
  opacity: 0.032;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px;
  animation: grain-shift 8s steps(1) infinite;
}
@keyframes grain-shift {
  0%   { transform: translate(0,0); }
  10%  { transform: translate(-5%,-8%); }
  20%  { transform: translate(-12%,4%); }
  30%  { transform: translate(4%,-9%); }
  40%  { transform: translate(-7%,6%); }
  50%  { transform: translate(-11%,3%); }
  60%  { transform: translate(6%,-5%); }
  70%  { transform: translate(-8%,9%); }
  80%  { transform: translate(-4%,7%); }
  90%  { transform: translate(7%,-4%); }
  100% { transform: translate(0,0); }
}

/* ─── App shell ─── */
.app { display: flex; flex-direction: column; height: 100vh; position: relative; z-index: 1; }

/* ═══════════════════════════════════════
   TOP BAR
   ═══════════════════════════════════════ */
.top-bar {
  height: 50px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  flex-shrink: 0;
  position: relative;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 250px;
}

/* Logo — Syne 700, big character */
.logo {
  font-family: var(--ui);
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
}

/* Service Switch */
.service-switch {
  display: flex;
  background: rgba(255,255,255,0.03);
  padding: 3px;
  border-radius: var(--pill);
  border: 1px solid var(--line-md);
}

.svc-btn {
  background: transparent;
  border: none;
  color: var(--text-3);
  padding: 4px 12px;
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--pill);
  cursor: pointer;
  transition: all 0.2s ease;
}

.svc-btn.active {
  background: rgba(255,255,255,0.1);
  color: var(--text-1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ─── Tabs (Syne, centered) ─── */
.tabs-wrap { flex: 1; display: flex; align-items: center; justify-content: center; }
.tabs {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 3px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: var(--r2);
}
.tab {
  background: transparent;
  border: none;
  color: var(--text-3);
  padding: 0 14px;
  height: 28px;
  cursor: pointer;
  font-family: var(--ui);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  gap: 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.tab:hover { color: var(--text-2); background: rgba(255,255,255,0.02); }
.tab.active {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}
.tab-count {
  font-family: var(--code);
  font-size: 10px;
  font-weight: 400;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.tab.active .tab-count { color: var(--text-2); }

/* ─── Scan counter badge ─── */
.scan-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--code);
  font-size: 11px;
  color: var(--accent);
  padding: 0 10px;
  height: 26px;
  border: 1px solid rgba(91,141,239,0.2);
  border-radius: var(--pill);
  background: rgba(91,141,239,0.05);
  white-space: nowrap;
}
.scan-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ─── Top-right actions ─── */
.top-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 32px;
}

.btn-check {
  height: 28px;
  padding: 0 12px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--line-md);
  border-radius: var(--r);
  font-family: var(--ui);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.btn-check:hover { background: rgba(255,255,255,0.04); color: var(--text); border-color: var(--line-lg); }
.btn-check:disabled { opacity: 0.25; cursor: wait; }

.search-group { display: flex; align-items: center; }
.btn-icon {
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid var(--line-md);
  border-radius: var(--r);
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  z-index: 2;
  position: relative;
}
.btn-icon:hover { color: var(--text-2); background: rgba(255,255,255,0.04); border-color: var(--line-lg); }

.search-input {
  width: 0;
  height: 28px;
  background: var(--bg-2);
  border: 1px solid var(--line-md);
  border-left: none;
  border-radius: 0 var(--r) var(--r) 0;
  color: var(--text);
  font-family: var(--code);
  font-size: 11.5px;
  padding: 0;
  outline: none;
  overflow: hidden;
  transition: width 0.22s ease, padding 0.22s ease;
}
.search-input.visible { width: 160px; padding: 0 10px; }
.search-input::placeholder { color: var(--text-3); }

.btn-add {
  width: 28px; height: 28px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--line-md);
  border-radius: var(--r);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
}
.btn-add:hover { background: rgba(255,255,255,0.04); color: var(--text); border-color: var(--line-lg); }

/* ═══════════════════════════════════════
   CONTENT AREA
   ═══════════════════════════════════════ */
.content { flex: 1; overflow-y: auto; background: var(--bg); }
.content::-webkit-scrollbar { width: 2px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }

.loading { display: flex; align-items: center; justify-content: center; height: 220px; }

/* ═══════════════════════════════════════
   ACCOUNT ROW — core component
   ═══════════════════════════════════════ */
.account-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  padding: 0 22px;
  height: 50px;
  border-bottom: 1px solid var(--line);
  gap: 16px;
  /* Entry animation */
  opacity: 0;
  transform: translateY(6px);
  transition: background 0.12s;
}
.account-row.visible {
  animation: row-in 0.3s ease forwards;
}
@keyframes row-in {
  to { opacity: 1; transform: translateY(0); }
}
.account-row:hover { background: rgba(255,255,255,0.014); }

/* Defective row — subtle red tint */
.account-row.defective {
  opacity: 0.55;
}
.account-row.defective:hover {
  background: rgba(255, 80, 80, 0.04);
  opacity: 0.75;
}

/* Брак button — red tone on hover */
.btn-defect {
  color: rgba(255, 100, 100, 0.4) !important;
}
.btn-defect:hover {
  color: rgba(255, 100, 100, 0.85) !important;
  background: rgba(255, 80, 80, 0.08) !important;
  border-color: rgba(255, 80, 80, 0.2) !important;
}

/* Email — DM Mono, crisp white */
.row-email {
  font-family: var(--code);
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
  transition: opacity 0.15s;
}
.row-email:hover { opacity: 0.55; }
.row-email.muted { color: var(--text-3); font-weight: 300; }

/* Scanning pill — matches reference */
.row-scanning {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 13px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--pill);
  font-family: var(--ui);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.scan-spinner {
  width: 10px; height: 10px;
  border: 1.5px solid rgba(255,255,255,0.1);
  border-top-color: var(--text-2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* Code badge */
.row-code {
  font-family: var(--code);
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.06em;
  padding: 0 13px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 88px;
}
.row-code.copyable {
  background: var(--bg-3);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.row-code.copyable:hover {
  background: var(--bg-4);
  border-color: var(--line-md);
  transform: scale(1.02);
}
.row-code.copyable:active { transform: scale(0.97); }

/* Code found — flash green then settle */
.row-code.has-code {
  color: var(--green);
  background: rgba(74,222,152,0.06);
  border-color: rgba(74,222,152,0.15);
  animation: code-appear 0.4s ease;
}
@keyframes code-appear {
  0% { background: rgba(74,222,152,0.2); transform: scale(1.04); }
  100% { background: rgba(74,222,152,0.06); transform: scale(1); }
}

.row-code.no-code {
  color: var(--text-3);
  font-family: var(--code);
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 0.14em;
  background: transparent;
  border: none;
  cursor: default;
  min-width: auto;
}

/* Time */
.row-time {
  font-family: var(--code);
  font-size: 11px;
  font-weight: 300;
  color: var(--text-2);
  white-space: nowrap;
  min-width: 85px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* Row buttons */
.row-actions { display: flex; gap: 3px; }
.row-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-3);
  width: 26px; height: 26px;
  border-radius: var(--r);
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  font-family: var(--ui);
}
.row-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--line-md);
  color: var(--text-2);
  transform: scale(1.08);
}

/* Empty state */
.empty-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 260px;
  color: var(--text-3);
  font-family: var(--code);
  font-size: 12px;
  font-weight: 300;
  letter-spacing: 0.04em;
  gap: 8px;
}
.empty-msg::before {
  content: '∅';
  font-size: 28px;
  opacity: 0.2;
}

/* ═══════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spinner {
  to { transform: rotate(360deg); }
}

/* ChatGPT Background Watermark */
.chatgpt-bg {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50vh;
  height: 50vh;
  background: url('openai-logo.png') center/contain no-repeat;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.5s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  transform: translate(-50%, -50%) scale(0.9);
}

body.chatgpt-mode .chatgpt-bg {
  opacity: 0.03; /* Very subtle */
  transform: translate(-50%, -50%) scale(1);
}

/* Push content above background */
.app {
  position: relative;
  z-index: 1;
}

/* ═══════════════════════════════════════
   TOAST — with slide + fade
   ═══════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  background: var(--bg-2);
  border: 1px solid var(--line-md);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--r);
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  opacity: 0;
  transition: opacity 0.22s, transform 0.22s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ═══════════════════════════════════════
   MODAL
   ═══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: overlay-in 0.2s ease;
}
@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--line-md);
  border-radius: var(--r2);
  width: 440px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03),
    0 32px 80px rgba(0,0,0,0.9);
  animation: modal-in 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}


.modal-header h3 {
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r);
  transition: all 0.12s;
}
.modal-close:hover { color: var(--text-2); background: rgba(255,255,255,0.05); }

.modal-body { padding: 16px 20px; }
.modal-body p {
  font-family: var(--ui);
  color: var(--text-3);
  font-size: 12px;
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}
.modal-hint { margin-top: 10px !important; margin-bottom: 0 !important; font-size: 11px !important; }

.modal-body textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
  font-family: var(--code);
  font-size: 11.5px;
  font-weight: 300;
  line-height: 1.7;
  resize: vertical;
  min-height: 120px;
  outline: none;
  transition: border-color 0.15s;
}
.modal-body textarea:focus { border-color: var(--line-lg); }
.modal-body textarea::placeholder { color: var(--text-3); }

.modal-footer { padding: 14px 20px; border-top: 1px solid var(--line); }
.btn-primary {
  width: 100%;
  height: 36px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--r);
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.12s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:active { transform: scale(0.98); }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 1.5px solid rgba(255,255,255,0.06);
  border-top-color: var(--text-2);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
