/* ══════════════════════════════════════════════════════════════════
   history.css  —  Atlas · История поиска
   ══════════════════════════════════════════════════════════════════ */

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

:root {
  --clr-primary:    #6366f1;
  --clr-primary-dk: #4f46e5;
  --clr-accent:     #8b5cf6;
  --clr-text:       #1e1b4b;
  --clr-text-muted: #6b7280;
  --clr-bg-from:    #dde4ff;
  --clr-bg-to:      #f3f0ff;
  --clr-glass:      rgba(255,255,255,0.72);
  --radius-lg: 22px;
  --radius-md: 14px;
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  background: linear-gradient(135deg, var(--clr-bg-from) 0%, var(--clr-bg-to) 100%);
  min-height: 100vh;
}

/* ── Background ─────────────────────────────────────────────────── */
.bg-blobs {
  position: fixed; inset: 0;
  pointer-events: none; overflow: hidden; z-index: 0;
}
.blob { position: absolute; border-radius: 50%; animation: blobFloat 12s ease-in-out infinite alternate; }
.blob-1 { width: 680px; height: 680px; background: radial-gradient(circle at 40% 40%, #818cf8, #4f46e5); filter: blur(100px); opacity: 0.45; top: -180px; left: -160px; animation-duration: 14s; }
.blob-2 { width: 500px; height: 500px; background: radial-gradient(circle at 60% 60%, #c084fc, #7c3aed); filter: blur(100px); opacity: 0.3; bottom: -100px; right: -100px; animation-duration: 11s; animation-delay: -4s; }
.blob-3 { width: 380px; height: 380px; background: radial-gradient(circle at 50% 50%, #67e8f9, #3b82f6); filter: blur(90px); opacity: 0.25; top: 40%; left: 55%; transform: translate(-50%,-50%); animation-duration: 18s; animation-delay: -7s; }
@keyframes blobFloat {
  0%   { transform: translate(0,0) scale(1); }
  33%  { transform: translate(30px,-20px) scale(1.05); }
  66%  { transform: translate(-20px,25px) scale(0.96); }
  100% { transform: translate(15px,10px) scale(1.02); }
}
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(circle, rgba(99,102,241,0.1) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
}

/* ── Main layout ────────────────────────────────────────────────── */
.hist-main {
  position: relative; z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 20px 56px;
  animation: pageIn 0.45s ease both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ─────────────────────────────────────────────────────── */
.hist-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}
.hist-header-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.hist-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-decoration: none;
  transition: color var(--transition), transform var(--transition);
  width: fit-content;
}
.hist-back-btn:hover { color: var(--clr-primary); transform: translateX(-3px); }
.hist-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hist-page-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.15));
  border: 1.5px solid rgba(99,102,241,0.2);
  border-radius: 14px;
  color: #6366f1;
  flex-shrink: 0;
}
.hist-page-title {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--clr-text);
}
.hist-page-sub {
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  margin-top: 2px;
  font-weight: 500;
}
.hist-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Filter input */
.hist-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.hist-search-icon {
  position: absolute; left: 10px;
  color: var(--clr-text-muted);
  pointer-events: none;
}
.hist-filter-input {
  padding: 8px 14px 8px 30px;
  border-radius: 10px;
  border: 1.5px solid rgba(99,102,241,0.2);
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(10px);
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--clr-text);
  outline: none;
  width: 200px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.hist-filter-input::placeholder { color: #bbb; }
.hist-filter-input:focus {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* Clear button */
.hist-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1.5px solid rgba(239,68,68,0.25);
  background: rgba(239,68,68,0.06);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: #dc2626;
  cursor: pointer;
  transition: all 0.2s ease;
}
.hist-clear-btn:hover {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.4);
  transform: translateY(-1px);
}
.hist-clear-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

/* ── Main card ──────────────────────────────────────────────────── */
.hist-card {
  background: rgba(255,255,255,0.68);
  border: 1.5px solid rgba(255,255,255,0.88);
  border-radius: 24px;
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow:
    0 8px 40px rgba(99,102,241,0.1),
    0 2px 8px rgba(0,0,0,0.04),
    inset 0 1px 0 rgba(255,255,255,0.9);
  overflow: hidden;
}

/* Loading */
.hist-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  color: var(--clr-text-muted);
  font-size: 0.88rem;
  font-weight: 500;
}
.hist-spinner {
  width: 22px; height: 22px;
  border: 2.5px solid rgba(99,102,241,0.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty */
.hist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 24px;
  text-align: center;
}
.hist-empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--clr-text);
  opacity: 0.6;
}
.hist-empty-sub {
  font-size: 0.83rem;
  color: var(--clr-text-muted);
  margin-bottom: 8px;
}
.hist-go-search {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--clr-primary);
  text-decoration: none;
  padding: 7px 16px;
  border-radius: 10px;
  background: rgba(99,102,241,0.08);
  border: 1.5px solid rgba(99,102,241,0.2);
  transition: all 0.2s;
}
.hist-go-search:hover {
  background: rgba(99,102,241,0.14);
  transform: translateX(2px);
}

/* ── History list ───────────────────────────────────────────────── */
.hist-list { display: flex; flex-direction: column; }

.hist-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(99,102,241,0.07);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  color: inherit;
  position: relative;
}
.hist-item:last-child { border-bottom: none; }
.hist-item:hover { background: rgba(99,102,241,0.04); }
.hist-item:hover .hist-item-arrow { opacity: 1; transform: translateX(3px); }

