/* ============================================================
   POPUSTIĆ – Design System
   Segoe UI · Dark/Light theme · Mobile-first
============================================================ */

:root {
  --bg: #0d0d10;
  --surface: #16161c;
  --surface2: #1e1e27;
  --border: rgba(255,255,255,0.07);
  --accent: #ff3c5f;
  --accent2: #ff8c42;
  --accent3: #7c3aed;
  --text: #f0f0f4;
  --text2: #8888a0;
  --text3: #555568;
  --green: #22c55e;
  --yellow: #eab308;
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Segoe UI', system-ui, sans-serif;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --glow-accent: 0 0 24px rgba(255,60,95,0.3);
  --topbar-bg: rgba(13,13,16,0.88);
  --bottomnav-bg: rgba(22,22,28,0.95);
}

html.light {
  --bg: #f4f4f8;
  --surface: #ffffff;
  --surface2: #ebebf2;
  --border: rgba(0,0,0,0.08);
  --text: #0d0d14;
  --text2: #5a5a72;
  --text3: #9999b0;
  --shadow: 0 8px 32px rgba(0,0,0,0.10);
  --glow-accent: 0 0 24px rgba(255,60,95,0.18);
  --topbar-bg: rgba(244,244,248,0.90);
  --bottomnav-bg: rgba(255,255,255,0.96);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.25s, color 0.2s;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.35;
}

