/* =========================================================================
   Naj Naj Lepinje — dizajn tokeni, reset, tipografija i osnovne komponente
   ========================================================================= */
:root {
  /* Boje — tople krem nijanse, boja pečenog testa, tamnosmeđi tekst */
  --cream-50: #FDFAF4;
  --cream-100: #FAF4EA;
  --cream-200: #F3E9D8;
  --cream-300: #E9DAC1;
  --crust-300: #DDB27A;
  --crust-400: #C98E4E;
  --crust-500: #A8662B;
  --crust-600: #8C5222;
  --crust-700: #6E3F1A;
  --brown-900: #1E1611;
  --brown-800: #2B2019;
  --brown-700: #4A3A2E;
  --brown-500: #7A6858;
  --brown-400: #9C8B7A;

  --bg: var(--cream-100);
  --surface: #FFFFFF;
  --surface-2: var(--cream-50);
  --surface-3: var(--cream-200);
  --border: #EADFCD;
  --border-strong: #DCCBB0;
  --text: var(--brown-900);
  --text-2: var(--brown-700);
  --muted: var(--brown-500);
  --primary: var(--crust-500);
  --primary-hover: var(--crust-600);
  --primary-soft: #F6E8D4;
  --primary-ink: #FFFFFF;
  --focus: rgba(168, 102, 43, .32);

  --st-nova: #2A63B8;      --st-nova-bg: #E8F0FB;
  --st-potvrdjena: #9A6200; --st-potvrdjena-bg: #FCF0D7;
  --st-zavrsena: #1F7A3E;  --st-zavrsena-bg: #E3F3E8;
  --st-otkazana: #B3362F;  --st-otkazana-bg: #FBE7E5;
  --danger: #B3362F;
  --success: #1F7A3E;
  --warning: #9A6200;

  /* Tipografija */
  --font-display: 'Fraunces', 'Georgia', serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Oblici i senke */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --shadow-xs: 0 1px 2px rgba(43, 32, 25, .06);
  --shadow-sm: 0 1px 2px rgba(43, 32, 25, .05), 0 2px 8px rgba(43, 32, 25, .05);
  --shadow: 0 2px 6px rgba(43, 32, 25, .05), 0 12px 32px rgba(43, 32, 25, .08);
  --shadow-lg: 0 10px 30px rgba(43, 32, 25, .12), 0 30px 80px rgba(43, 32, 25, .16);
  --ease: cubic-bezier(.2, .7, .2, 1);

  --sidebar-w: 264px;
  --topbar-h: 64px;
  --demobar-h: 36px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body.no-scroll { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
svg.ic { display: inline-block; flex-shrink: 0; vertical-align: middle; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--crust-300); color: var(--brown-900); }

.skip { position: absolute; left: -999px; top: 8px; z-index: 999; background: var(--brown-900); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip:focus { left: 8px; }

/* ------------------------------- Dugmad ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 11px;
  font-weight: 600; font-size: 14.5px; white-space: nowrap;
  border: 1px solid transparent;
  transition: background .18s var(--ease), border-color .18s, color .18s, transform .12s, box-shadow .18s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 4px 14px rgba(168, 102, 43, .28); }
.btn--primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn--dark { background: var(--brown-900); color: #fff; }
.btn--dark:hover:not(:disabled) { background: var(--brown-800); }
.btn--ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--crust-300); }
.btn--soft { background: var(--primary-soft); color: var(--crust-700); }
.btn--soft:hover:not(:disabled) { background: #F0DCC0; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #962a24; }
.btn--danger-ghost { background: var(--surface); color: var(--danger); border-color: #EBC4C0; }
.btn--danger-ghost:hover:not(:disabled) { background: var(--st-otkazana-bg); }
.btn--link { height: auto; padding: 0; color: var(--primary); font-weight: 600; }
.btn--link:hover { color: var(--primary-hover); text-decoration: underline; }
.btn--sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; gap: 6px; }
.btn--lg { height: 52px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn--block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-color: rgba(255,255,255,.9) rgba(255,255,255,.9) transparent transparent; animation: spin .7s linear infinite; }
.btn--ghost.is-busy::after { border-color: var(--primary) var(--primary) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 11px; color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn--sm { width: 32px; height: 32px; border-radius: 9px; }
.link-btn { color: var(--primary); font-weight: 600; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }

/* ------------------------------- Forme ------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field__label small { font-weight: 500; color: var(--muted); }
.field__hint { font-size: 12.5px; color: var(--muted); }
.field__error { font-size: 12.5px; color: var(--danger); font-weight: 500; }
.field--error .input { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(179, 54, 47, .12); }
.input {
  width: 100%; height: 44px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 11px;
  transition: border-color .15s, box-shadow .15s;
  font-size: 15px;
}
.input::placeholder { color: var(--brown-400); }
.input:hover { border-color: var(--crust-300); }
.input:focus { outline: none; border-color: var(--crust-400); box-shadow: 0 0 0 4px var(--focus); }
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237A6858' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
.input--sm { height: 36px; font-size: 14px; border-radius: 9px; padding: 0 12px; }
select.input--sm { padding-right: 34px; background-position: right 10px center; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 40px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 40px; height: 24px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .2s; flex-shrink: 0; }
.switch__track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform .2s var(--ease); }
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--focus); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 11px; gap: 2px; flex-wrap: wrap; }
.segmented button { height: 32px; padding: 0 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ------------------------------- Bedževi ------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.badge--nova { color: var(--st-nova); background: var(--st-nova-bg); }
.badge--potvrdjena { color: var(--st-potvrdjena); background: var(--st-potvrdjena-bg); }
.badge--zavrsena { color: var(--st-zavrsena); background: var(--st-zavrsena-bg); }
.badge--otkazana { color: var(--st-otkazana); background: var(--st-otkazana-bg); }
.badge--muted { color: var(--text-2); background: var(--surface-3); }
.badge--success { color: var(--success); background: var(--st-zavrsena-bg); }
.badge--danger { color: var(--danger); background: var(--st-otkazana-bg); }
.badge--warning { color: var(--warning); background: var(--st-potvrdjena-bg); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--crust-700); white-space: nowrap; }
.tag--demo { background: #FFF1C9; color: #7A5600; }

/* ------------------------------- Avatar ------------------------------- */
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--crust-300), var(--crust-500)); color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; letter-spacing: .02em; }
.avatar--sq { border-radius: 10px; background: linear-gradient(135deg, var(--brown-700), var(--brown-900)); }
.avatar--lg { width: 52px; height: 52px; font-size: 17px; border-radius: 14px; }

