/* global */
body { font-family: Arial, sans-serif; margin: 20px; }
input, select { display:block; margin:8px 0; padding:8px; width:300px; max-width:100%; }
#orders { margin-top: 24px; }
.orders-header { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.orders-toggle .small-btn { min-width:44px; height:32px; margin-left:4px; }

/* Two column layout for orders */
#ordersList { display:flex; gap:16px; }
#ordersList.two-column-layout { flex-direction: row; align-items: flex-start; }
.orders-column { flex: 1; min-width: 0; }
.orders-column h3 { margin-top: 0; margin-bottom: 12px; font-size: 18px; }
.orders-column .order { margin-bottom: 8px; }

/* Delivery view: two columns per date group */
.delivery-columns { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; flex-basis: 100%; width: 100%; }
.delivery-columns .orders-column { flex: 1; min-width: 0; }
.delivery-columns .orders-column h3 { margin-top: 0; margin-bottom: 12px; font-size: 18px; }

/* Monthly summary layout */
.monthly-summary {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  padding: 6px 0;
}
.monthly-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 6px 0;
}
.monthly-summary-row + .monthly-summary-row {
  border-top: 1px dashed rgba(255,255,255,0.6);
}
.monthly-summary-left,
.monthly-summary-right {
  display: flex;
  align-items: center;
}

/* Archive monthly summary */
.monthly-archive-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.monthly-archive-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

/* Fallback for single column */
#ordersList:not(.two-column-layout) { display:flex; flex-wrap:wrap; gap:8px; }
#ordersList:not(.two-column-layout) .order { flex:1 1 320px; max-width:420px; box-sizing:border-box; }