/* ============================================================
   TOPBAR
============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--topbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.25s;
}

.logo {
  font-family: var(--font);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
}

.logo-icon {
  width: 30px; height: 30px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: var(--glow-accent);
}

.logo span { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1;
}

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: var(--glow-accent);
}
.btn-primary:hover { background: #ff1a42; transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-outline:hover { background: rgba(255,60,95,0.1); }

.btn-success {
  background: var(--green);
  color: #0a1f0a;
  font-weight: 600;
}
.btn-success:hover { background: #16a34a; transform: translateY(-1px); }

/* ============================================================
   LAYOUT
============================================================ */
.page-wrap {
  padding-top: 60px;
  padding-bottom: 80px;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ============================================================
   ALERTS
============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error   { background: rgba(255,60,95,0.12);  color: #ff6b88;  border: 1px solid rgba(255,60,95,0.3); }
.alert-success { background: rgba(34,197,94,0.12);  color: #4ade80;  border: 1px solid rgba(34,197,94,0.3); }
html.light .alert-error   { color: #cc0022; }
html.light .alert-success { color: #166534; }

/* ============================================================
   HERO
============================================================ */
.hero {
  padding: 52px 20px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -100px; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 400px;
  background: radial-gradient(ellipse, rgba(255,60,95,0.1) 0%, transparent 70%);
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,60,95,0.12);
  border: 1px solid rgba(255,60,95,0.3);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.live-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.hero h1 {
  font-size: clamp(28px, 5.5vw, 52px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1px;
  margin-bottom: 14px;
}

.hero h1 em { font-style: normal; color: var(--accent); }

.hero p {
  color: var(--text2);
  font-size: 16px;
  max-width: 460px;
  margin: 0 auto 28px;
}

/* ============================================================
   FILTER BAR
============================================================ */
.filters-bar {
  padding: 0 16px 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filters-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--accent); color: var(--text); }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: white; box-shadow: var(--glow-accent); }

/* ============================================================
   SORT TABS
============================================================ */
.sort-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  padding: 0 16px;
}

.sort-tab {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.sort-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.sort-tab:hover  { color: var(--text2); }

.count-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--text2);
  margin: 0 16px 16px;
}
.count-pill strong { color: var(--text); }

/* ============================================================
   DEALS GRID
============================================================ */
.deals-grid {
  padding: 0 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  max-width: 1100px;
  margin: 0 auto;
}

@media (max-width: 340px) {
  .deals-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   DEAL CARD
============================================================ */
.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  cursor: pointer;
  position: relative;
  animation: cardIn 0.4s ease both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.deal-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(255,60,95,0.2);
}

.deal-card-header {
  padding: 16px 16px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.deal-badge {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: white;
  font-weight: 800;
  font-size: 26px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  line-height: 1;
  box-shadow: var(--glow-accent);
  flex-shrink: 0;
}
.deal-badge.orange { background: var(--accent2); box-shadow: 0 0 20px rgba(255,140,66,0.4); }
.deal-badge.purple { background: var(--accent3); box-shadow: 0 0 20px rgba(124,58,237,0.4); }
.deal-badge.green  { background: var(--green);   box-shadow: 0 0 20px rgba(34,197,94,0.4); color: #0a1f0a; }

.deal-category-icon { font-size: 30px; line-height: 1; flex-shrink: 0; }

.deal-card-body { padding: 0 16px 14px; }

.deal-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.deal-desc {
  color: var(--text2);
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.deal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0;
}

.deal-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--text3);
  background: var(--surface2);
  padding: 3px 9px;
  border-radius: 100px;
}

.deal-expiry.urgent   { color: var(--yellow); }
.deal-expiry.critical { color: var(--accent); font-weight: 600; }

/* Contact block on card */
.deal-contact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.deal-contact-item {
  font-size: 12.5px;
  color: #c8c8dc;
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
html.light .deal-contact-item { color: #3a3a55; }

.deal-contact-link { color: #a0a0cc; }
html.light .deal-contact-link { color: #5050aa; }

.deal-card-footer {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.deal-biz { display: flex; align-items: center; gap: 8px; min-width: 0; }

.deal-biz-avatar {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.deal-biz-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deal-cta {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  padding: 11px;
  text-align: center;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 14px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  letter-spacing: 0.01em;
}
.deal-cta:hover { background: #ff1a42; transform: translateY(-1px); box-shadow: var(--glow-accent); }

.trending-ribbon {
  position: absolute;
  top: 12px; right: -28px;
  background: var(--yellow);
  color: #1a1000;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 36px;
  transform: rotate(45deg);
  width: 120px;
  text-align: center;
}

/* ============================================================
   PAGINATION
============================================================ */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px 32px;
  flex-wrap: wrap;
}

/* ============================================================
   EMPTY STATE
============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
  grid-column: 1 / -1;
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; }

/* ============================================================
   BOTTOM NAV
============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--bottomnav-bg);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  transition: background 0.25s;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  color: var(--text3);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}
.nav-item:hover { color: var(--text2); }
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 22px; line-height: 1; }

/* ============================================================
   AUTH PAGES
============================================================ */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 60px);
  padding: 24px 16px 90px;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 420px;
}

.auth-box h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 6px;
}

.auth-box > p {
  color: var(--text2);
  font-size: 14px;
  margin-bottom: 24px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text3);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.auth-toggle {
  text-align: center;
  font-size: 13px;
  color: var(--text2);
  margin-top: 16px;
}
.auth-toggle a { color: var(--accent); cursor: pointer; text-decoration: none; }

/* ============================================================
   FORM ELEMENTS
============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 88px; }
.form-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ============================================================
   DASHBOARD
============================================================ */
.dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 16px 90px;
}

.dashboard-header { margin-bottom: 24px; }
.dashboard-header h2 { font-size: 26px; font-weight: 800; margin-bottom: 4px; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-deal-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color 0.2s;
}
.dash-deal-row:hover { border-color: var(--text3); }

.dash-deal-info { flex: 1; min-width: 0; }

.dash-deal-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-deal-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

.status-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 100px;
  flex-shrink: 0;
  white-space: nowrap;
}
.status-active   { background: rgba(34,197,94,0.15);   color: var(--green); }
.status-expired  { background: rgba(255,60,95,0.12);   color: var(--accent); }
.status-draft    { background: rgba(136,136,160,0.12); color: var(--text3); }
.status-pending  { background: rgba(234,179,8,0.15);   color: var(--yellow); }
.status-approved { background: rgba(34,197,94,0.15);   color: var(--green); }
.status-rejected { background: rgba(255,60,95,0.12);   color: var(--accent); }

/* ============================================================
   MODAL
============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 20px; }
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 24px 20px 36px;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (min-width: 600px) { .modal { border-radius: var(--radius); } }

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title { font-size: 19px; font-weight: 700; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  border: none;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.modal-close:hover { background: var(--border); }

.modal-contact-row {
  font-size: 14px;
  color: #c8c8dc;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.5;
}
html.light .modal-contact-row { color: #3a3a55; }

/* ============================================================
   ADMIN DEAL ROW TABS (reuse sort-tabs)
============================================================ */
.sort-tabs a { text-decoration: none; }

/* ============================================================
   AI SECTION
============================================================ */
.ai-section {
  background: linear-gradient(135deg, rgba(124,58,237,0.12) 0%, rgba(255,60,95,0.08) 100%);
  border: 1px solid rgba(124,58,237,0.25);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.ai-section-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* ============================================================
   TOAST
============================================================ */
.toast {
  position: fixed;
  bottom: 76px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9000;
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ============================================================
   DEAL DETAIL PAGE
============================================================ */
.deal-detail {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 16px 90px;
}

/* ============================================================
   RESPONSIVE TWEAKS
============================================================ */
@media (max-width: 600px) {
  .topbar-right .btn-ghost:not(#themeToggle) { display: none; }
  .auth-box { padding: 24px 18px; }
}
