/* Osnovni stil – krupno i čitljivo, za osoblje koje radi brzo. */

:root {
    --bg: #f5f5f5;
    --fg: #1a1a1a;
    --muted: #666;
    --ok-bg: #e6f4ea;
    --ok-fg: #1e5e2e;
    --error-bg: #fdecea;
    --error-fg: #8a1c1c;
    --border: #ddd;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 18px;
    line-height: 1.4;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 16px;
}

h1 { font-size: 32px; margin: 0 0 16px; }

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.alert-ok    { background: var(--ok-bg);    color: var(--ok-fg); }
.alert-error { background: var(--error-bg); color: var(--error-fg); }

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
}
.table th, .table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.table .num { text-align: right; white-space: nowrap; }

.muted { color: var(--muted); font-size: 15px; }

/* --- Dugmad i forme --- */

.btn {
    display: inline-block;
    padding: 12px 20px;
    font-size: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--fg);
    text-decoration: none;
    cursor: pointer;
}
.btn-primary { background: #1565c0; border-color: #1565c0; color: #fff; }
.btn-block   { display: block; width: 100%; }
.btn-small   { padding: 6px 12px; font-size: 15px; }

.form label { display: block; margin: 16px 0 6px; font-weight: 600; }
.form input[type=text],
.form input[type=password] {
    width: 100%;
    padding: 14px;
    font-size: 20px;
    border: 1px solid #bbb;
    border-radius: 8px;
}
.form .btn { margin-top: 24px; font-size: 20px; padding: 16px; }

form.inline { display: inline; }

/* --- Prijava --- */

.login-box {
    max-width: 400px;
    margin: 10vh auto 0;
    padding: 32px 24px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .08);
}
.login-box h1 { text-align: center; }

/* --- Gornja traka --- */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #263238;
    color: #fff;
}
.topbar-title { font-size: 20px; font-weight: 600; }
.topbar-user  { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.badge {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .15);
    font-size: 13px;
}

/* --- Admin --- */

h2 { font-size: 24px; margin: 0 0 8px; }

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 12px;
    background: #37474f;
}
.admin-nav a {
    padding: 12px 16px;
    color: #cfd8dc;
    text-decoration: none;
    border-bottom: 3px solid transparent;
}
.admin-nav a.active { color: #fff; border-bottom-color: #64b5f6; }

.flash-wrap { padding-bottom: 0; }
.flash-wrap .alert { margin-bottom: 0; }

.card {
    margin-top: 24px;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .06);
}
.form .card { margin-top: 0; margin-bottom: 24px; }

.tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px;
    background: #fff;
    border-radius: 12px;
    color: var(--fg);
    text-decoration: none;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .06);
}
.tile strong { font-size: 22px; }

