:root {
  --wood-dark: #3e2417;
  --wood: #5c3a26;
  --cream: #fbf3e3;
  --paper: #fffaf0;
  --amber: #d99a2b;
  --amber-dark: #b9791a;
  --green: #4c7a4c;
  --red: #b23b3b;
  --text: #2b1d14;
  --muted: #8a7a6a;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(60, 30, 10, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Stresanje zaslona (nov naročilo pri gostilničarju) ---- */
@keyframes shake {
  0% { transform: translate(0, 0) rotate(0deg); }
  10% { transform: translate(-10px, 2px) rotate(-1deg); }
  20% { transform: translate(9px, -2px) rotate(1deg); }
  30% { transform: translate(-9px, 2px) rotate(-1deg); }
  40% { transform: translate(8px, -1px) rotate(1deg); }
  50% { transform: translate(-6px, 1px) rotate(-0.5deg); }
  60% { transform: translate(6px, -1px) rotate(0.5deg); }
  70% { transform: translate(-4px, 1px) rotate(-0.5deg); }
  80% { transform: translate(4px, 0) rotate(0.5deg); }
  90% { transform: translate(-2px, 0) rotate(0deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}
body.shake {
  animation: shake 0.5s ease-in-out;
}

h1, h2 { font-family: inherit; }

/* ---- Landing page ---- */
.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, #6b4530, var(--wood-dark));
}
.landing-card {
  background: var(--paper);
  border-radius: 20px;
  padding: 40px 28px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.logo { font-size: 56px; }
.landing-card h1 { margin: 8px 0 0; font-size: 28px; color: var(--wood-dark); }
.subtitle { color: var(--muted); margin: 6px 0 28px; }

.error-msg {
  color: var(--red);
  font-size: 13px;
  margin: 10px 0 0;
  display: none;
  text-align: left;
}
.error-msg.visible { display: block; }

.big-btn {
  display: block;
  text-decoration: none;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  font-size: 20px;
  font-weight: 700;
  transition: transform 0.1s ease;
}
.big-btn:active { transform: scale(0.97); }
.big-btn span { display: block; font-size: 13px; font-weight: 400; opacity: 0.9; margin-top: 4px; }
.guest-btn { background: var(--amber); color: var(--wood-dark); }
.host-btn { background: var(--wood-dark); color: white; }

/* ---- Layout ---- */
.topbar {
  background: var(--wood-dark);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.back-link { color: white; text-decoration: none; font-size: 22px; }
.name-badge { font-size: 13px; opacity: 0.85; font-weight: 400; }
.link-btn { background: none; border: none; color: var(--amber); font-size: 14px; cursor: pointer; text-decoration: underline; padding: 0; }
.link-btn.danger { color: #ff8a8a; }
.sound-toggle { font-size: 18px; display: flex; align-items: center; gap: 6px; cursor: pointer; }

.container { max-width: 640px; margin: 0 auto; padding: 16px; padding-bottom: 60px; }
.host-layout { max-width: 900px; }

.card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 12px; font-size: 16px; color: var(--wood); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.section-header h2 { margin: 0; }

/* ---- Forms ---- */
input[type="text"], input[type="number"], input[type="password"] {
  border: 2px solid #e5d7bf;
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  width: 100%;
  background: white;
  color: var(--text);
  font-family: inherit;
}
input[type="number"] { width: 70px; text-align: center; flex: none; }
input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(217, 154, 43, 0.18);
}

/* ---- Vhodna polja z ikono (npr. prijava) ---- */
.input-group {
  position: relative;
  margin-bottom: 12px;
}
.input-group input {
  padding-left: 40px;
}
.input-group input#login-password {
  padding-right: 40px;
}
.input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  opacity: 0.55;
  pointer-events: none;
}
.input-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  opacity: 0.6;
  line-height: 1;
}
.input-toggle:hover { opacity: 1; }

.add-item-row { display: flex; gap: 8px; margin-bottom: 4px; }
.add-item-row input[type="text"] { flex: 1; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--amber); color: var(--wood-dark); }
.btn.primary:disabled { background: #e5d7bf; color: var(--muted); cursor: not-allowed; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; margin-top: 10px; }
.btn:active:not(:disabled) { transform: scale(0.98); }

#order-note { margin: 10px 0 0; }

/* ---- Cart / lists ---- */
.cart-list, .orders-list, .summary-list { list-style: none; padding: 0; margin: 0 0 10px; }
.cart-list li, .orders-list li, .summary-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #f6ead2;
  border-radius: 8px;
  margin-bottom: 6px;
}
.empty { color: var(--muted); font-style: italic; background: transparent !important; justify-content: flex-start !important; }
.remove-btn { background: none; border: none; color: var(--red); font-size: 16px; cursor: pointer; padding: 0 6px; }

/* ---- Order cards (host + guest status) ---- */
.orders-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .orders-grid { grid-template-columns: 1fr 1fr; } }

