/* ============================================================
   FRESCO JEDILNIK — main.css
   ============================================================ */

:root {
  --red:       #8B0000;
  --red-hover: #a30000;
  --red-light: #fff0f0;
  --white:     #ffffff;
  --bg:        #f2f2f2;
  --card:      #ffffff;
  --border:    #d8d8d8;
  --text:      #1a1a1a;
  --muted:     #666666;
  --green:     #2a6e2a;
  --radius:    5px;
  --shadow:    0 1px 4px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── HEADER ──────────────────────────────────────────────── */
.site-header {
  background: var(--red);
  padding: .6rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
  min-height: 58px;
}

.header-logo {
  height: 38px;
  width: auto;
  display: block;
}

.header-name {
  color: var(--white);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: .03em;
}

.logout-btn {
  position: absolute;
  left: 1.25rem;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  padding: .3rem .75rem;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: rgba(255,255,255,.18); color: var(--white); }

/* ── LAYOUT ──────────────────────────────────────────────── */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 960px) {
  .editor-layout { grid-template-columns: 1fr; }
}

/* ── CARDS ───────────────────────────────────────────────── */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .45rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-primary   { background: var(--red);   color: var(--white); border-color: var(--red); }
.btn-primary:hover { background: var(--red-hover); border-color: var(--red-hover); }
.btn-secondary { background: var(--white); color: var(--text);  border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.add-btn { margin-top: .6rem; font-size: .8rem; }

/* ── FORM TOP BAR (print btn + save indicator) ───────────── */
.form-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
}

.btn-outline-print {
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: .55rem 1.4rem;
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  transition: background .15s;
  box-shadow: 0 1px 4px rgba(139,0,0,.25);
}
.btn-outline-print:hover { background: var(--red-hover); }

/* ── SAVE INDICATOR ──────────────────────────────────────── */
.save-indicator {
  font-size: .78rem;
  font-weight: 500;
}
.save-indicator.saving { color: var(--muted); }
.save-indicator.saved  { color: var(--green); }
.save-indicator.error  { color: #b00; }

/* ── SECONDARY ACTION ROW (below calendar) ───────────────── */
.form-secondary-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  margin: .75rem 0 1rem;
}

/* ── SECTION LABELS ──────────────────────────────────────── */
.section-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red);
  border-bottom: 2px solid var(--red);
  padding-bottom: .2rem;
  margin-bottom: .6rem;
}

/* ── ENTRY ROWS ──────────────────────────────────────────── */
.entry-row,
.ponudba-row {
  display: flex;
  gap: .4rem;
  align-items: flex-start;
  margin-bottom: .45rem;
}

.autocomplete-wrapper { flex: 1; position: relative; }

.desc-input {
  width: 100%;
  padding: .4rem .55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  font-family: inherit;
  resize: vertical;
  min-height: 52px;
  transition: border-color .15s;
}
.desc-input:focus { outline: none; border-color: var(--red); }

#kosilo_desc { overflow: hidden; resize: none; }

.price-col { display: flex; align-items: center; gap: .15rem; }

.price-input {
  width: 64px;
  padding: .4rem .4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .88rem;
  text-align: right;
  transition: border-color .15s;
}
.price-input:focus { outline: none; border-color: var(--red); }

.eur { font-size: .82rem; color: var(--muted); user-select: none; }

.row-num {
  font-size: .8rem;
  color: var(--muted);
  width: 1.5rem;
  flex-shrink: 0;
  text-align: right;
  padding-top: .55rem;
  user-select: none;
}

.remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #c0c0c0;
  font-size: 1.2rem;
  line-height: 1;
  padding: .25rem .35rem;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
  flex-shrink: 0;
  margin-top: .2rem;
}
.remove-btn:hover { color: var(--red); background: var(--red-light); }


