/* ──────────────────────────────────────────────────────────────────────────
   GMaps Pipeline — UI sistem inspirisan course-portal (LevelUp Academy)
   shadcn-style: HSL CSS variables + light/dark teme + sidebar layout
   ────────────────────────────────────────────────────────────────────────── */

:root {
  /* Light theme (default) */
  --background: 0 0% 100%;
  --foreground: 224 71.4% 4.1%;
  --card: 0 0% 100%;
  --card-foreground: 224 71.4% 4.1%;
  --popover: 0 0% 100%;
  --popover-foreground: 224 71.4% 4.1%;
  --primary: 217 91% 60%;
  --primary-hover: 217 91% 52%;
  --primary-foreground: 0 0% 100%;
  --secondary: 220 14.3% 95.9%;
  --secondary-foreground: 220.9 39.3% 11%;
  --muted: 220 14.3% 95.9%;
  --muted-foreground: 220 8.9% 46.1%;
  --accent: 220 14.3% 95.9%;
  --accent-foreground: 220.9 39.3% 11%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 100%;
  --success: 142 71% 45%;
  --success-foreground: 0 0% 100%;
  --warning: 38 92% 50%;
  --warning-foreground: 0 0% 100%;
  --info: 199 89% 48%;
  --info-foreground: 0 0% 100%;
  --border: 220 13% 91%;
  --input: 220 13% 91%;
  --ring: 217 91% 60%;
  --radius: 0.5rem;
  --sidebar-bg: 220 14.3% 97%;
  --sidebar-fg: 224 71.4% 4.1%;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.dark {
  --background: 224 71.4% 4.1%;
  --foreground: 210 20% 98%;
  --card: 224 47% 8%;
  --card-foreground: 210 20% 98%;
  --popover: 224 47% 8%;
  --popover-foreground: 210 20% 98%;
  --primary: 217 91% 60%;
  --primary-hover: 217 91% 68%;
  --primary-foreground: 0 0% 100%;
  --secondary: 215 27.9% 16.9%;
  --secondary-foreground: 210 20% 98%;
  --muted: 215 27.9% 16.9%;
  --muted-foreground: 217.9 10.6% 64.9%;
  --accent: 215 27.9% 16.9%;
  --accent-foreground: 210 20% 98%;
  --destructive: 0 62.8% 50%;
  --destructive-foreground: 0 0% 100%;
  --success: 142 71% 45%;
  --warning: 38 92% 50%;
  --info: 199 89% 48%;
  --border: 215 27.9% 16.9%;
  --input: 215 27.9% 16.9%;
  --ring: 217 91% 60%;
  --sidebar-bg: 224 47% 6%;
  --sidebar-fg: 210 20% 98%;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  transition: background-color 0.2s ease, color 0.2s ease;
}

.hidden { display: none !important; }

a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App layout: sidebar + main ─────────────────────────────────────────── */
/* VAZNO — minmax(0, 1fr), NE 1fr:
   grid traka "1fr" ima podrazumevani minimum min-content, pa se kolona sadrzaja
   siri do najsireg elementa (tabela, kanban tabla) i razvlaci celu stranicu.
   Na telefonu to pokrece zacarani krug: stranica postane npr. 1440px siroka →
   layout viewport se prosiri na 1440px → @media (max-width:768px) VISE NE VAZI →
   mobilni CSS se ne primeni → stranica ostane siroka i browser je zumira na 25%.
   Zato ovo mora biti u osnovnom CSS-u, a ne u media query-ju. */
.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.collapsed { grid-template-columns: 60px minmax(0, 1fr); }

/* Kolona sa topbar-om i sadrzajem sme da se skupi ispod sirine sadrzaja;
   prelivanje se resava klizanjem unutar tabele/kanbana, ne sirenjem stranice. */
.app-shell > .main-col { min-width: 0; }

.sidebar {
  background: hsl(var(--sidebar-bg));
  border-right: 1px solid hsl(var(--border));
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid hsl(var(--border));
  height: 60px;
  gap: 8px;
}

.sidebar-logo {
  font-size: 15px;
  font-weight: 700;
  background: linear-gradient(90deg, hsl(var(--primary)), hsl(214 95% 70%));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.app-shell.collapsed .sidebar-logo-text { display: none; }

.sidebar-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-toggle:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.sidebar-nav {
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-section {
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 10px 6px;
}

.app-shell.collapsed .sidebar-section { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

.nav-item:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.nav-item.active {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: hsl(var(--primary));
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
}

.app-shell.collapsed .nav-label { display: none; }
.app-shell.collapsed .nav-item { justify-content: center; padding: 9px 8px; }
.app-shell.collapsed .nav-item::before { display: none; }

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid hsl(var(--border));
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}

.app-shell.collapsed .sidebar-footer { display: none; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 60px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 12px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.topbar-spacer { flex: 1; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-radius: 999px;
  border: 1px solid hsl(var(--border));
}

.status-pill .ok { color: hsl(var(--success)); }
.status-pill .err { color: hsl(var(--destructive)); }

.icon-btn {
  background: transparent;
  border: 1px solid hsl(var(--border));
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  transition: all 0.15s ease;
}
.icon-btn:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* ── Main content area ──────────────────────────────────────────────────── */
.main-content {
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: hsl(var(--foreground));
}

h3 {
  font-size: 16px;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Card ────────────────────────────────────────────────────────────────── */
.card, .form-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  color: hsl(var(--card-foreground));
  box-shadow: var(--shadow-sm);
}

.card:hover, .form-card:hover { box-shadow: var(--shadow); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.card-desc {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  margin: 0 0 12px 0;
}

/* Stat card (Dashboard) */
.stat-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat-label {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

/* Kanban kolona (sirina se menja na mobilnom — vidi media query dole).
   Klasa umesto inline stila da bi CSS mogao da je pregazi bez !important. */
.pipe-col { flex: 0 0 240px; }

/* ── Form elements ───────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--foreground));
  margin-bottom: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.form-row.single { grid-template-columns: 1fr; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: 6px;
  color: hsl(var(--foreground));
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

input::placeholder { color: hsl(var(--muted-foreground)); }

textarea { font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace; line-height: 1.5; }

.checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  margin: 0;
  color: hsl(var(--foreground));
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: hsl(var(--primary));
  cursor: pointer;
}

.radio-group {
  border: none;
  padding: 0;
  margin: 0 0 14px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-group legend {
  font-size: 12px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding: 0;
  width: 100%;
}

.radio-group label {
  background: hsl(var(--secondary));
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.radio-group label:has(input:checked) {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

.field-hint { color: hsl(var(--muted-foreground)); font-size: 12px; display: block; margin-top: 2px; }

.file-select-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.file-select-row select { flex: 1; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
button, .btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-primary:hover:not(:disabled) {
  background: hsl(var(--primary-hover));
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid hsl(var(--border));
}
.btn-secondary:hover:not(:disabled) { background: hsl(var(--accent)); }

.btn-danger, .btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.btn-danger:hover:not(:disabled) { background: hsl(var(--destructive) / 0.85); }

.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}
.btn-ghost:hover:not(:disabled) { background: hsl(var(--accent)); }

.btn-refresh {
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  padding: 6px 10px;
  font-size: 13px;
}
.btn-refresh:hover:not(:disabled) {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn-status-refresh {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
}
.btn-status-refresh:hover:not(:disabled) {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* ── Subtabs ─────────────────────────────────────────────────────────────── */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid hsl(var(--border));
  padding-bottom: 0;
}

.subtab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  border-radius: 0;
  margin-bottom: -1px;
}

.subtab:hover { color: hsl(var(--foreground)); }
.subtab.active {
  color: hsl(var(--primary));
  border-bottom-color: hsl(var(--primary));
  font-weight: 600;
}

.subtab-content { display: none; }
.subtab-content.active { display: block; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-primary { background: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
.badge-success { background: hsl(var(--success) / 0.15); color: hsl(var(--success)); }
.badge-warning { background: hsl(var(--warning) / 0.15); color: hsl(var(--warning)); }
.badge-danger { background: hsl(var(--destructive) / 0.15); color: hsl(var(--destructive)); }
.badge-muted { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table thead th {
  text-align: left;
  padding: 10px 8px;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--secondary) / 0.4);
}

table tbody td {
  padding: 8px;
  border-bottom: 1px solid hsl(var(--border));
}

table tbody tr:hover { background: hsl(var(--accent) / 0.4); }

/* ── Log area (SSE output) ───────────────────────────────────────────────── */
.log-area {
  background: hsl(224 47% 6%);
  color: hsl(140 60% 75%);
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  font-size: 12px;
  padding: 14px;
  border-radius: var(--radius);
  max-height: 320px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid hsl(var(--border));
}

.log-area::-webkit-scrollbar { width: 6px; }
.log-area::-webkit-scrollbar-thumb { background: hsl(var(--muted-foreground) / 0.4); border-radius: 3px; }

.result-bar {
  margin-top: 12px;
  padding: 12px 16px;
  background: hsl(var(--success) / 0.1);
  border: 1px solid hsl(var(--success) / 0.3);
  border-radius: 6px;
  font-size: 13px;
  color: hsl(var(--success));
  display: flex;
  align-items: center;
  gap: 10px;
}

.result-bar.error {
  background: hsl(var(--destructive) / 0.1);
  border-color: hsl(var(--destructive) / 0.3);
  color: hsl(var(--destructive));
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ───────────────────────────────────────────────────────────────── */
#modal-overlay, #preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  border: 1px solid hsl(var(--border));
}

.modal h3 { margin-top: 0; }

.modal-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── City chips (Scrape tab) ─────────────────────────────────────────────── */
.city-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 14px 0;
}

.city-chip {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid hsl(var(--border));
  transition: all 0.15s ease;
}
.city-chip:hover {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  border-color: hsl(var(--primary));
}

/* ── Chat ────────────────────────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-token-info {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  padding: 4px 10px;
  background: hsl(var(--muted));
  border-radius: 999px;
}

.chat-wrapper {
  position: relative;
  margin-bottom: 12px;
}

.chat-messages {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 16px;
  min-height: 420px;
  max-height: 60vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Welcome screen */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  min-height: 350px;
}
.chat-welcome.hidden { display: none; }
.chat-welcome-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.8;
}
.chat-welcome h3 {
  margin: 0 0 8px 0;
  font-size: 22px;
  font-weight: 600;
  color: hsl(var(--foreground));
}
.chat-welcome-sub {
  margin: 0 0 24px 0;
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  max-width: 460px;
}
.chat-suggestions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 600px;
}
.chat-suggest {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 12px 14px;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  color: hsl(var(--foreground));
  font-family: inherit;
}
.chat-suggest:hover {
  background: hsl(var(--accent));
  border-color: hsl(var(--primary));
  transform: translateY(-1px);
}
.chat-suggest strong {
  font-size: 13px;
  margin-bottom: 4px;
  font-weight: 600;
}
.chat-suggest span {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}

/* Scroll-to-bottom dugme */
.chat-scroll-bottom {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: 0;
  cursor: pointer;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 5;
}
.chat-scroll-bottom:hover { transform: translateY(-2px); }
.chat-scroll-bottom.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

/* Message wrapper (sadrži msg + actions) */
.msg-wrapper {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  animation: msg-fade-in 0.2s ease-out;
}
.msg-wrapper-user { align-items: flex-end; }
.msg-wrapper-assistant, .msg-wrapper-thinking { align-items: flex-start; }
.msg-wrapper:last-child { margin-bottom: 0; }

@keyframes msg-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Action toolbar ispod assistant poruke */
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  padding-left: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.msg-wrapper:hover .msg-actions,
.msg-wrapper:focus-within .msg-actions { opacity: 1; }
.msg-action-btn {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11.5px;
  font-family: inherit;
  transition: all 0.15s;
}
.msg-action-btn:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border-color: hsl(var(--primary));
}
.msg-action-btn.copied { color: #2e7d32; border-color: #2e7d32; }

/* Aborted poruka indikator */
.msg-aborted {
  margin-top: 8px !important;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

.chat-msg, .msg {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chat-msg.user, .msg-user {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  margin-left: auto;
  max-width: 80%;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.chat-msg.assistant, .msg-assistant {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  max-width: 95%;
  border-radius: 14px;
}
.msg-thinking {
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-style: italic;
  max-width: 80%;
  border-bottom-left-radius: 4px;
  min-height: 36px;
  display: flex;
  align-items: center;
}
.msg-thinking::before {
  content: '';
  display: inline-flex;
  width: 36px;
  height: 12px;
  background-image: radial-gradient(circle, currentColor 2px, transparent 2.5px);
  background-size: 12px 12px;
  background-repeat: repeat-x;
  background-position: 0 50%;
  animation: dots-pulse 1.4s ease-in-out infinite;
  opacity: 0.6;
}
@keyframes dots-pulse {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 0.9; }
}

/* Streaming cursor — pojavi se na kraju AI poruke dok piše */
.msg-assistant.streaming::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 14px;
  margin-left: 2px;
  vertical-align: middle;
  background: hsl(var(--primary));
  opacity: 0.8;
  animation: cursor-blink 1s steps(2) infinite;
}
@keyframes cursor-blink {
  0%, 50% { opacity: 0.8; }
  51%, 100% { opacity: 0; }
}

/* ── Markdown formatiranje unutar AI odgovora ── */
.msg-assistant > *:first-child { margin-top: 0 !important; }
.msg-assistant > *:last-child { margin-bottom: 0 !important; }

.msg-assistant p { margin: 0 0 8px 0; }
.msg-assistant p + p { margin-top: 0; }

.msg-assistant h2, .msg-assistant h3, .msg-assistant h4, .msg-assistant h5 {
  margin: 14px 0 6px 0;
  line-height: 1.3;
  font-weight: 600;
  text-wrap: balance;
}
.msg-assistant h2 { font-size: 18px; padding-bottom: 4px; border-bottom: 1px solid hsl(var(--border)); }
.msg-assistant h3 { font-size: 16px; }
.msg-assistant h4 { font-size: 15px; }
.msg-assistant h5 { font-size: 14px; color: hsl(var(--muted-foreground)); text-transform: uppercase; letter-spacing: 0.4px; }

/* Naslov posle paragrafa ima manji top margin */
.msg-assistant p + h2, .msg-assistant p + h3, .msg-assistant p + h4 { margin-top: 12px; }
/* Naslov direktno posle naslova - bez razmaka */
.msg-assistant h2 + h3, .msg-assistant h3 + h4 { margin-top: 6px; }

.msg-assistant ul, .msg-assistant ol {
  margin: 6px 0 8px 0;
  padding-left: 22px;
}
.msg-assistant ul ul, .msg-assistant ol ol, .msg-assistant ul ol, .msg-assistant ol ul {
  margin: 4px 0;
}
.msg-assistant li { margin-bottom: 3px; }
.msg-assistant li:last-child { margin-bottom: 0; }
.msg-assistant li > p { margin: 0; }
.msg-assistant li.task-li {
  list-style: none;
  margin-left: -20px;
}
.msg-assistant li.task-li input[type=checkbox] {
  margin-right: 6px;
  vertical-align: middle;
}

.msg-assistant strong { font-weight: 600; color: hsl(var(--foreground)); }
.msg-assistant em { font-style: italic; }
.msg-assistant del { color: hsl(var(--muted-foreground)); }

.msg-assistant a {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.msg-assistant a:hover { text-decoration: none; }

.msg-assistant hr {
  border: 0;
  border-top: 1px solid hsl(var(--border));
  margin: 12px 0;
}

/* Inline code */
.msg-assistant code {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  padding: 2px 7px;
  border-radius: 5px;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  border: 1px solid hsl(var(--border));
}

/* Code block sa header-om (lang + copy) */
.msg-assistant .code-block {
  position: relative;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  margin: 8px 0;
  overflow: hidden;
}
.msg-assistant .code-lang {
  display: inline-block;
  padding: 4px 12px;
  background: hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom-right-radius: 6px;
}
.msg-assistant .code-copy {
  position: absolute;
  top: 6px;
  right: 8px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
}
.msg-assistant .code-copy:hover { opacity: 1; background: hsl(var(--accent)); }
.msg-assistant .code-copy.copied { color: #2e7d32; opacity: 1; }
.msg-assistant .code-block pre {
  background: transparent;
  border: 0;
  padding: 14px 16px;
  margin: 0;
  overflow-x: auto;
}
.msg-assistant .code-block pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 13.5px;
  line-height: 1.6;
}

/* Blockquote */
.msg-assistant blockquote {
  border-left: 4px solid hsl(var(--primary));
  margin: 8px 0;
  padding: 6px 12px;
  background: hsl(var(--muted) / 0.4);
  border-radius: 0 6px 6px 0;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* Tabele */
.msg-assistant .md-table {
  border-collapse: collapse;
  margin: 8px 0;
  width: 100%;
  font-size: 13.5px;
  overflow-x: auto;
  display: block;
}
.msg-assistant .md-table thead {
  background: hsl(var(--muted));
}
.msg-assistant .md-table th,
.msg-assistant .md-table td {
  border: 1px solid hsl(var(--border));
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
.msg-assistant .md-table th {
  font-weight: 600;
  color: hsl(var(--foreground));
}
.msg-assistant .md-table tbody tr:nth-child(even) {
  background: hsl(var(--muted) / 0.3);
}

/* Input zona */
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input-wrap {
  flex: 1;
  position: relative;
}
.chat-input-row textarea {
  width: 100%;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  padding: 11px 70px 11px 14px;
  border-radius: 12px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.chat-input-row textarea:focus {
  outline: 0;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15);
}
.chat-input-row textarea:disabled {
  background: hsl(var(--muted));
  cursor: not-allowed;
}
.chat-char-count {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  pointer-events: none;
  user-select: none;
  background: hsl(var(--card));
  padding: 2px 4px;
}
.chat-char-count.warn { color: #d97706; font-weight: 600; }

.chat-submit, .chat-stop {
  height: 44px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  white-space: nowrap;
}
.chat-submit .btn-icon, .chat-stop .btn-icon {
  font-size: 16px;
  font-weight: bold;
}
.chat-submit.hidden, .chat-stop.hidden { display: none; }

/* Na mobilnim sakrij tekst dugmadi, ostavi ikonu */
@media (max-width: 600px) {
  .chat-submit .btn-text, .chat-stop .btn-text, .chat-clear-btn .btn-text { display: none; }
  .chat-submit, .chat-stop { padding: 0 12px; }
}

/* ── Grid napredne opcije ────────────────────────────────────────────────── */
.grid-advanced {
  margin-top: 12px;
  background: hsl(var(--muted) / 0.4);
  border: 1px solid hsl(var(--border));
  border-left: 3px solid hsl(var(--primary));
  padding: 14px 16px;
  border-radius: 8px;
}
.grid-advanced.hidden { display: none; }
.grid-advanced label { font-weight: 500; }

/* Slider stilovi */
.grid-advanced input[type=range] {
  width: 100%;
  margin: 10px 0 4px 0;
  accent-color: hsl(var(--primary));
}
.slider-marks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  margin-bottom: 6px;
}

/* Calculator kartica */
.grid-calculator {
  margin-top: 12px;
  padding: 10px 14px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 6px;
  font-size: 13px;
}
.grid-calculator.hidden { display: none; }
.calc-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  gap: 12px;
}
.calc-row + .calc-row {
  border-top: 1px dashed hsl(var(--border));
}
.calc-label {
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  flex-shrink: 0;
}
.calc-value {
  color: hsl(var(--foreground));
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Dropdown opstine */
#g-opstina {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 6px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 14px;
  margin-top: 4px;
}
#g-opstina:focus {
  outline: 0;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15);
}

/* ── Schedule hint ──────────────────────────────────────────────────────── */
.schedule-hint {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  margin-top: 6px;
}

/* ── Status bar (top) — held in topbar ──────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.status-item {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  padding: 4px 10px;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
}

/* ── Agent (kolega koji izvršava zadatke) ───────────────────────────────── */

/* Napomena na vrhu taba — objašnjava granicu izmedju "radi odmah" i "traži potvrdu" */
.agent-note {
  background: hsl(var(--primary) / 0.07);
  border: 1px solid hsl(var(--primary) / 0.25);
  border-left: 3px solid hsl(var(--primary));
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: hsl(var(--foreground));
  margin-bottom: 12px;
}

/* Spisak izvršenih koraka — korisnik uvek vidi ŠTA je agent stvarno uradio,
   ne samo šta tvrdi da je uradio. */
.agent-steps {
  background: hsl(var(--muted) / 0.5);
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 12px;
  font-size: 13px;
}
.agent-steps-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  margin-bottom: 6px;
}
.agent-step {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 3px 0;
  flex-wrap: wrap;
}
.agent-step code {
  background: hsl(var(--secondary));
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 12.5px;
}
.agent-step-ico { font-weight: 700; flex: none; }
.agent-step.ok .agent-step-ico { color: hsl(var(--success)); }
.agent-step.fail .agent-step-ico { color: hsl(var(--destructive)); }
.agent-step-args {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  word-break: break-word;
}

/* Kartica predloga — sve što šalje mejlove ili troši kredite staje ovde
   i čeka klik. Namerno upadljiva. */
.agent-proposal {
  border: 1.5px solid hsl(var(--warning));
  background: hsl(var(--warning) / 0.07);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 10px 0 14px;
}
.agent-proposal-head {
  font-weight: 700;
  color: hsl(var(--warning));
  margin-bottom: 8px;
  font-size: 14px;
}
.agent-proposal-body {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 7px;
  padding: 10px 12px;
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  max-height: 300px;
  overflow-y: auto;
}
.agent-proposal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.agent-proposal.done {
  border-color: hsl(var(--success));
  background: hsl(var(--success) / 0.07);
}
.agent-proposal.done .agent-proposal-head { color: hsl(var(--success)); }
.agent-proposal.rejected {
  border-color: hsl(var(--border));
  background: hsl(var(--muted) / 0.4);
  opacity: 0.75;
}
.agent-proposal.rejected .agent-proposal-head { color: hsl(var(--muted-foreground)); }

/* Predlozi u welcome ekranu — isti izgled kao chat predlozi */
.agent-suggest {
  text-align: left;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color .15s, box-shadow .15s;
}
.agent-suggest:hover { border-color: hsl(var(--primary)); box-shadow: 0 2px 10px -4px hsl(var(--primary) / 0.5); }
.agent-suggest strong { font-size: 13.5px; }
.agent-suggest span { font-size: 12.5px; color: hsl(var(--muted-foreground)); }

/* ── Ponavljajuće (zakazane) komande agenta ─────────────────────────────── */
.agent-sched-list {
  background: hsl(var(--muted) / 0.5);
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 12px;
}
.agent-sch {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 13px;
}
.agent-sch-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agent-sch-on, .agent-sch-off {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.agent-sch-on { background: hsl(var(--success) / 0.15); color: hsl(var(--success)); }
.agent-sch-off { background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); }
.agent-sch-when { color: hsl(var(--primary)); font-weight: 600; margin-top: 4px; }
.agent-sch-cmd {
  color: hsl(var(--muted-foreground));
  margin-top: 4px;
  font-style: italic;
  overflow-wrap: anywhere;
}
.agent-sch-meta { color: hsl(var(--muted-foreground)); font-size: 12px; margin-top: 4px; }
.agent-sch-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.agent-sch-actions button { font-size: 12.5px; padding: 5px 10px; }

/* ── Plutajući agent (dole desno, na svakoj stranici) ───────────────────── */

/* Kontejner je fiksan i iznad svega osim modala; sam po sebi ne hvata klikove
   (pointer-events:none) da ne bi blokirao sadržaj ispod — samo dugme i panel hvataju. */
#agent-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  pointer-events: none;
}
#agent-widget > * { pointer-events: auto; }

