/* EuroTim AI — frontend stilovi (brand: lime #b0d040, tekst #505050) */

:root {
  --brand: #b0d040;
  --brand-dark: #95b033;
  --brand-darker: #6e8520;
  --brand-light: #e9f4cc;
  --brand-bg: #f7fbe9;
  --text: #2a2a2a;
  --text-soft: #505050;
  --text-muted: #888;
  --border: #e3e3e3;
  --border-soft: #ececec;
  --bg: #f5f6f4;
  --card-bg: #ffffff;
  --warn-bg: #fff8e1;
  --warn-text: #6b4d00;
  --warn-border: #f0c14b;
  --error-bg: #fdecea;
  --error-text: #a3261c;
  --error-border: #f5b6af;
  --info-bg: #eef7d6;
  --info-text: var(--brand-darker);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(40, 60, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(40, 60, 0, 0.1);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ===== Navbar ===== */
.navbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.navbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
}
.navbar .brand img { height: 32px; width: auto; display: block; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a {
  color: var(--text-soft);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover { background: var(--brand-light); color: var(--brand-darker); }
.nav-links a.active { background: var(--brand); color: #fff; }
.nav-links .logout-btn {
  margin-left: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.nav-links .logout-btn:hover { background: var(--error-bg); color: var(--error-text); border-color: var(--error-border); }
.nav-links .user-name { color: var(--text-muted); font-size: 13px; padding: 0 6px; }

/* ===== Container ===== */
.container { max-width: 1180px; margin: 24px auto; padding: 0 18px; }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 16px; color: var(--text); }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; color: var(--text); }
.muted { color: var(--text-muted); font-size: 13px; }
code { background: #f0f0f0; padding: 1px 6px; border-radius: 3px; font-size: 12.5px; }

/* ===== Card ===== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
input[type="text"], input[type="email"], input[type="number"], input[type="password"],
input[type="date"], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-dark);
  box-shadow: 0 0 0 3px var(--brand-light);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input[type="checkbox"] { width: auto; margin-right: 6px; vertical-align: middle; }

.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.05s;
}
button:hover:not(:disabled), .btn:hover { background: var(--brand-dark); }
button:active { transform: translateY(1px); }
button:disabled { background: #c7c7c7; cursor: not-allowed; }
.btn-secondary {
  background: #fff; color: var(--text-soft); border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--brand-light); color: var(--brand-darker); border-color: var(--brand); }
.btn-ghost {
  background: transparent; color: var(--brand-darker); border: none; padding: 6px 10px; font-weight: 600;
}
.btn-ghost:hover { background: var(--brand-light); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 10px 20px; background: transparent; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  border-radius: 0; transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text-soft); background: transparent; }
.tab.active { color: var(--brand-darker); border-bottom-color: var(--brand); background: transparent; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-ai { color: #b8860b; }
.tab-ai.active { color: #8a6d00; border-bottom-color: #f5b301; }

/* AI Asistent — istaknuti nav link (zvjezdica, gore desno) */
.nav-links a.ai-link {
  background: linear-gradient(135deg, #fff7e0, #ffe7a3);
  color: #8a6d00; font-weight: 600; border: 1px solid #f0d27a;
}
.nav-links a.ai-link:hover { background: linear-gradient(135deg, #ffe7a3, #ffd866); color: #6b5400; }
.nav-links a.ai-link.active { background: linear-gradient(135deg, #f5b301, #e3950a); color: #fff; border-color: #d98e00; }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: top; }
th { background: var(--brand-bg); color: var(--text-soft); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:hover td { background: #fafafa; }
.num, th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Alerts ===== */
.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin: 10px 0; font-size: 13.5px; border: 1px solid; }
.alert-error { background: var(--error-bg); color: var(--error-text); border-color: var(--error-border); }
.alert-warn  { background: var(--warn-bg);  color: var(--warn-text);  border-color: var(--warn-border); }
.alert-info  { background: var(--info-bg);  color: var(--info-text);  border-color: var(--brand); }

/* ===== Totals box (rezultat upita) ===== */
.totals-box { margin-top: 16px; padding: 14px 18px; background: var(--brand-bg); border: 1px solid var(--brand-light); border-radius: var(--radius); }
.total-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.total-row.popust { color: #b85c00; }
.total-row.final { font-size: 17px; font-weight: 700; color: var(--brand-darker); border-top: 2px solid var(--brand); margin-top: 8px; padding-top: 10px; }

/* ===== Badge ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11.5px; font-weight: 600; background: var(--brand-light); color: var(--brand-darker); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }

/* ===== Prilozi u admin tablici ===== */
.prilozi-list { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.prilog-img, .prilog-pdf {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 4px; overflow: hidden;
  border: 1px solid var(--border); flex-shrink: 0; text-decoration: none;
  transition: transform 0.1s, border-color 0.15s;
}
.prilog-img:hover, .prilog-pdf:hover { border-color: var(--brand); transform: scale(1.08); }
.prilog-img img { width: 100%; height: 100%; object-fit: cover; }
.prilog-pdf {
  background: #fef0e6; color: #b85c00;
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
}

/* ===== Spinner ===== */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid #fff; border-top-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Details (meta override) ===== */
.meta-details {
  margin: 14px 0 6px;
  padding: 12px 16px;
  border: 1px dashed var(--brand);
  border-radius: var(--radius-sm);
  background: var(--brand-bg);
}
.meta-details summary {
  cursor: pointer; font-weight: 600; color: var(--brand-darker);
  margin: -2px 0 4px; user-select: none;
}
.meta-details[open] summary { margin-bottom: 10px; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h2 { margin-top: 0; }
.modal .close-x {
  float: right; background: transparent; color: var(--text-muted); padding: 0;
  font-size: 22px; line-height: 1; border: none; cursor: pointer;
}
.modal .close-x:hover { background: transparent; color: var(--error-text); }

/* ===== File upload ===== */
.file-drop {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 18px; text-align: center; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s; background: #fafafa;
}
.file-drop:hover, .file-drop.dragging { border-color: var(--brand); background: var(--brand-bg); color: var(--brand-darker); }
.file-drop input { display: none; }
.file-list { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; }
.file-thumb {
  position: relative; width: 80px; height: 80px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: #f0f0f0;
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb.is-pdf { background: #fef0e6; border-color: #f0b890; }
.file-thumb .pdf-icon {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #b85c00; font-weight: 700; font-size: 14px; line-height: 1.2;
  text-align: center;
}
.file-thumb .pdf-icon small { font-weight: normal; font-size: 9px; opacity: 0.75; margin-top: 4px; }
.file-thumb .rm {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,0.6); color: #fff; border: none;
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0;
}

/* ===== Login page ===== */
body.login-page {
  background: linear-gradient(135deg, var(--brand-bg) 0%, #fff 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff; padding: 36px 32px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 380px; text-align: center;
}
.login-logo { width: 200px; max-width: 100%; height: auto; margin-bottom: 14px; }
.login-card h1 { margin: 8px 0 4px; }
.login-card p { margin: 0 0 22px; }
.login-card form { text-align: left; }
.login-card .btn-row { margin-top: 18px; }
.login-card button { width: 100%; }

/* ===== Chat ===== */
.chat-shell { display: flex; flex-direction: column; height: calc(100vh - 130px); max-height: 800px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; background: #fafafa; border-radius: var(--radius); border: 1px solid var(--border); }
.chat-msg { margin-bottom: 14px; display: flex; gap: 10px; }
.chat-msg .avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: #fff; }
.chat-msg.user .avatar { background: var(--text-soft); }
.chat-msg.assistant .avatar { background: var(--brand); }
.chat-msg .bubble { background: #fff; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-soft); max-width: 80%; white-space: pre-wrap; line-height: 1.5; font-size: 14px; }
.chat-msg.user .bubble { background: var(--brand-bg); border-color: var(--brand-light); }
.chat-form { display: flex; gap: 8px; padding-top: 12px; }
.chat-form textarea { min-height: 56px; max-height: 200px; }
.chat-form button { align-self: stretch; padding: 0 22px; }

.tool-actions { margin-bottom: 8px; display: flex; flex-direction: column; gap: 4px; }
.tool-action {
  font-size: 12.5px; padding: 5px 10px; border-radius: 5px;
  font-family: "DejaVu Sans Mono", "Menlo", monospace;
  border: 1px solid;
}
.tool-action.tool-ok { background: var(--brand-bg); color: var(--brand-darker); border-color: var(--brand-light); }
.tool-action.tool-err { background: var(--error-bg); color: var(--error-text); border-color: var(--error-border); }
.tool-action span { font-family: "Inter", sans-serif; }
.tool-action a { color: var(--brand-darker); font-weight: 600; }
.bubble code { background: rgba(0,0,0,0.04); padding: 1px 5px; border-radius: 3px; font-size: 12.5px; }
.bubble a { color: var(--brand-darker); }

/* ===== Mobile ===== */
@media (max-width: 700px) {
  .navbar { padding: 10px 14px; flex-direction: column; gap: 10px; align-items: stretch; }
  .navbar .brand { justify-content: center; }
  .nav-links { justify-content: center; flex-wrap: wrap; }
  .container { margin: 12px auto; padding: 0 12px; }
  .card { padding: 14px; }
  h1 { font-size: 18px; }
  table { font-size: 12.5px; }
  th, td { padding: 8px 6px; }
  .btn-row { flex-direction: column; }
  .btn-row .btn, .btn-row button { width: 100%; }
  .tab { padding: 8px 14px; font-size: 13px; }
  .login-card { padding: 24px 18px; }
}

/* ===== Plutajući AI chat widget (dolje desno) ===== */
.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #f5b301, #e3950a); color: #fff;
  font-size: 26px; line-height: 1; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.ai-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 8px 26px rgba(0,0,0,0.3); }
.ai-widget {
  position: fixed; right: 22px; bottom: 92px; z-index: 200;
  width: 400px; max-width: calc(100vw - 28px);
  height: 600px; max-height: calc(100vh - 130px);
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 14px 44px rgba(0,0,0,0.28); border: 1px solid var(--border);
  display: none; flex-direction: column;
}
.ai-widget.open { display: flex; }
.ai-widget-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; font-weight: 600;
  background: linear-gradient(135deg, #f5b301, #e3950a); color: #fff;
}
.ai-widget-head button { background: transparent; border: none; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }
.ai-widget iframe { flex: 1; width: 100%; border: none; display: block; }
@media (max-width: 480px) {
  .ai-widget { right: 8px; left: 8px; width: auto; bottom: 84px; height: calc(100vh - 100px); }
  .ai-fab { right: 16px; bottom: 16px; }
}

/* ===== Embed mod (chat unutar plutajućeg widgeta: /chat.html?embed=1) ===== */
html.embed { background: #fff; }
html.embed .navbar { display: none; }
html.embed .container { margin: 0; padding: 0; max-width: none; }
html.embed .container > h1, html.embed .container > p.muted { display: none; }
html.embed .card { border: none; box-shadow: none; border-radius: 0; margin: 0; padding: 8px 12px; }
html.embed .chat-shell { height: calc(100vh - 16px); max-height: none; }