.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: #eceff1;
    color: var(--muted);
    font-size: 14px;
}
.tag-ok { background: var(--ok-bg); color: var(--ok-fg); }
.tag-warn  { background: #fff3e0; color: #8a3b00; }
.tag-error { background: var(--error-bg); color: var(--error-fg); }
.checks td:nth-child(2) { white-space: nowrap; }
.row-inactive td:first-child { color: var(--muted); text-decoration: line-through; }

.btn-danger { background: #fff; border-color: #c62828; color: #c62828; }

.form select {
    width: 100%;
    padding: 14px;
    font-size: 20px;
    border: 1px solid #bbb;
    border-radius: 8px;
    background: #fff;
}
.form label.check { display: flex; align-items: center; gap: 10px; font-weight: 400; margin-top: 20px; }
.form label.check input { width: 22px; height: 22px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.form-actions .btn { margin-top: 24px; }
.form-actions.secondary { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--border); }
.form-actions.secondary .btn { margin-top: 12px; }

.field-error { margin-top: 6px; color: var(--error-fg); font-size: 15px; }

.input-unit { display: flex; align-items: center; gap: 10px; }
.input-unit input { max-width: 160px; }
.input-unit span { color: var(--muted); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.map {
    height: 360px;
    margin-top: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* --- Admin: zone --- */

.container-wide { max-width: 1100px; }
.map-large { height: 520px; }
.swatch {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 10px;
    border-radius: 4px;
    vertical-align: -2px;
}
.row-selected td { background: #e3f2fd; }
.form input[type=color] { width: 80px; height: 48px; padding: 2px; border: 1px solid #bbb; border-radius: 8px; }

@media (max-width: 600px) {
    .table th, .table td { padding: 8px 6px; font-size: 16px; }
    .admin-nav a { padding: 10px 10px; }
    .card { padding: 16px; }
}

/* --- Unos porudžbina (osoblje) --- */

.entry {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
    align-items: start;
}
.entry .card { margin-top: 0; }
.entry-form .form label:first-child { margin-top: 0; }
.form .input-xl {
    font-size: 30px;
    padding: 14px 16px;
    letter-spacing: 1px;
    font-weight: 600;
}
.form input[type=tel] {
    width: 100%;
    padding: 14px;
    border: 1px solid #bbb;
    border-radius: 8px;
}
.form input:focus { outline: 3px solid #90caf9; outline-offset: 0; border-color: #1565c0; }
.entry-status { min-height: 26px; margin-top: 6px; font-size: 17px; }
.cust-known { color: var(--ok-fg); font-weight: 600; }
.cust-new     { color: #1565c0; font-weight: 600; }
.cust-error   { color: var(--error-fg); }

.input-action { display: flex; gap: 8px; }
.input-action input { flex: 1; min-width: 0; }
.form .input-action .btn { margin-top: 0; padding: 12px 18px; font-size: 18px; }

.geo-results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.geo-results .btn { text-align: left; }
.geo-results .btn.selected { border-color: #1565c0; background: #e3f2fd; }

.map-entry { height: 340px; }

.zone-box {
    margin-top: 12px;
    padding: 12px 16px;
    border-left: 8px solid transparent;
    border-radius: 8px;
    font-size: 20px;
}
.zone-box:empty { display: none; }
.zone-in  { display: flex; justify-content: space-between; align-items: center; background: #f1f8e9; }
.zone-in .zone-price { font-size: 26px; font-weight: 700; }
.zone-out { background: #fff3e0; border-left-color: #e65100; color: #8a3b00; font-weight: 600; }

.form-msg:empty { display: none; }
.form-msg { margin-top: 16px; }
.form-msg .alert, .form-msg.alert { margin-bottom: 0; }

.form .btn-xl { font-size: 22px; padding: 18px 28px; }
.btn small { font-size: 14px; opacity: .75; font-weight: 400; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary:focus { outline: 4px solid #90caf9; }

.entry-list h2 { display: flex; align-items: center; gap: 10px; }
.orders-list { display: flex; flex-direction: column; gap: 10px; }
.order-row {
    padding: 12px 14px;
    background: #fff;
    border-radius: 10px;
    border-left: 6px solid #90a4ae;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
.order-row.status-new   { border-left-color: #1565c0; }
.order-row.status-ready { border-left-color: #2e7d32; }
.order-row.status-taken { opacity: .6; }
.order-row.just-added   { animation: just-added 2s ease-out; }
@keyframes just-added { from { background: #fff59d; } to { background: #fff; } }
.order-head { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--muted); }
.order-id { font-weight: 700; color: var(--fg); }
.order-head .tag { margin-left: auto; }
.tag-new   { background: #e3f2fd; color: #0d47a1; }
.tag-ready { background: var(--ok-bg); color: var(--ok-fg); }
.order-address { font-size: 20px; font-weight: 600; margin-top: 2px; }
.order-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 15px; color: var(--muted); }
.order-zone { padding-left: 6px; border-left: 4px solid #ccc; }
.order-zone.out { color: #e65100; font-weight: 700; border-left-color: #e65100; }
.order-note { margin-top: 4px; font-size: 15px; font-style: italic; }
.order-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-ready { background: #2e7d32; border-color: #2e7d32; color: #fff; font-weight: 600; }

@media (max-width: 900px) {
    .entry { grid-template-columns: 1fr; }
}

/* --- Tablet za dostavljače (landscape, dodir, bez hover-a) --- */

body.page-tablet {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}
.page-tablet .topbar { padding: 6px 16px; }
.page-tablet [hidden] { display: none !important; }
.page-tablet button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.tablet {
    flex: 1;
    display: flex;
    min-height: 0;
}
.tablet-map { flex: 1; min-width: 0; height: 100%; }
.tablet-side {
    display: flex;
    flex-direction: column;
    width: 400px;
    max-width: 45vw;
    background: var(--bg);
    border-left: 1px solid var(--border);
}
.tablet-scroll { flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.tablet-scroll h2 { display: flex; align-items: center; gap: 10px; font-size: 22px; margin: 4px 0 10px; }
.tablet-scroll .form-msg { margin: 0 0 12px; }
.t-trips-title { margin-top: 24px !important; }
.t-list { display: flex; flex-direction: column; gap: 10px; }

.t-order {
    padding: 12px 14px;
    background: #fff;
    border-radius: 12px;
    border: 3px solid transparent;
    border-left: 10px solid #90a4ae;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
    cursor: pointer;
    user-select: none;
}
.t-order.status-new   { border-left-color: #1565c0; }
.t-order.status-ready { border-left-color: #2e7d32; }
.t-order.grouped      { border-color: var(--ring); border-left-width: 10px; }
.t-order.selected     { background: #fff8e1; box-shadow: 0 0 0 3px #263238; }
.t-order-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); }
.t-check {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border: 2px solid #90a4ae; border-radius: 6px;
    background: #fff; color: #fff; font-weight: 700;
}
.t-order.selected .t-check { background: #263238; border-color: #263238; }
.t-wait { margin-left: auto; white-space: nowrap; }
.t-wait.late { color: var(--error-fg); font-weight: 700; }
.t-address { font-size: 21px; font-weight: 600; margin: 4px 0 2px; }
.t-group-btn { margin-top: 8px; padding: 8px 14px; font-size: 16px; border-width: 2px; }

.t-trip { padding: 12px 14px; background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
.t-trip-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 19px; }
.t-trip-stops { margin: 6px 0 8px; padding-left: 22px; font-size: 16px; }
.t-trip-actions { display: flex; gap: 8px; }
.t-trip-actions .btn { flex: 1; padding: 14px 10px; font-size: 18px; }
.t-drivers { margin-top: 16px; color: var(--muted); font-size: 16px; }

.tablet-actions { display: flex; gap: 8px; padding: 12px; background: #fff; border-top: 1px solid var(--border); }
.t-take { flex: 1; padding: 20px; font-size: 26px; font-weight: 700; }
.t-clear { padding: 20px 16px; font-size: 18px; }

/* Markeri: new treperi blago, ready jače; okvir u boji grupe. */
.tm {
    display: flex; align-items: center; justify-content: center;
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 6px solid var(--ring, #fff);
    color: #fff; font-weight: 700; font-size: 16px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .45);
}
.tm-new   { background: #1565c0; animation: tm-blink-new 1.6s ease-in-out infinite; }
.tm-ready { background: #2e7d32; animation: tm-blink-ready .8s ease-in-out infinite; }
.tm-sel   { outline: 4px solid #263238; outline-offset: 2px; animation: none; transform: scale(1.15); background: #263238; }
@keyframes tm-blink-new   { 50% { opacity: .45; } }
@keyframes tm-blink-ready { 50% { opacity: .25; transform: scale(1.18); } }
.tm-home { font-size: 30px; line-height: 40px; text-align: center; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }

/* Prozori (PIN, tura) */
.modal {
    position: fixed; inset: 0; z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .55);
}
.modal[hidden] { display: none; }
#pin-modal { z-index: 2100; } /* PIN se otvara i preko prozora ture */
.modal-box {
    max-height: 100%;
    overflow-y: auto;
    padding: 20px 24px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .3);
}
.modal-box h2 { font-size: 24px; margin-bottom: 12px; }

.pin-box { width: 420px; text-align: center; }
.pin-dots { display: flex; justify-content: center; gap: 18px; margin: 8px 0; }
.pin-dots span { width: 24px; height: 24px; border-radius: 50%; border: 3px solid #263238; }
.pin-dots span.on { background: #263238; }
.pin-error { min-height: 28px; color: var(--error-fg); font-weight: 600; font-size: 18px; }
.pin-error.checking { color: var(--muted); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 14px; }
.pin-pad button {
    height: 76px;
    font-size: 34px; font-weight: 600;
    border: 1px solid var(--border); border-radius: 12px;
    background: #f5f7f8; color: var(--fg);
}
.pin-pad button:active { background: #cfd8dc; }
.pin-pad .pin-fn { font-size: 20px; }
.pin-pad button:disabled { opacity: .4; }
.t-cancel { padding: 16px; font-size: 20px; }

.trip-box { width: 900px; max-width: 100%; }
.trip-body { display: flex; gap: 20px; align-items: flex-start; }
.trip-stops { flex: 1; margin: 0; padding-left: 26px; font-size: 18px; }
.trip-stop { padding: 10px 0; border-bottom: 1px solid var(--border); }
.trip-stop::marker { font-weight: 700; font-size: 22px; }
.trip-stop { display: list-item; }
.trip-stop > .btn { margin-top: 8px; padding: 12px 22px; font-size: 18px; }
.trip-qr { width: 280px; flex-shrink: 0; text-align: center; }
.trip-qr svg { width: 100%; height: auto; display: block; }
.trip-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 16px; }
.t-big { padding: 16px 26px; font-size: 20px; }

/* Uspravno (ili mali ekran): mapa gore, lista dole. */
@media (orientation: portrait) and (max-width: 900px) {
    .tablet { flex-direction: column; }
    .tablet-map { flex: 0 0 42%; height: auto; }
    .tablet-side { width: auto; max-width: none; flex: 1; min-height: 0; border-left: 0; border-top: 1px solid var(--border); }
    .trip-body { flex-direction: column-reverse; align-items: stretch; }
    .trip-qr { width: 220px; margin: 0 auto; }
}

/* --- Admin: istorija porudžbina i mušterije --- */

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.filters select, .filters input[type=date] {
    padding: 10px 12px;
    font-size: 18px;
    border: 1px solid #bbb;
    border-radius: 8px;
    background: #fff;
}
.form.filters select { width: auto; }
.day-nav { display: flex; gap: 6px; align-items: center; }
.day-nav .btn { padding: 8px 16px; }
.table-scroll { overflow-x: auto; }
.table-history td { vertical-align: top; }
.table-history .muted { font-size: 14px; }
.row-cancelled td { color: var(--muted); }
.row-cancelled td a { color: var(--muted); }
.tag-taken     { background: #fff3e0; color: #8a3b00; }
.tag-delivered { background: var(--ok-bg); color: var(--ok-fg); }
.tag-cancelled { background: var(--error-bg); color: var(--error-fg); }
.tag-warn      { background: #fff3e0; color: #8a3b00; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.table-customers td:nth-child(1),
.table-customers td:nth-child(2) { white-space: nowrap; }