.agent-widget-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, hsl(var(--primary)), hsl(var(--primary) / 0.75));
  box-shadow: 0 10px 26px -8px hsl(var(--primary) / 0.7), 0 2px 6px rgba(0,0,0,.18);
  transition: transform .15s ease, box-shadow .2s ease;
}
.agent-widget-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px -10px hsl(var(--primary) / 0.8), 0 3px 8px rgba(0,0,0,.2);
}
.agent-widget-btn.hidden { display: none; }

.agent-widget-panel {
  display: none;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 96px);
  flex-direction: column;
  overflow: hidden;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  box-shadow: 0 24px 60px -18px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.12);
}
.agent-widget-panel.open { display: flex; }

.agent-w-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid hsl(var(--border));
  background: linear-gradient(90deg, hsl(var(--primary) / 0.1), transparent);
  flex: none;
}
.agent-w-ico { font-size: 18px; }
.agent-w-title { min-width: 0; flex: 1; line-height: 1.25; }
.agent-w-title strong { display: block; font-size: 14px; }
.agent-w-title span {
  display: block;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-w-ibtn {
  background: transparent;
  border: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 6px;
  flex: none;
}
.agent-w-ibtn:hover { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }

.agent-w-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  font-size: 13px;
}
.agent-w-messages .msg { font-size: 13px; }
.agent-w-messages .agent-proposal { padding: 11px 12px; }
.agent-w-messages .agent-proposal-body { font-size: 12px; max-height: 180px; }