/* ------------------------------- Toast ------------------------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 500; display: flex; flex-direction: column; gap: 10px; pointer-events: none; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 400px; padding: 13px 14px; background: var(--brown-900); color: #fff; border-radius: 13px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500; transform: translateY(12px); opacity: 0; transition: transform .25s var(--ease), opacity .25s; }
.toast.in { transform: none; opacity: 1; }
.toast > .ic { margin-top: 1px; }
.toast--success > .ic { color: #7ED69B; }
.toast--error > .ic { color: #FF9C93; }
.toast--info > .ic, .toast--warning > .ic { color: var(--crust-300); }
.toast__msg { flex: 1; }
.toast__x { opacity: .6; padding: 2px; }
.toast__x:hover { opacity: 1; }

/* ------------------------------- Modal ------------------------------- */
.modal { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(30, 22, 17, .45); backdrop-filter: blur(3px); opacity: 0; transition: opacity .22s; }
.modal__panel { position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); transform: translateY(14px) scale(.98); opacity: 0; transition: transform .24s var(--ease), opacity .22s; outline: none; }
.modal--sm .modal__panel { max-width: 420px; }
.modal--lg .modal__panel { max-width: 780px; }
.modal.open .modal__backdrop { opacity: 1; }
.modal.open .modal__panel { transform: none; opacity: 1; }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 22px 12px; }
.modal__title { font-size: 18px; font-weight: 700; }
.modal__sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.modal__body { padding: 8px 22px 20px; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); flex-wrap: wrap; }
.modal--drawer { place-items: stretch end; padding: 0; }
.modal--drawer .modal__panel { max-width: 560px; height: 100%; max-height: none; border-radius: 0; transform: translateX(30px); }
.modal--drawer .modal__foot { border-radius: 0; }
.modal--drawer.open .modal__panel { transform: none; }

/* ------------------------------- Dropdown ------------------------------- */
.dropdown { position: relative; }
.dropdown__menu { position: absolute; top: calc(100% + 8px); left: 0; z-index: 120; min-width: 240px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .16s, transform .16s var(--ease), visibility .16s; }
.dropdown--right .dropdown__menu { left: auto; right: 0; }
.dropdown.open .dropdown__menu { opacity: 1; visibility: visible; transform: none; }
.dropdown__head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; gap: 3px; }
.dropdown__head small { color: var(--muted); font-size: 12.5px; }
.dropdown__head .tag { align-self: flex-start; margin-top: 6px; }
.dropdown__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 9px; font-size: 14px; color: var(--text-2); text-align: left; }
.dropdown__item:hover { background: var(--surface-2); color: var(--text); }

/* ------------------------------- Ostalo ------------------------------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty__ic { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--crust-600); }
.empty h4 { color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty p { max-width: 380px; margin: 0 auto; font-size: 14px; }
.skeleton { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.skeleton__row { height: 16px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 0%, var(--cream-50) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton__row:nth-child(2n) { width: 80%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: var(--primary-soft); color: var(--crust-700); font-size: 14px; }
.notice .ic { margin-top: 2px; }
.notice--info { background: var(--st-nova-bg); color: #1E4A8A; }
.notice--warn { background: #FFF4D6; color: #6E4E00; }

.text-muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.text-sm { font-size: 13.5px; }
.text-xs { font-size: 12.5px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.fw-600 { font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 24px; } .mt-6 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hide { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .modal { padding: 0; place-items: end stretch; }
  .modal__panel { max-width: none !important; max-height: 92vh; border-radius: 20px 20px 0 0; transform: translateY(40px); }
  .modal__foot { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal__foot .btn { flex: 1; }
  .modal--drawer .modal__panel { height: 94vh; border-radius: 20px 20px 0 0; transform: translateY(40px); }
  .toasts { left: 16px; right: 16px; bottom: 84px; }
  .toast { min-width: 0; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