/* ── HTMX SPINNER ────────────────────────────────────────── */
.spinner {
  display: none;
  width: 14px; height: 14px;
  border: 2px solid rgba(139,0,0,.2);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
.htmx-request .spinner,
.htmx-request.spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── AUTOCOMPLETE ────────────────────────────────────────── */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  z-index: 200;
  max-height: 240px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: .45rem .65rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .6rem;
  font-size: .84rem;
  border-bottom: 1px solid #f0f0f0;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.ac-selected { background: #fdf5f5; }
.autocomplete-item .ac-desc  { flex: 1; }
.autocomplete-item .ac-price { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.ac-mark { background: none; color: var(--red); font-weight: 700; }

.ac-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #ccc;
  font-size: 1rem;
  line-height: 1;
  padding: .1rem .25rem;
  border-radius: 3px;
  flex-shrink: 0;
  margin-left: .25rem;
  transition: color .1s, background .1s;
}
.ac-delete-btn:hover { color: var(--red); background: var(--red-light); }

.autocomplete-item.ac-deleting {
  gap: .4rem;
  align-items: center;
}
.ac-delete-confirm {
  flex: 1;
  font-size: .8rem;
  color: var(--muted);
}
.ac-confirm-yes,
.ac-confirm-no {
  border: 1px solid;
  border-radius: 3px;
  padding: .1rem .45rem;
  cursor: pointer;
  font-size: .76rem;
  background: none;
  white-space: nowrap;
}
.ac-confirm-yes { border-color: #900; color: #900; }
.ac-confirm-yes:hover { background: var(--red-light); }
.ac-confirm-no  { border-color: var(--border); color: var(--muted); }
.ac-confirm-no:hover  { background: var(--bg); }

/* ── INLINE CALENDAR ─────────────────────────────────────── */
.cal-widget {
  background: var(--white);
  margin-bottom: 0;
  user-select: none;
}

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .3rem .4rem .4rem;
}

.cal-month-label { font-size: .85rem; }
.cal-m { color: var(--red); font-weight: 700; }
.cal-y { color: var(--muted); font-weight: 400; margin-left: .2em; }

.cal-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: .15rem .5rem;
  color: var(--red);
  font-size: 1.15rem;
  line-height: 1;
  border-radius: var(--radius);
  transition: background .15s;
}
.cal-nav-btn:hover { background: var(--red-light); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-day-header {
  text-align: center;
  padding: .25rem 0;
  font-size: .62rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .03em;
}
.cal-day-header.weekend { color: var(--red); opacity: .55; }

.cal-day {
  text-align: center;
  padding: .2rem 0;
  font-size: .8rem;
  cursor: pointer;
  transition: background .1s;
}

.cal-day:not(.weekend):not(.other-month):not(.selected):hover .cal-day-num {
  background: #f5e0e0;
  color: var(--text);
}
.cal-day.weekend { color: var(--red); cursor: default; }
.cal-day.other-month { color: #d8d8d8; cursor: default; }

.cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin: auto;
  font-size: .78rem;
  transition: background .15s, color .15s;
}

.cal-day.today:not(.selected) .cal-day-num {
  border: 2px solid var(--red);
  color: var(--red);
  font-weight: 700;
}
.cal-day.selected .cal-day-num {
  background: var(--red);
  color: var(--white);
  font-weight: 700;
}
.cal-day.selected:hover .cal-day-num {
  background: #6b0000;
  color: var(--white);
}
.cal-day.today.selected .cal-day-num {
  background: var(--red);
  color: var(--white);
  border: none;
}
.cal-day.today.selected:hover .cal-day-num {
  background: #6b0000;
  color: var(--white);
}

/* ── PRINT PREVIEW COLUMN ────────────────────────────────── */
.preview-column {
  position: sticky;
  top: 80px;
  height: calc(100vh - 96px);
  overflow-y: auto;
}

.preview-label {
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .5rem;
}

.preview-scaler {
  width: 100%;
  overflow: hidden;
  position: relative;
}

.print-paper {
  width: 794px;
  padding: 12mm 18mm;
  transform-origin: top left;
  background: var(--white);
  box-shadow: 0 2px 12px rgba(0,0,0,.15), 0 0 0 1px rgba(0,0,0,.06);
  border-radius: 2px;
}

/* ── PRINT DOCUMENT — screen preview matches print output exactly ── */
.print-doc {
  font-family: Georgia, 'Times New Roman', serif;
}

.print-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6mm;
}

.print-date {
  font-size: 15pt;
  font-style: italic;
  color: #111;
}

.print-logo {
  height: 45pt;
  width: auto;
}

.print-tenant-name {
  font-size: 16pt;
  font-weight: bold;
  color: #111;
  align-self: center;
}

.print-divider {
  border: none;
  border-top: .75pt solid #000;
  margin: 0 0 5mm;
}

.print-section-title {
  text-align: center;
  font-weight: bold;
  font-style: italic;
  font-size: 18pt;
  letter-spacing: .06em;
  margin: 7mm 0 4mm;
}

.print-item {
  display: flex;
  align-items: baseline;
  margin-bottom: 3.5mm;
  font-size: 16pt;
  line-height: 1.4;
}

.print-num {
  width: 12mm;
  flex-shrink: 0;
  color: #222;
}

.print-desc { flex: 1; }

.print-kosilo-item {
  display: table;
  width: 100%;
  font-size: 14pt;
  margin-bottom: 3mm;
  line-height: 1.5;
}
.print-kosilo-desc {
  display: table-cell;
  text-align: center;
  font-style: italic;
  width: 85%;
  padding-left: 15%;
}
.print-kosilo-price {
  display: table-cell;
  text-align: right;
  vertical-align: top;
  white-space: nowrap;
  width: 15%;
}

.print-price {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 16pt;
  margin-left: 5mm;
}

.print-footer {
  text-align: center;
  font-weight: bold;
  font-style: italic;
  margin-top: 22mm;
  font-size: 18pt;
  letter-spacing: .06em;
}

/* ── LOGIN PAGE ──────────────────────────────────────────── */
.login-body { background: var(--bg); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 2.25rem 1.75rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 24px rgba(0,0,0,.14);
  text-align: center;
}

.login-heading {
  text-align: center;
  margin-bottom: 1.25rem;
}

.login-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--red);
  letter-spacing: -.01em;
  line-height: 1.1;
}

.login-tagline {
  font-size: .82rem;
  color: var(--muted);
  margin-top: .2rem;
  letter-spacing: .04em;
}

.login-error {
  background: var(--red-light);
  border: 1px solid #ffc0c0;
  border-radius: var(--radius);
  color: #900;
  font-size: .82rem;
  padding: .5rem .65rem;
  margin-bottom: .85rem;
  text-align: left;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  display: block;
  padding: .65rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: .7rem;
  transition: border-color .15s;
}
.login-card input:focus { outline: none; border-color: var(--red); }

.login-btn {
  width: 100%;
  padding: .7rem;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.login-btn:hover { background: var(--red-hover); }

/* ── IMPERSONATION BAR ───────────────────────────────────── */
.impersonation-bar {
  background: #fff3cd;
  border-bottom: 1px solid #ffc107;
  color: #856404;
  font-size: .85rem;
  padding: .45rem 1.5rem;
  text-align: center;
}
.impersonation-bar a {
  color: #533f03;
  font-weight: 600;
  text-decoration: underline;
}