.hist-item-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: #d1d5db;
  min-width: 22px;
  text-align: right;
  flex-shrink: 0;
}
.hist-item-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
  background: rgba(99,102,241,0.08);
  color: #6366f1;
}
.hist-item-icon--phone {
  background: rgba(16,185,129,0.08);
  color: #059669;
}
.hist-item-body { flex: 1; min-width: 0; }
.hist-item-query {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--clr-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-item-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
}
.hist-item-date {
  font-size: 0.72rem;
  color: var(--clr-text-muted);
  font-weight: 500;
}
.hist-item-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
}
.hist-item-badge--found {
  background: rgba(99,102,241,0.1);
  color: #4f46e5;
}
.hist-item-badge--zero {
  background: rgba(107,114,128,0.1);
  color: #6b7280;
}
.hist-item-arrow {
  color: #d1d5db;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  flex-shrink: 0;
}

/* ── Pagination ─────────────────────────────────────────────────── */
.hist-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}
.hist-page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9px;
  border: 1.5px solid rgba(99,102,241,0.15);
  background: rgba(255,255,255,0.7);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--clr-text-muted);
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(8px);
}
.hist-page-btn:hover {
  border-color: rgba(99,102,241,0.35);
  color: var(--clr-primary);
  background: rgba(99,102,241,0.06);
}
.hist-page-btn.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}
.hist-page-btn:disabled { opacity: 0.3; cursor: default; }

/* ── Modal ──────────────────────────────────────────────────────── */
.hist-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15,10,40,0.45);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeOverlay 0.2s ease;
}
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }
.hist-modal {
  background: rgba(255,255,255,0.95);
  border: 1.5px solid rgba(255,255,255,0.9);
  border-radius: 22px;
  padding: 32px 28px 28px;
  max-width: 380px; width: 90%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
  animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
  text-align: center;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.9) translateY(10px); } to { opacity: 1; transform: none; } }
.hist-modal-icon {
  width: 56px; height: 56px;
  background: rgba(239,68,68,0.1);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  color: #dc2626;
  margin: 0 auto 16px;
}
.hist-modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--clr-text);
  margin-bottom: 8px;
}
.hist-modal-text {
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}
.hist-modal-btns {
  display: flex;
  gap: 10px;
}
.hist-modal-cancel {
  flex: 1;
  padding: 10px;
  border-radius: 11px;
  border: 1.5px solid rgba(99,102,241,0.2);
  background: rgba(99,102,241,0.06);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--clr-text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.hist-modal-cancel:hover { background: rgba(99,102,241,0.1); }
.hist-modal-confirm {
  flex: 1;
  padding: 10px;
  border-radius: 11px;
  border: none;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(239,68,68,0.35);
  transition: all 0.2s;
}
.hist-modal-confirm:hover {
  box-shadow: 0 6px 20px rgba(239,68,68,0.5);
  transform: translateY(-1px);
}

/* ── Dark mode ──────────────────────────────────────────────────── */
html.dark body {
  background:
    radial-gradient(ellipse at 0% 0%,   #1e1340 0%, transparent 55%),
    radial-gradient(ellipse at 100% 100%, #130d2e 0%, transparent 55%),
    linear-gradient(160deg, #0d0b1a 0%, #110e22 50%, #0e0c1e 100%) !important;
}
html.dark .hist-card {
  background: rgba(14,10,36,0.82) !important;
  border-color: rgba(99,102,241,0.18) !important;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.04) !important;
}
html.dark .hist-page-title { color: #e0e7ff !important; }
html.dark .hist-page-sub { color: #6b6890 !important; }
html.dark .hist-page-icon { background: rgba(99,102,241,0.15) !important; border-color: rgba(99,102,241,0.2) !important; }
html.dark .hist-back-btn { color: #6b6890 !important; }
html.dark .hist-back-btn:hover { color: #a5b4fc !important; }
html.dark .hist-filter-input {
  background: rgba(20,15,50,0.8) !important;
  border-color: rgba(99,102,241,0.22) !important;
  color: #e0e7ff !important;
}
html.dark .hist-clear-btn {
  background: rgba(239,68,68,0.08) !important;
  border-color: rgba(239,68,68,0.2) !important;
}
html.dark .hist-item { border-color: rgba(99,102,241,0.1) !important; }
html.dark .hist-item:hover { background: rgba(99,102,241,0.07) !important; }
html.dark .hist-item-query { color: #e0e7ff !important; }
html.dark .hist-item-num { color: #3a365a !important; }
html.dark .hist-item-icon { background: rgba(99,102,241,0.12) !important; }
html.dark .hist-page-btn {
  background: rgba(20,15,50,0.7) !important;
  border-color: rgba(99,102,241,0.18) !important;
  color: #6b6890 !important;
}
html.dark .hist-modal {
  background: rgba(18,13,42,0.97) !important;
  border-color: rgba(99,102,241,0.2) !important;
}
html.dark .hist-modal-title { color: #e0e7ff !important; }
html.dark .hist-modal-cancel {
  background: rgba(99,102,241,0.1) !important;
  border-color: rgba(99,102,241,0.2) !important;
  color: #9ca3af !important;
}
html.dark .hist-loading { color: #6b6890 !important; }
html.dark .hist-spinner { border-color: rgba(99,102,241,0.2) !important; border-top-color: #6366f1 !important; }
html.dark .hist-empty-title { color: #e0e7ff !important; }