.agent-w-welcome {
  color: hsl(var(--muted-foreground));
  font-size: 12.5px;
  line-height: 1.7;
}
.agent-w-welcome p { margin: 0 0 4px; }
.agent-w-welcome p:first-child { color: hsl(var(--foreground)); font-size: 14px; margin-bottom: 8px; }

.agent-w-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid hsl(var(--border));
  flex: none;
}
.agent-w-form input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 13px;
}
.agent-w-form input:focus {
  outline: 0;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.15);
}
.agent-w-form button { padding: 9px 14px; border-radius: 10px; }

/* Prolazni indikator „Agent radi…" — nije deo istorije razgovora */
.agent-working {
  margin: 6px 0 10px;
  padding: 8px 12px;
  border: 1px solid hsl(var(--primary) / 0.3);
  background: hsl(var(--primary) / 0.07);
  border-radius: 10px;
  font-size: 13px;
  color: hsl(var(--primary));
  font-weight: 500;
}
.agent-working-dot { animation: agent-puls 1.2s ease-in-out infinite; }
@keyframes agent-puls { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Na telefonu panel zauzima skoro ceo ekran — inače je neupotrebljiv */
@media (max-width: 560px) {
  #agent-widget { right: 12px; bottom: 12px; }
  .agent-widget-btn { width: 52px; height: 52px; font-size: 24px; }
  .agent-widget-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 90px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-widget-btn { transition: none; }
  .agent-working-dot { animation: none; }
}

/* ── Mobile (responsive) ─────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Korenska popravka (minmax(0,1fr) + .main-col min-width:0) je u OSNOVNOM
     CSS-u, ne ovde — vidi komentar kod .app-shell. Ovde ostaje samo suzavanje
     sidebar-a na traku sa ikonicama. */
  .app-shell { grid-template-columns: 60px minmax(0, 1fr); }
  .main-content { min-width: 0; padding: 14px; }
  .tab-content { min-width: 0; }

  /* ═══ Sidebar — samo ikonice ═════════════════════════════════════════════ */
  .app-shell .sidebar-logo-text,
  .app-shell .nav-label,
  .app-shell .sidebar-section,
  .app-shell .sidebar-footer { display: none; }
  .app-shell .nav-item {
    justify-content: center;
    padding: 10px 8px;
    min-height: 44px;          /* meta za prst */
  }
  .sidebar-toggle { min-width: 40px; min-height: 40px; }

  /* ═══ Topbar ═════════════════════════════════════════════════════════════
     Bio je height:60px sa 9 stavki — stavke su se prelamale i PREKRIVALE
     naslov stranice ispod. Sada: gornji red su dugmad i korisnik, a pilule
     sa stanjem kredita idu u DRUGI red preko cele sirine koji se prevlaci
     prstom (da se ne spljoste na 40px i postanu neupotrebljive).             */
  .topbar {
    height: auto;
    min-height: 52px;
    padding: 8px 10px;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
  }
  .status-bar {
    order: 2;
    flex: 1 0 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    min-width: 0;
    padding-bottom: 2px;
  }
  .status-bar::-webkit-scrollbar { display: none; }
  .status-pill { white-space: nowrap; flex: 0 0 auto; font-size: 12px; }
  .topbar-spacer { flex: 1; }      /* gura dugmad desno u prvom redu */
  #st-user {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .status-item { font-size: 12px; padding: 3px 8px; }

  /* ═══ Forme u jednu kolonu ═══════════════════════════════════════════════ */
  .form-row { grid-template-columns: 1fr; }
  .form-card, .card { min-width: 0; }

  /* ═══ Statistike: dve kartice po redu (bilo jedna — predugacka stranica) ══ */
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

  /* ═══ Kanban kolone uze, da se vidi da ih ima jos desno ══════════════════ */
  .pipe-col { flex: 0 0 78vw; max-width: 300px; }

  /* ═══ Podtabovi — prevlacenje umesto prelamanja ══════════════════════════ */
  .subtabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    min-width: 0;
  }
  .subtabs::-webkit-scrollbar { display: none; }
  .subtab { flex: 0 0 auto; white-space: nowrap; min-height: 40px; }

  /* ═══ Tabele — klizaju same umesto da razvlace stranicu ══════════════════ */
  table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  th, td { white-space: nowrap; }

  /* ═══ Tekst nikad ispod 12px ═════════════════════════════════════════════
     Selektori moraju biti bar jednako specificni kao originalni
     (npr. "table thead th"), inace pravilo ne prolazi.                       */
  table thead th { font-size: 12px; }
  .badge { font-size: 12px; }
  .chat-char-count, #chat-char-count { font-size: 12px; }

  /* ═══ Mete za prst — minimum 40px ════════════════════════════════════════ */
  button, .btn, .btn-primary, .btn-secondary, .btn-ghost, .chip, a.btn-ghost {
    min-height: 40px;
  }
  /* Dugmici sa samo ikonicom bili su siroki 24px — preusko za prst */
  .btn-ghost, a.btn-ghost, .btn-refresh { min-width: 40px; }
  select, input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="url"], input[type="datetime-local"] {
    min-height: 40px;
  }
  input[type="checkbox"], input[type="radio"] {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
  }
  .checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
  }

  /* ═══ Izbor fajla: naziv fajla mora da se vidi ═══════════════════════════
     Dugmici pored njega su ga stiskali na ~90px ("-- izab⌄").               */
  .file-select-row { flex-wrap: wrap; }
  .file-select-row select { flex: 1 1 100%; min-width: 0; }

  /* ═══ Kanban tabla — horizontalno klizanje (7 kolona nikad ne stane) ═════ */
  #pipeline-board { max-width: 100%; }

  /* ═══ Mete za prst: minimum 40px (bilo 18-30px) ══════════════════════════ */
  .icon-btn,
  .btn-status-refresh,
  .btn-refresh {
    min-width: 40px;
    min-height: 40px;
  }

  /* ═══ Chat ═══════════════════════════════════════════════════════════════ */
  .chat-header { flex-wrap: wrap; }
  .chat-header-actions { flex-wrap: wrap; }
  .chat-input-row { min-width: 0; }
  .chat-input-wrap { min-width: 0; }
  .chat-messages { min-height: 320px; }

  /* Duge reci / URL-ovi / email adrese ne smeju da probiju ekran */
  .card, .form-card, .chat-messages, .log-box, p, li {
    overflow-wrap: anywhere;
  }
}