.order-card {
  border-radius: 12px;
  padding: 14px;
  background: #f6ead2;
  border-left: 5px solid var(--amber);
}
.order-card.status-done { border-left-color: var(--green); opacity: 0.75; }
.order-card.status-rejected { border-left-color: var(--red); opacity: 0.75; }
.order-header { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; color: var(--wood-dark); }
.order-guest { overflow: hidden; text-overflow: ellipsis; }
.order-time { font-weight: 400; font-size: 12px; color: var(--muted); white-space: nowrap; margin-left: 8px; }
.order-items-list { margin: 0 0 8px; padding-left: 18px; }
.order-note { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.order-rejected-label { font-size: 13px; color: var(--red); font-weight: 700; margin-bottom: 8px; }
.order-host-reply {
  font-size: 13px;
  color: var(--wood-dark);
  background: rgba(217, 154, 43, 0.25);
  border: 1px solid var(--amber);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
}
.order-status { font-size: 13px; font-weight: 700; }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.action-btn { border: none; border-radius: 8px; padding: 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.done-btn { background: var(--green); color: white; }
.reject-btn { background: var(--red); color: white; }
.reply-btn { background: #e8d9bd; color: var(--wood-dark); }
.undo-btn { background: #e5d7bf; color: var(--text); }
.delete-btn { background: transparent; color: var(--red); font-size: 16px; }

.muted { opacity: 0.7; }
.summary-list li { background: #fff; border: 1px solid #e5d7bf; }
.summary-list li strong { color: var(--amber-dark); margin-right: 6px; }
.empty-state { text-align: center; color: var(--muted); padding: 30px 10px; }
.hidden { display: none !important; }

/* ---- Tabs ---- */
.tabbar {
  display: flex;
  background: var(--wood);
}
.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  padding: 12px 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab-btn.active {
  color: white;
  border-bottom-color: var(--amber);
  background: rgba(255, 255, 255, 0.08);
}
.tab-badge {
  display: inline-block;
  background: var(--red);
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.tab-panel.hidden { display: none !important; }

/* ---- Klepet ---- */
.chat-card { display: flex; flex-direction: column; }
.chat-hint { font-size: 11px; color: var(--muted); }
.chat-messages {
  height: 55vh;
  max-height: 520px;
  min-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  margin-bottom: 10px;
  border: 2px solid #e5d7bf;
  border-radius: 10px;
  background: #fffdf8;
}
.chat-msg {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f6ead2;
  align-self: flex-start;
}
.chat-msg.me { align-self: flex-end; background: var(--amber); }
.chat-msg.role-host { border: 2px solid var(--wood-dark); }
.chat-author { font-weight: 700; font-size: 12px; display: block; margin-bottom: 2px; color: var(--wood); }
.chat-msg.me .chat-author { color: var(--wood-dark); }
.chat-text { font-size: 15px; word-wrap: break-word; white-space: pre-wrap; display: block; }
.chat-time { font-size: 10px; opacity: 0.6; margin-top: 3px; display: block; }
.chat-empty { color: var(--muted); font-style: italic; text-align: center; margin: auto; }
.chat-input-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chat-input-row input[type="text"] { flex: 1 1 160px; }

.chat-image { max-width: 100%; max-height: 220px; border-radius: 10px; margin-top: 4px; display: block; cursor: zoom-in; }
.chat-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  padding: 6px 10px;
  text-decoration: none;
  color: var(--wood-dark);
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
}

/* ---- Emotikoni + priloge ---- */
.icon-btn {
  border: none;
  background: #f6ead2;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  font-size: 20px;
  cursor: pointer;
  flex: none;
}
.icon-btn:active { transform: scale(0.95); }

.emoji-picker-wrap { position: relative; }
.emoji-popover {
  position: absolute;
  bottom: 52px;
  left: 0;
  background: var(--paper);
  border: 2px solid #e5d7bf;
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  box-shadow: var(--shadow);
  z-index: 20;
  width: 232px;
}
.emoji-popover.hidden { display: none !important; }
.emoji-popover button {
  border: none;
  background: transparent;
  font-size: 20px;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-popover button:hover, .emoji-popover button:active { background: #f6ead2; }

.chat-attachment-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f6ead2;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 13px;
}
.chat-attachment-preview img { max-height: 40px; border-radius: 6px; }
.chat-attachment-preview .remove-attachment {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--red);
  font-size: 16px;
  cursor: pointer;
}

/* ---- Zaloga ---- */
.stock-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.stock-row { display: flex; align-items: center; justify-content: space-between; background: #f6ead2; border-radius: 10px; padding: 10px 12px; gap: 10px; }
.stock-name { font-weight: 700; color: var(--wood-dark); flex: 1; overflow: hidden; text-overflow: ellipsis; }
.stock-name.out-of-stock { color: var(--red); }
.stock-qty-controls { display: flex; align-items: center; gap: 6px; flex: none; }
.stock-qty-controls button {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--amber);
  color: var(--wood-dark);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.stock-qty-controls input[type="number"] { width: 56px; text-align: center; padding: 6px; }
.stock-delete-btn { background: transparent; border: none; color: var(--red); font-size: 16px; cursor: pointer; padding: 0 4px; }
.stock-qty-readonly { font-weight: 700; font-size: 16px; color: var(--wood); min-width: 70px; text-align: right; }
.stock-qty-readonly.zero { color: var(--red); }
.hint-text { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-box {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}
.modal-box h2 { margin-top: 0; }
.modal-box form { display: flex; flex-direction: column; gap: 12px; }