.order { border:1px solid #ddd; padding:10px; border-radius:4px; transition: background 0.15s ease, border-color 0.15s ease; }
.meta { color:#666; font-size:12px; }
.order-compact { padding:12px; font-size:14px; cursor:pointer; }
.order-compact:hover { opacity:0.85; transform:scale(1.02); transition:all 0.15s ease; }
.order-compact strong { display:block; }
.oddano-completed { background-color: #f5f5f5 !important; border-left: 6px solid #9e9e9e !important; }

/* primary action */
#placeOrder {
  background: #007bff;
  color: #fff;
  padding: 12px 24px;
  font-size: 18px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transition: background 0.15s ease, transform 0.08s ease;
}
#placeOrder:hover { background: #0062cc; transform: translateY(-1px); }

/* Status colors */
.s-naroceno { background: #ffecec; border-left: 6px solid #ff4d4d; }
.s-sprejeto { background: #fff6e6; border-left: 6px solid #ffb84d; }
.s-v-delu { background: #fffde6; border-left: 6px solid #ffd11a; }
.s-koncano { background: #eaffeb; border-left: 6px solid #7ed37a; }
.s-oddano { background: #f5f5f5; border-left: 6px solid #9e9e9e; }

.small-btn { padding:6px 10px; font-size:13px; margin-left:6px; border-radius:6px; cursor:pointer; }
.status-select { margin-top:8px; }

/* Modal styling */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.modal[aria-hidden="true"] { display: none; }

/* backdrop */
.modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 25, 41, 0.55);
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
}

/* modal card */
.modal-content {
  position: relative;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  padding: 18px;
  border-radius: 12px;
  width: 560px;
  max-width: calc(100% - 32px);
  box-shadow: 0 12px 40px rgba(12, 30, 60, 0.25);
  border: 1px solid rgba(30, 60, 90, 0.06);
  transform: translateY(6px);
  transition: transform 180ms ease, opacity 180ms ease;
  opacity: 1;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-header h3 { margin: 0; font-size: 18px; color: #0b2540; }
.modal-close {
  background: transparent; border: none; color: #516b86;
  font-size: 18px; cursor: pointer; padding: 6px; border-radius: 6px;
}
.modal-close:hover { background: rgba(0,0,0,0.04); color: #223648; }

.modal-body { padding-top: 6px; }
.modal-body input, .modal-body select, .modal-body textarea {
  width: 100%; box-sizing: border-box; padding: 10px 12px;
  margin: 8px 0 6px 0; border-radius: 8px; border: 1px solid #e2e8f0;
  background: #fff; transition: box-shadow 120ms ease, border-color 120ms ease;
  font-size: 14px;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
  outline: none; border-color: #7aa7ff;
  box-shadow: 0 6px 18px rgba(30,100,220,0.08);
}
.modal-body .hint { color: #5b6b7a; font-size: 13px; margin-top: 6px; }

.modal-actions { margin-top: 14px; text-align: right; display:flex; justify-content:flex-end; gap:8px; }
.modal-actions .small-btn { padding:8px 12px; border-radius:8px; font-size:14px; }
.modal-actions .small-btn.primary {
  background: #0b74ff; color: #fff; border: none;
  box-shadow: 0 6px 18px rgba(11,116,255,0.12);
}
.modal-actions .small-btn.secondary { background: transparent; color: #12324a; border: 1px solid #dfe7ef; }
.modal-actions .small-btn.danger { background: #ff4444; color: #fff; border: none; box-shadow: 0 6px 18px rgba(255, 68, 68, 0.12); }
.modal-actions .small-btn.danger:hover { background: #dd0000; }

/* error state */
.input-error { border-color: #ff6b6b !important; box-shadow: 0 4px 12px rgba(255,107,107,0.08); }
.field-error { color: #c0392b; font-size:12px; margin-top:4px; }

/* responsive modal */
@media (max-width: 600px) {
  .modal-content { width: calc(100% - 24px); padding: 14px; border-radius: 10px; }
  .modal-header h3 { font-size: 16px; }
  .modal-actions { flex-direction: column-reverse; gap:6px; }
  .modal-actions .small-btn { width: 100%; }
}

/* Alternating rows */
#articlesList > .order:nth-child(odd),
#customersList > .customer:nth-child(odd) {
  background: #e8f4ff;
}
#articlesList > .order:nth-child(even),
#customersList > .customer:nth-child(even) {
  background: transparent;
}

/* ---------- Customers: card + actions (base) ---------- */
#customersList .customer {
  background: linear-gradient(180deg,#ffffff,#fbfdff);
  border: 1px solid rgba(30,60,90,0.05);
  box-shadow: 0 8px 24px rgba(12,30,60,0.06);
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 10px;
  transition: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* remove lift */
#customersList .customer:hover { transform: none; box-shadow: none; }

/* actions container */
#customersList .customer .customer-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

/* customer action buttons: light gray, outline, no hover lift */
#customersList .customer .small-btn {
  background: #f4f6f8;
  color: #223648;
  border: 1px solid rgba(30,60,90,0.06);
  box-shadow: none;
  padding: 10px 14px;
  border-radius: 8px;
  transition: none;
  outline: 2px solid #000;
  outline-offset: 0;
  height: 44px;
  line-height: 20px;
}

/* keep hover identical */
#customersList .customer .small-btn:hover { background: #f4f6f8; transform: none; box-shadow: none; }

/* delete variant with black outline (non-aggressive) */
#customersList .customer .danger {
  background: #f4f6f8;
  color: #b03030;
  border: 1px solid rgba(200,80,80,0.08);
  box-shadow: none;
  padding: 10px 14px;
  border-radius: 8px;
  outline: 2px solid #000;
  height: 44px;
  line-height: 20px;
}
#customersList .customer .danger:hover { background: #f4f6f8; transform: none; box-shadow: none; }

/* Add customer button: light gray, black outline, taller */
#addCustomerBtn {
  padding: 12px 18px;
  font-size: 15px;
  height: 46px;
  line-height: 20px;
  border-radius: 10px;
  background: #f4f6f8;
  color: #223648;
  border: none;
  box-shadow: none;
  outline: 2px solid #000;
}
#addCustomerBtn:hover { background: #f4f6f8; transform: none; box-shadow: none; }

/* (Legacy .danger fallback - kept minimal and without lift) */
.danger {
  background: #f44336;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  height: 44px;
  line-height: 24px;
  width: 100%;
  max-width: 160px;
}
.danger:hover { background: #f44336; transform: none; box-shadow: none; }

/* ---------- Autocomplete dropdown ---------- */
.customer-autocomplete { position: relative; max-width: 420px; }
.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid rgba(30,60,90,0.08);
  box-shadow: 0 8px 24px rgba(12,30,60,0.06);
  border-radius: 8px;
  z-index: 1200;
  max-height: 280px;
  overflow: auto;
}
.suggestion { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid rgba(0,0,0,0.03); }
.suggestion:hover, .suggestion:focus { background: #f3f8ff; outline: none; }
.suggestion .s-meta { color: #516b86; font-size: 12px; margin-top: 4px; }

/* ---------- Order items / add item UI ---------- */
.order-items { margin-top: 8px; padding-left: 0; }
.order-item { padding: 6px 8px; border-radius: 6px; background: rgba(255,255,255,0.6); margin-bottom:6px; font-size: 14px; }
.add-item-wrap { margin-top: 8px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.article-select { min-width: 220px; }
.article-qty { padding:6px; border-radius:6px; border:1px solid #e2e8f0; width:80px; }

/* ---------- Articles view: make cards & buttons match customers ---------- */
#articlesList .order {
  background: linear-gradient(180deg,#ffffff,#fbfdff);
  border: 1px solid rgba(30,60,90,0.05);
  box-shadow: 0 8px 24px rgba(12,30,60,0.06);
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 10px;
  transition: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 56px;
  box-sizing: border-box;
}

/* remove lift */
#articlesList .order:hover { transform: none; box-shadow: 0 8px 24px rgba(12,30,60,0.06); }

/* article buttons: same look as customer buttons */
#articlesList .order .small-btn,
#articlesList .order button {
  background: #f4f6f8;
  color: #223648;
  border: 1px solid rgba(30,60,90,0.06);
  box-shadow: none;
  padding: 10px 14px;
  border-radius: 8px;
  transition: none;
  outline: 2px solid #000;
  outline-offset: 0;
  height: 44px;
  line-height: 20px;
  cursor: pointer;
}
#articlesList .order .small-btn:hover,
#articlesList .order button:hover { background: #f4f6f8; transform: none; box-shadow: none; }

/* delete variant for articles */
#articlesList .order .danger {
  background: #f4f6f8;
  color: #b03030;
  border: 1px solid rgba(200,80,80,0.08);
  box-shadow: none;
  padding: 10px 14px;
  border-radius: 8px;
  outline: 2px solid #000;
  height: 44px;
  line-height: 20px;
}

/* ensure article meta styling */
#articlesList .order .meta { color: #4f6678; font-size: 13px; margin-top: 2px; }

/* actions container and spacing (match customers) */
#articlesList .order > div:last-child,
#articlesList .order .actions {
  display: flex;
  gap: 6px; /* increased gap between buttons */
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}

/* extra safety: spacing between immediate sibling buttons */
#articlesList .order button + button { margin-left: 6px; }

/* Add Article button sizing to match Add Customer */
#addArticleBtn {
  padding: 12px 18px;
  font-size: 15px;
  height: 46px;
  line-height: 20px;
  border-radius: 10px;
  background: #f4f6f8;
  color: #223648;
  border: none;
  box-shadow: none;
  outline: 2px solid #000;
}
#addArticleBtn:hover { background: #f4f6f8; transform: none; box-shadow: none; }

.order-total { margin-top: 10px; padding: 8px; background: #f8f9fa; border-radius: 4px; text-align: right; }

.date-group-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  padding: 12px 16px; 
  margin: 16px -9999px 8px -9999px;
  padding-left: calc(16px + 9999px);
  padding-right: calc(16px + 9999px);
  background: linear-gradient(135deg, #0277bd 0%, #0288d1 100%); 
  color: white; 
  border-radius: 0;
  font-size: 16px; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  flex-basis: 100%;
  width: 100%;
}
.date-group-header strong { font-size: 18px; margin-right: 100px; }
.date-group-header .date-total { font-size: 18px; font-weight: bold; }

.status-history { margin-top: 10px; padding: 8px; border-radius: 4px; font-size: 12px; }
.status-history ul { margin: 5px 0 0 20px; padding: 0; }
.status-history li { margin: 2px 0; }

/* Status history backgrounds matching order statuses */
.status-history.s-naroceno { background: #ffecec; }
.status-history.s-sprejeto { background: #fff6e6; }
.status-history.s-v-delu { background: #fffde6; }
.status-history.s-koncano { background: #eaffeb; }
.status-history.s-oddano { background: #f5f5f5; }

.add-item-wrap { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.article-qty { width: 80px; }

/* Mobile responsiveness */
@media (max-width: 768px) {
  body { margin: 10px; font-size: 14px; }
  input, select { width: 100%; padding: 10px; font-size: 16px; } /* Prevent zoom on iOS */
  #placeOrder { width: 100%; padding: 15px; font-size: 18px; }
  .order { padding: 15px; }
  .meta { font-size: 14px; }
  .small-btn { padding: 8px 12px; font-size: 14px; margin-left: 4px; }
  .modal-content { width: 90%; max-width: none; }
  .order-item { font-size: 14px; }
  .order-total { font-size: 14px; padding: 10px; }
  nav { font-size: 16px; }
  h1 { font-size: 24px; }
  .order > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .order > div:last-child > * { flex: 1; min-width: 100px; }
  .add-item-wrap { flex-wrap: wrap; }
  .status-history { font-size: 11px; }
}

@media (max-width: 900px) {
  .delivery-columns { flex-direction: column; }
}
