/* components.css — ღილაკები, badge-ები, ძიება, progress, toast, მდგომარეობები, skeleton */

/* ── ღილაკები ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 28px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(180deg, var(--c-accent-soft) 0%, var(--c-accent-soft-2) 100%);
  color: var(--c-on-accent);
  box-shadow: 0 10px 28px rgba(122, 156, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-ghost {
  padding: 0 22px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--c-text);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.btn-ghost:hover { background: rgba(20, 26, 38, 0.7); }
.btn-ghost[aria-disabled="true"] { border-color: rgba(173, 196, 255, 0.55); color: var(--c-accent-soft); cursor: default; }
.btn[aria-busy="true"] { opacity: 0.7; cursor: progress; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--c-text);
  transition: background-color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); }

/* ── Badge-ები ────────────────────────────────────────────── */
.badge {
  position: absolute;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  color: #fff;
  pointer-events: none;
}
.badge-trending {
  top: 8px;
  left: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: rgba(8, 11, 17, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: var(--fs-xs);
  font-weight: 500;
}
/* ახალი ეპიზოდი: „S2 E5“ პოსტერის ზედა კუთხეში (აქცენტის ფერით — თვალში მოსახვედრი, მაგრამ მშვიდი) */
.badge-episode {
  top: 8px;
  left: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-pill);
  background: rgba(122, 156, 255, 0.92);
  color: var(--c-on-accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.badge-quality {
  right: 6px;
  bottom: 6px;
  padding: 3px 5px;
  border-radius: var(--radius-xs);
  background: rgba(8, 11, 17, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
/* „ქართულად“: GEO — გახმოვანება (ღია), GEO SUB — სუბტიტრები (კონტური) */
.badge-geo {
  left: 6px;
  bottom: 6px;
  padding: 3px 6px;
  border-radius: var(--radius-xs);
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.badge-geo--dub { background: linear-gradient(135deg, #ff5a5f, #e0303a); color: #fff; }
.badge-geo--sub { background: rgba(8, 11, 17, 0.8); border: 1px solid rgba(255, 110, 110, 0.75); color: #ffd6d6; }

/* ── ძიების ველი + შემოთავაზებები ─────────────────────────── */
.search-box { position: relative; }
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  background: var(--c-glass);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.search-field:focus-within { border-color: rgba(173, 196, 255, 0.55); background: var(--c-glass-strong); }
.search-field .icon { color: var(--c-text-2); }
.search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  font-size: var(--fs-sm);
  color: var(--c-text);
  outline: none;
}
.search-input::placeholder { color: var(--c-text-2); opacity: 1; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-field:has(.search-input:focus-visible) { outline: 2px solid var(--c-focus); outline-offset: 2px; }

.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--radius-lg);
  background: var(--c-surface);
  border: 1px solid var(--c-line-strong);
  box-shadow: var(--shadow-pop);
}
.search-option {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.search-option[aria-selected="true"], .search-option:hover { background: var(--c-surface-2); }
.search-thumb {
  width: 36px;
  aspect-ratio: 2 / 3;
  border-radius: 5px;
  overflow: hidden;
  background: var(--c-surface-3);
}
.search-thumb img { width: 100%; height: 100%; object-fit: cover; }
.search-option-title { display: block; font-size: var(--fs-sm); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-option-meta { display: block; font-size: var(--fs-xs); color: var(--c-text-3); }
.search-empty { padding: 14px 10px; font-size: var(--fs-sm); color: var(--c-text-2); }

.search-overlay .search-suggestions { max-height: calc(100dvh - 120px); }

/* ── Progress ─────────────────────────────────────────────── */
.progress {
  display: block;
  width: 100%;
  height: 3px;
  border: 0;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.22);
  -webkit-appearance: none;
  appearance: none;
}
.progress::-webkit-progress-bar { background: rgba(255, 255, 255, 0.22); border-radius: var(--radius-pill); }
.progress::-webkit-progress-value { background: var(--c-accent-soft-2); border-radius: var(--radius-pill); }
.progress::-moz-progress-bar { background: var(--c-accent-soft-2); border-radius: var(--radius-pill); }

/* ── Toast ────────────────────────────────────────────────── */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 120;
  display: grid;
  gap: 8px;
  width: min(92vw, 420px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--c-surface-3);
  border: 1px solid var(--c-line-strong);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  color: var(--c-text);
  animation: toast-in var(--dur) var(--ease);
}
.toast--success { border-color: rgba(62, 207, 142, 0.45); }
.toast--error { border-color: rgba(255, 59, 79, 0.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
/* ღილაკიანი შეტყობინება („დაბრუნება“) + დარჩენილი დროის ზოლი */
.toast--action {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  overflow: hidden;
  pointer-events: auto;
}
.toast-text { flex: 1; min-width: 0; }
.toast-action {
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: rgba(61, 126, 255, 0.16);
  color: var(--c-accent-soft);
  font-weight: 600;
  transition: background-color var(--dur-fast) var(--ease);
}
.toast-action:hover { background: rgba(61, 126, 255, 0.28); }
.toast-timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--c-accent);
  transform-origin: left center;
  animation: toast-timer var(--toast-duration, 8000ms) linear forwards;
}
@keyframes toast-timer { to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .toast-timer { animation: none; opacity: 0.5; }
}
.btn-link { color: var(--c-accent-soft); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { color: #fff; }
.chip-count { margin-left: 6px; padding: 0 6px; border-radius: var(--radius-pill); background: rgba(255, 255, 255, 0.1); font-size: var(--fs-2xs); font-variant-numeric: tabular-nums; }
.chip--toggle[aria-pressed="true"] .chip-count { background: rgba(8, 11, 17, 0.14); }

@media (max-width: 899px) {
  .toast-region { bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 14px); }
}

/* ── მდგომარეობები: შეცდომა / ცარიელი / 404 ────────────────── */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 440px;
  margin: 24px auto;
  padding: 32px var(--gutter);
  text-align: center;
}
.state .icon { color: var(--c-text-3); }
.state-title { font-size: var(--fs-lg); font-weight: 600; }
.state-body { color: var(--c-text-2); font-size: var(--fs-sm); }
/* დიაგნოსტიკის კოდი: „კოდი: DATABASE_AUTH · 500 · 3f2a9c1e“ — შესამჩნევი, მაგრამ მეორეხარისხოვანი */
.state-code {
  max-width: 100%;
  padding: 4px 12px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  color: var(--c-text-3);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}
.state-code code {
  color: var(--c-text-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  user-select: all;
}
.state .btn { margin-top: 8px; min-height: 44px; }
.state--page {
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}
.state-mark { width: 56px; height: 56px; margin-bottom: 8px; }

/* ── Skeleton ─────────────────────────────────────────────── */
.sk {
  display: block;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--c-surface) 0%, var(--c-surface-2) 40%, var(--c-surface) 80%);
  background-size: 300% 100%;
  animation: sk-shimmer 1.6s ease-in-out infinite;
}
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* ── ჩიპი (ჟანრები, სეზონები) ─────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  flex: none;
  min-height: 36px;
  padding: 0 15px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--c-line-strong);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-text);
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
a.chip:hover,
.chip--toggle:hover { background: rgba(255, 255, 255, 0.14); }
.chip--toggle[aria-pressed="true"] { background: var(--c-text); color: var(--c-bg); border-color: transparent; }

.icon-flip { transform: scaleX(-1); }

/* ── ფანჯრები: დადასტურება და ფორმები (<dialog>) ─────────── */
.confirm-dialog,
.app-dialog {
  width: min(420px, 92vw);
  padding: 0;
  border-radius: var(--radius-xl);
  border: 1px solid var(--c-line-strong);
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow-pop);
}
.app-dialog { width: min(480px, 94vw); max-height: min(640px, 90dvh); }
.confirm-dialog::backdrop,
.app-dialog::backdrop { background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(4px); }
.confirm-body,
.app-dialog-body { display: grid; gap: 18px; padding: 24px; }
.confirm-text { font-size: var(--fs-md); line-height: 1.55; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.app-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -6px -8px 0 0; }
.app-dialog-title { font-size: var(--fs-xl); font-weight: 600; }

/* ── „რა ვუყურო?“ ─────────────────────────────────────────── */
.random-dialog { width: min(560px, 94vw); max-height: min(760px, 92dvh); overflow-y: auto; overscroll-behavior: contain; }
.random-heading { display: inline-flex; align-items: center; gap: 10px; }
.random-heading .icon { color: var(--c-accent-soft); }
.random-step { display: grid; gap: 18px; }
.random-step[hidden] { display: none; }
.random-lead { margin-top: -8px; color: var(--c-text-2); font-size: var(--fs-sm); line-height: 1.55; }
.random-filters { display: grid; gap: 16px; }
.random-group { display: grid; gap: 8px; }
.random-group[data-disabled] { opacity: 0.5; }
.random-legend { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.02em; color: var(--c-text-3); text-transform: uppercase; }
.random-segmented { width: 100%; }
.random-segmented .segmented-item { flex: 1 1 0; padding: 0 10px; }
.random-segmented .segmented-item:disabled { cursor: not-allowed; }
.random-note { font-size: var(--fs-xs); color: var(--c-text-3); line-height: 1.5; }
.random-go { width: 100%; }
.random-go[aria-busy="true"] .icon,
[data-random-again][aria-busy="true"] .icon { animation: random-roll 0.7s var(--ease) infinite; }
@keyframes random-roll { to { transform: rotate(360deg); } }

.random-card {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-line-strong);
  background: var(--c-surface-2);
  overflow: hidden;
  isolation: isolate;
  animation: random-in 0.45s var(--ease) both;
}
@keyframes random-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } }
.random-card-media { position: absolute; inset: 0 0 auto; height: 190px; z-index: -1; }
.random-card-media::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14, 18, 27, 0.35) 0%, var(--c-surface-2) 96%); }
.random-backdrop { width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.random-card-body { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 16px; align-items: end; padding-top: 64px; }
.random-poster { width: 92px; height: 138px; border-radius: 10px; object-fit: cover; background: var(--c-surface-3); box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45); }
.random-poster--empty { display: grid; place-items: center; color: var(--c-text-3); }
.random-info { display: grid; gap: 6px; min-width: 0; }
.random-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: var(--fs-xs); color: var(--c-text-2); }
.random-rating { display: inline-flex; align-items: center; gap: 4px; color: #ffd27a; font-weight: 600; }
.random-rating .icon { fill: currentColor; }
.random-title { font-size: 1.35rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.random-genres { font-size: var(--fs-sm); color: var(--c-text-2); }
.random-overview {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--c-text-2);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.random-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.random-actions .btn { min-height: 46px; padding: 0 20px; }
.random-actions .btn-primary { flex: 1 1 160px; }
.random-back { justify-self: start; }
.random-empty { display: grid; justify-items: center; gap: 10px; padding: 26px 12px; text-align: center; color: var(--c-text-2); }
.random-empty-title { color: var(--c-text); font-weight: 600; }
@media (max-width: 599px) {
  .random-dialog { width: 100vw; max-width: 100vw; max-height: 94dvh; margin: auto 0 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; border-bottom: 0; }
  .random-dialog .app-dialog-body { padding: 20px 16px calc(20px + var(--safe-bottom)); }
  .random-segmented .segmented-item { padding: 0 6px; font-size: var(--fs-xs); }
  .random-card-body { grid-template-columns: 76px minmax(0, 1fr); padding-top: 52px; }
  .random-poster { width: 76px; height: 114px; }
  .random-actions .btn { flex: 1 1 auto; }
}

/* ── ტექსტური ღილაკი და ბმული ─────────────────────────────── */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 2px;
  border-radius: var(--radius-xs);
  color: var(--c-accent-text);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.link { color: var(--c-accent-text); font-weight: 600; border-radius: var(--radius-xs); }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.icon-btn--sm { width: 32px; height: 32px; flex: none; color: var(--c-text-2); }
.icon-btn--sm:hover { color: var(--c-text); }

/* ── გაზიარება ────────────────────────────────────────────── */
.share-subject { margin-bottom: 14px; color: var(--c-text-2); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.share-targets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 16px; }
.share-target {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  font-weight: 600;
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.share-target:hover { background: var(--c-surface-3); border-color: var(--c-line-strong); }
.share-target .icon { color: var(--c-text-3); }
.share-dot { width: 12px; height: 12px; border-radius: 50%; }
.share-target--telegram .share-dot { background: #2aabee; }
.share-target--whatsapp .share-dot { background: #25d366; }
.share-target--facebook .share-dot { background: #1877f2; }
.share-target--x .share-dot { background: #e7e9ea; }
.share-target--reddit .share-dot { background: #ff4500; }
.share-copy { display: flex; gap: 8px; }
.share-url { flex: 1; min-width: 0; font-size: var(--fs-sm); }
@media (max-width: 599px) {
  .share-copy { flex-direction: column; }
}

/* ── „აპის დაყენება“ (sidebar) ────────────────────────────── */
.nav-install { width: 100%; text-align: left; color: var(--c-accent-soft); }
.nav-install .icon { color: var(--c-accent-soft); }

/* ── „ავტომატური თარგმანი“ (მანქანით თარგმნილი აღწერა / ბიოგრაფია) ── */
.auto-note { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-xs); line-height: 1.4; color: var(--c-text-3); }
.auto-note .icon { flex: none; opacity: 0.85; }
.title-overview + .auto-note { margin-top: -6px; }
.title-content .auto-note { color: rgba(238, 242, 248, 0.62); }