/* ── Vrlo uski telefoni (iPhone SE i slicni) ─────────────────────────────── */
@media (max-width: 400px) {
  .app-shell { grid-template-columns: 52px minmax(0, 1fr); }
  .main-content { padding: 10px; }
  .topbar { padding: 6px 8px; }
  #st-user { max-width: 28vw; }
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.text-muted { color: hsl(var(--muted-foreground)); }
.text-success { color: hsl(var(--success)); }
.text-danger { color: hsl(var(--destructive)); }
.text-warning { color: hsl(var(--warning)); }
.text-primary { color: hsl(var(--primary)); }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

/* ══ Danas + Kampanje (glavni tok rada, 09/2026) ════════════════════════════ */
#company-modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(2px);
}
.btn-sm { padding: 4px 10px !important; font-size: 12px !important; }
a.btn-ghost, a.btn-secondary, a.btn-primary { text-decoration: none; display: inline-flex; align-items: center; }
.sidebar-opcija { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 400;
  color: hsl(var(--muted-foreground)); padding: 6px 14px; cursor: pointer; }
.sidebar-opcija input { width: auto; margin: 0; }
.app-shell.collapsed .sidebar-opcija { display: none; }

.zadaci-panel { position: fixed; top: 56px; right: 16px; z-index: 90; width: min(420px, calc(100vw - 32px));
  max-height: 60vh; overflow-y: auto; box-shadow: var(--shadow-lg); }

