/* ============================================================
   TenderHunter — "Hunter's Console" design system
   Loaded after Bootstrap 5.3. All values are tokens; components
   below override Bootstrap only where the world demands it.
   ============================================================ */

:root {
  /* Surfaces */
  --th-ink: #0a1120;
  --th-ink-2: #101b31;
  --th-ink-line: rgba(148, 173, 218, 0.14);
  --th-bg: #f4f6fb;
  --th-surface: #ffffff;

  /* Text */
  --th-text: #182136;
  --th-muted: #5b6b84;
  --th-soft: #8a9bb5;

  /* Brand */
  --th-primary: #3b5bfd;
  --th-primary-deep: #2b43d4;
  --th-primary-soft: #eaf0ff;
  --th-accent: #e63946;
  --th-accent-soft: #fdecec;
  --th-signal: #00b4d8;
  --th-signal-soft: #e1f7fd;

  /* Status */
  --st-novo: #00b4d8;        --st-novo-bg: #e1f7fd;
  --st-obrada: #f59e0b;      --st-obrada-bg: #fef3e2;
  --st-prijavljeno: #10b981; --st-prijavljeno-bg: #e3f9f2;
  --st-dobiveno: #22c55e;    --st-dobiveno-bg: #e8f9ee;
  --st-odbijeno: #e63946;    --st-odbijeno-bg: #fdecec;
  --st-nije: #94a3b8;        --st-nije-bg: #f1f5f9;

  /* Elevation */
  --th-shadow-sm: 0 1px 2px rgba(10, 17, 32, 0.04), 0 4px 10px -2px rgba(10, 17, 32, 0.06);
  --th-shadow-md: 0 2px 4px rgba(10, 17, 32, 0.05), 0 12px 28px -6px rgba(10, 17, 32, 0.12);
  --th-shadow-lg: 0 8px 16px -6px rgba(10, 17, 32, 0.12), 0 24px 48px -12px rgba(10, 17, 32, 0.18);

  /* Shape & type */
  --th-radius: 16px;
  --th-radius-sm: 10px;
  --th-font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --th-font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ---------- Base & browser surfaces ---------- */
html { scrollbar-color: #c3cde0 #eef1f7; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #eef1f7; }
::-webkit-scrollbar-thumb { background: #c3cde0; border-radius: 8px; border: 2px solid #eef1f7; }
::selection { background: rgba(59, 91, 253, 0.22); }

body {
  background-color: var(--th-bg);
  font-family: var(--th-font-body);
  color: var(--th-text);
  font-size: 0.9375rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--th-primary); }
:focus-visible { outline: 2px solid var(--th-primary); outline-offset: 2px; }

.font-display { font-family: var(--th-font-display); letter-spacing: -0.02em; }

/* ---------- Brand mark (authored SVG) ---------- */
.th-brand {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--th-primary);
}
.th-brand svg { width: 1em; height: 1em; display: block; }
.th-brand--light { color: #ffffff; }

/* ---------- App navbar (ink command surface) ---------- */
.th-navbar {
  background: linear-gradient(180deg, var(--th-ink) 0%, var(--th-ink-2) 100%);
  border-bottom: 1px solid var(--th-ink-line);
}
.th-navbar .navbar-brand {
  color: #ffffff !important;
  font-family: var(--th-font-display);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.th-navbar .navbar-brand .text-accent { color: var(--th-signal) !important; }
.th-navbar .navbar-toggler { color: #fff; border: 1px solid var(--th-ink-line); }
.th-navbar .navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.th-navbar .nav-link, .th-navbar .nav-link:hover { color: #c7d2ea; }
.th-navbar .nav-link:hover { color: #fff; }
.th-navbar .nav-item .bg-light {
  background: rgba(255,255,255,0.06) !important;
  border-color: var(--th-ink-line) !important;
  color: #dce6f7 !important;
}

/* ---------- Buttons / pills ---------- */
.btn-pill { border-radius: 50rem; }
.btn-action {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--th-surface);
  border: 1px solid #e2e8f2;
  color: var(--th-text);
  border-radius: 50rem;
  padding: 0.55rem 1.1rem;
  font-weight: 700;
  box-shadow: var(--th-shadow-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-action:hover { transform: translateY(-1px); box-shadow: var(--th-shadow-md); color: var(--th-text); }
.btn-action i { color: var(--th-primary); }
.btn-action .text-success { color: #10b981 !important; }

.btn-primary {
  background: linear-gradient(180deg, #4d69ff 0%, var(--th-primary-deep) 100%);
  border: 1px solid transparent;
  box-shadow: 0 6px 14px -6px rgba(59, 91, 253, 0.55);
}
.btn-primary:hover, .btn-primary:focus { background: linear-gradient(180deg, #5c75ff 0%, #2b43d4 100%); border-color: transparent; }

/* Status pill dot */
.status-dot { width: 0.55em; height: 0.55em; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ============================================================
   LOGIN — split "command surface" layout
   ============================================================ */
.login-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--th-surface);
}
@media (min-width: 992px) {
  .login-shell { grid-template-columns: 46% 54%; }
}

/* Ink brand panel */
.login-brand {
  position: relative; overflow: hidden;
  background:
    radial-gradient(120% 90% at 20% 0%, #1b2a4d 0%, transparent 60%),
    radial-gradient(90% 70% at 100% 100%, rgba(0, 180, 216, 0.18) 0%, transparent 55%),
    linear-gradient(160deg, var(--th-ink) 0%, var(--th-ink-2) 100%);
  color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: clamp(1.75rem, 5vw, 3.5rem);
  min-height: 40dvh;
}
@media (min-width: 992px) { .login-brand { min-height: 100dvh; } }

.login-brand::after { /* fine line texture */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background-image:
    linear-gradient(rgba(148,173,218,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,173,218,0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(120% 100% at 50% 0%, #000 55%, transparent 100%);
}

/* Radar sweep (the one authored moment) */
.radar-wrap { position: relative; width: 84px; height: 84px; margin-bottom: 1.25rem; }
.radar {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(0,180,216,0.55) 0deg, rgba(0,180,216,0) 70deg);
  animation: th-radar 5.5s linear infinite;
}
.radar::before, .radar::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(148,173,218,0.25);
}
.radar::after { inset: 26%; }
@keyframes th-radar { to { transform: rotate(360deg); } }

.login-brand-mark {
  position: relative; width: 64px; height: 64px; margin-top: 4px;
  color: #fff;
  filter: drop-shadow(0 0 18px rgba(0,180,216,0.35));
}
.login-brand-mark svg { width: 100%; height: 100%; }

.login-brand h1 {
  font-family: var(--th-font-display); font-weight: 700;
  font-size: clamp(1.9rem, 4vw, 2.6rem); letter-spacing: -0.02em;
  line-height: 1.05; margin: 0 0 0.75rem;
}
.login-brand .tagline { color: #aebfe0; font-size: 1.02rem; max-width: 34ch; margin-bottom: 2rem; }
.login-proof { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.9rem; }
.login-proof li { display: flex; gap: 0.75rem; align-items: flex-start; color: #d7e1f4; font-size: 0.92rem; }
.login-proof i { color: var(--th-signal); font-size: 1.05rem; margin-top: 0.1rem; }
.login-brand-foot { color: #61759c; font-size: 0.8rem; margin-top: 2.5rem; }

/* Light form panel */
.login-panel {
  display: flex; align-items: center; justify-content: center;
  padding: clamp(1.5rem, 6vw, 4rem);
  background: var(--th-surface);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--th-surface);
  border: 1px solid #e6ebf4;
  border-radius: var(--th-radius);
  box-shadow: var(--th-shadow-md);
  padding: clamp(1.5rem, 4vw, 2.5rem);
}
.login-card h2 { font-family: var(--th-font-display); font-weight: 700; letter-spacing: -0.02em; font-size: 1.5rem; }
.login-card .form-label { font-weight: 700; font-size: 0.8rem; color: var(--th-text); text-transform: uppercase; letter-spacing: 0.04em; }
.login-card .form-control {
  border-radius: var(--th-radius-sm); border: 1.5px solid #dde5f1;
  padding: 0.8rem 1rem; font-size: 1rem; background: #fbfcfe;
}
.login-card .form-control:focus { border-color: var(--th-primary); box-shadow: 0 0 0 4px rgba(59,91,253,0.12); background: #fff; }
.input-with-toggle { position: relative; }
.input-with-toggle .form-control { padding-right: 3rem; }
.input-with-toggle .toggle-pass {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--th-soft);
  width: 2.25rem; height: 2.25rem; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.input-with-toggle .toggle-pass:hover { color: var(--th-primary); background: var(--th-primary-soft); }

.login-submit { position: relative; padding: 0.85rem 1rem; border-radius: 50rem; font-weight: 700; }
.login-submit .spinner-border { width: 1.1em; height: 1.1em; }

/* Flash messages inside login */
.login-flash { border: 0; border-radius: var(--th-radius-sm); font-size: 0.9rem; }
.login-flash.alert-danger { background: var(--th-accent-soft); color: #b91c1c; }
.login-flash.alert-warning { background: #fef6e6; color: #92600a; }
.login-flash.alert-info { background: var(--th-signal-soft); color: #0369a1; }

/* ============================================================
   DASHBOARD
   ============================================================ */
.th-page { padding-top: 1.5rem; padding-bottom: 4rem; }

/* Header */
.dash-head h1 { font-family: var(--th-font-display); font-weight: 700; letter-spacing: -0.02em; font-size: clamp(1.35rem, 2.4vw, 1.75rem); }
.sync-stamp {
  display: inline-flex; align-items: center; gap: 0.45rem;
  color: var(--th-muted); font-size: 0.82rem;
}
.sync-stamp .pulse-dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%; background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.5); animation: th-pulse 2.4s ease-out infinite;
}
@keyframes th-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.45); }
  70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* Filter bar */
.th-filter-bar {
  background: var(--th-surface);
  border: 1px solid #e6ebf4;
  border-radius: var(--th-radius);
  box-shadow: var(--th-shadow-sm);
}
.filter-scroll {
  display: flex; gap: 0.5rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; padding-bottom: 0.25rem;
}
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-scroll .btn { white-space: nowrap; }
.status-filter-btn, .type-filter-btn {
  border-radius: 50rem !important;
  font-size: 0.82rem !important; font-weight: 700 !important;
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--th-muted);
}
.status-filter-btn .cnt {
  font-size: 0.68rem; background: #eef2f8; border-radius: 50rem;
  padding: 0.05rem 0.45rem; color: var(--th-muted); font-weight: 800;
}
.status-filter-btn.active .cnt { background: rgba(255,255,255,0.25); color: #fff; }

/* Search */
.th-search { position: relative; }
.th-search i { position: absolute; left: 0.95rem; top: 50%; transform: translateY(-50%); color: var(--th-soft); }
.th-search input {
  border-radius: 50rem; border: 1.5px solid #dde5f1; background: #fbfcfe;
  padding: 0.55rem 1.1rem 0.55rem 2.4rem; min-width: 200px;
}
.th-search input:focus { border-color: var(--th-primary); box-shadow: 0 0 0 4px rgba(59,91,253,0.12); background: #fff; }

/* Sort select */
.th-sort-select {
  border-radius: 50rem; border: 1.5px solid #dde5f1; background: var(--th-surface);
  font-size: 0.85rem; font-weight: 600; padding: 0.5rem 1rem; min-width: 200px;
}

/* Tender card grid + cards */
.th-list-card {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.25rem;
}
.tender-card {
  position: relative;
  background: var(--th-surface);
  border: 1px solid #e6ebf4;
  border-radius: var(--th-radius);
  box-shadow: var(--th-shadow-sm);
  padding: 1.25rem;
  display: flex; flex-direction: column;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.tender-card:hover { transform: translateY(-2px); box-shadow: var(--th-shadow-md); }
.tender-card.is-new::before {
  content: ""; position: absolute; top: 1.1rem; right: 1.25rem;
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: var(--th-signal); box-shadow: 0 0 0 0 rgba(0,180,216,0.5);
  animation: th-pulse 2.2s ease-out infinite;
}
.tender-card .tender-title { color: #111827; font-weight: 800; font-size: 1.02rem; line-height: 1.25; }
.tender-card .tender-body { color: #4b5563; font-size: 0.88rem; }

.badge-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; font-weight: 700; border-radius: 50rem;
  padding: 0.3rem 0.7rem;
}
.badge-chip i { font-size: 0.75em; }

/* Status pills */
.th-status {
  display: inline-flex; align-items: center; gap: 0.45rem;
  border-radius: 50rem; border: 0;
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.42rem 0.85rem; cursor: pointer;
}
.th-status .status-dot { width: 0.5em; height: 0.5em; }
.status-novo { background: var(--st-novo-bg); color: #0369a1; }
.status-u-obradi { background: var(--st-obrada-bg); color: #b45309; }
.status-prijavljeno { background: var(--st-prijavljeno-bg); color: #047857; }
.status-dobiveno { background: var(--st-dobiveno-bg); color: #15803d; }
.status-odbijeno { background: var(--st-odbijeno-bg); color: #b91c1c; }
.status-nije-interesantno { background: var(--st-nije-bg); color: #475569; }
.status-dot--novo { background: var(--st-novo); }
.status-dot--u-obradi { background: var(--st-obrada); }
.status-dot--prijavljeno { background: var(--st-prijavljeno); }
.status-dot--dobiveno { background: var(--st-dobiveno); }
.status-dot--odbijeno { background: var(--st-odbijeno); }
.status-dot--nije-interesantno { background: var(--st-nije); }

/* Deadline chip */
.deadline-chip { font-weight: 700; font-size: 0.78rem; color: var(--th-muted); }
.deadline-chip.is-urgent { color: #b91c1c; }

/* AI button */
.ai-btn-gradient {
  background: linear-gradient(135deg, #eef2ff 0%, #f6ecff 100%);
  color: #4338ca; border: 1px solid #dbe3ff; border-radius: 50rem;
  font-weight: 800; font-size: 0.86rem;
  transition: all 0.2s ease;
}
.ai-btn-gradient:hover { background: linear-gradient(135deg, #dbe3ff 0%, #ebd8ff 100%); color: #3730a3; transform: translateY(-1px); }

/* Quota chip */
.quota-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.7rem; font-weight: 700; color: var(--th-muted);
  background: #f1f5fb; border-radius: 50rem; padding: 0.25rem 0.7rem;
}

/* Empty state */
.th-empty { text-align: center; padding: 3.5rem 1.5rem; }
.th-empty .th-brand { font-size: 3rem; opacity: 0.55; }
.th-empty h4 { font-family: var(--th-font-display); font-weight: 700; letter-spacing: -0.01em; }

/* Modal bottom sheet on mobile */
@media (max-width: 767.98px) {
  .modal-dialog { margin: 0; }
  .modal.fade .modal-dialog { transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
  .modal.show .modal-dialog { transform: translateY(0); }
  .modal-content {
    border-radius: 1.25rem 1.25rem 0 0 !important;
    border-bottom: 0;
  }
}

/* Skeleton */
.th-skeleton {
  border-radius: var(--th-radius);
  background: linear-gradient(90deg, #eef1f7 25%, #f7f9fc 50%, #eef1f7 75%);
  background-size: 200% 100%;
  animation: th-shimmer 1.4s infinite;
}
@keyframes th-shimmer { to { background-position: -200% 0; } }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .radar, .tender-card.is-new::before, .sync-stamp .pulse-dot { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}

/* ============================================================
   MOBILE APP SHELL — bottom tab bar, FAB, sticky filters, safe-areas
   ============================================================ */

/* Content clears the fixed bottom chrome (mobile only) */
@media (max-width: 991.98px) {
  .th-app { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  /* Top navbar scrolls away on mobile; the tab bar owns navigation */
  .th-navbar { position: static !important; }
}

/* Bottom tab bar (app-like) */
.th-bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid #e6ebf4;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -8px 24px -12px rgba(10, 17, 32, 0.22);
}
.th-bn-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 9px 4px 7px;
  min-height: 56px;
  color: var(--th-muted);
  text-decoration: none;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
}
.th-bn-item i { font-size: 1.25rem; line-height: 1; }
.th-bn-item span { white-space: nowrap; }
.th-bn-item.active { color: var(--th-primary); }
.th-bn-item:active { color: var(--th-primary-deep); }

/* Floating action button (dashboard scan) */
.th-fab {
  position: fixed;
  right: calc(18px + env(safe-area-inset-right, 0px));
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(180deg, #4d69ff 0%, var(--th-primary-deep) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 26px -8px rgba(59, 91, 253, 0.6);
  z-index: 1035;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.th-fab i { font-size: 1.5rem; }
.th-fab:active { transform: scale(0.94); }

/* Sticky filter bar on mobile (dashboard): stays reachable while scrolling */
@media (max-width: 991.98px) {
  .th-filter-bar {
    position: sticky;
    top: 0;
    z-index: 1025;
    margin-left: calc(var(--bs-gutter-x, 1.5rem) / -2);
    margin-right: calc(var(--bs-gutter-x, 1.5rem) / -2);
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    background: rgba(244, 246, 251, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 6px 18px -12px rgba(10, 17, 32, 0.28);
  }
}

/* Floating privacy trigger + cookie manager stay above the tab bar */
@media (max-width: 991.98px) {
  .th-app .privacy-trigger {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
  .th-app .cookie-manager {
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  }
}