.danas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-bottom: 16px; }
.danas-grid .card h3 { margin: 0 0 10px 0; font-size: 15px; }
.danas-stavka { padding: 8px 0; border-bottom: 1px solid hsl(var(--border)); }
.danas-stavka:last-child { border-bottom: 0; }
.danas-klik { cursor: pointer; border-radius: 6px; padding: 8px; }
.danas-klik:hover { background: hsl(var(--accent)); }
.danas-stavka-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.danas-mali { font-size: 12px; margin-top: 3px; }
.danas-citat { font-size: 13px; margin: 6px 0; padding: 6px 10px; border-left: 3px solid hsl(var(--primary));
  background: hsl(var(--muted)); border-radius: 0 6px 6px 0; white-space: pre-wrap; }
.danas-akcije { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.danas-radi { margin-bottom: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.kamp-detalj-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.kamp-kartica { cursor: pointer; margin-bottom: 12px; transition: border-color .15s; }
.kamp-kartica:hover { border-color: hsl(var(--primary)); }
.kamp-kartica-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.kamp-brojke { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: hsl(var(--muted-foreground)); }
.kamp-brojke b { color: hsl(var(--foreground)); }
.kamp-poruka { margin: 6px 0 12px; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  background: hsl(var(--primary) / 0.08); border: 1px solid hsl(var(--primary) / 0.25); }
.kamp-koraci { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.kamp-korak { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground)); }
.kamp-korak.gotovo { color: hsl(var(--success)); border-color: hsl(var(--success) / 0.4); }
.kamp-korak.trenutno { color: hsl(var(--primary)); border-color: hsl(var(--primary)); font-weight: 600; }
.kamp-stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kamp-stats .stat-value { font-size: 22px; }
.kamp-stats .stat-label { white-space: normal; overflow-wrap: anywhere; }
.kamp-akcije { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
.kamp-tabovi { margin-top: 8px; }
.kamp-filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.kamp-filter input[type="text"] { max-width: 320px; }
.kamp-filter select { width: auto; }
.kamp-tabela { overflow-x: auto; }
.kamp-tabela table { width: 100%; font-size: 13px; }
.kamp-tabela td { padding: 5px 6px; vertical-align: top; }
.kamp-red-akcije { white-space: nowrap; }
.kamp-log-head { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-top: 12px; font-size: 13px; }
.poziv-kartica { margin-bottom: 10px; }
.poziv-ishod { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.poziv-ishod select, .poziv-ishod input { width: auto; flex: 1 1 140px; }

.pipeline-board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 12px; }
.pipe-col { background: hsl(var(--muted)); border-radius: 8px; padding: 10px; max-height: 75vh; overflow-y: auto; }
.pipe-col-head { font-weight: 700; padding-bottom: 8px; border-bottom: 2px solid; }
.pipe-card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: 6px;
  padding: 8px; margin-bottom: 6px; cursor: pointer; font-size: 12px; }
.pipe-card:hover { border-color: hsl(var(--primary)); }

.dash-mesec { display: flex; align-items: center; gap: 6px; font-size: 12px; margin: 4px 0; }
.dash-mesec-ime { width: 64px; color: hsl(var(--muted-foreground)); flex-shrink: 0; }
.dash-bar { display: inline-block; height: 10px; border-radius: 3px; background: hsl(var(--primary)); min-width: 2px; }
.dash-bar-fu { background: hsl(var(--primary) / 0.45); }

@media (max-width: 768px) {
  .sidebar-opcija { display: none; }
  .danas-grid { grid-template-columns: 1fr; }
  .kamp-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── WHR: izbor pokrajina, kartice poziva ───────────────────────────────── */
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 12px; margin: 6px 0 10px 0; }
.chk-grid .checkbox-label { font-size: 12.5px; }
#kamp-nova-forma .form-row > div .checkbox-label { display: flex; margin: 2px 0; }
#kamp-nova-forma .card .checkbox-label { display: flex; align-items: flex-start; margin: 4px 0; }
@media (max-width: 768px) {
  .chk-grid { grid-template-columns: repeat(2, 1fr); }
}
