/* =========================================================================
   Kuglanje — stil temeljen na "midnight precision instrument" sustavu
   (tamna podloga, jedan naglašeni akcent, hairline rubovi, Inter tipografija)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* dark-first tokeni (zadano stanje) */
  --bg: #08090a;
  --surface: #0f1011;
  --surface-2: #161718;
  --border: #23252a;
  --border-strong: #383b3f;
  --text: #ffffff;
  --text-2: #d0d6e0;
  --text-3: #8a8f98;

  --accent: #e4f222;
  --accent-text: #08090a;

  --success: #27a644;
  --danger: #eb5757;

  --radius-card: 12px;
  --radius-control: 6px;
  --radius-pill: 9999px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', 'Roboto Mono', Menlo, monospace;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f5f6;
    --surface: #ffffff;
    --surface-2: #f0f0f2;
    --border: #e2e2e6;
    --border-strong: #c7c7cf;
    --text: #0f1011;
    --text-2: #4b4f58;
    --text-3: #7b7f88;
    --accent: #d6e600;
    --accent-text: #0f1011;
  }
}

:root[data-theme="light"] {
  --bg: #f5f5f6;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --border: #e2e2e6;
  --border-strong: #c7c7cf;
  --text: #0f1011;
  --text-2: #4b4f58;
  --text-3: #7b7f88;
  --accent: #d6e600;
  --accent-text: #0f1011;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: inherit; }

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.012em;
  text-wrap: balance;
  margin: 0 0 4px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- top nav ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.brand-logo {
  height: 22px;
  width: auto;
  display: block;
  /* logo je bijeli/svijetli PNG s prozirnom pozadinom, crtan za tamnu podlogu */
  filter: drop-shadow(0 0 0 transparent);
}

:root[data-theme="light"] .brand-logo,
:root[data-theme="light"] .login-logo {
  filter: invert(1) brightness(0.15);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .brand-logo,
  :root:not([data-theme="dark"]) .login-logo {
    filter: invert(1) brightness(0.15);
  }
}

.login-logo {
  height: 40px;
  width: auto;
  margin: 0 auto;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  padding: 8px 12px;
  border-radius: var(--radius-control);
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
}

.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--surface-2); color: var(--text); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-3);
}

.swatch {
  width: 10px; height: 10px;
  border-radius: 999px;
  display: inline-block;
  flex: none;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

main.wide { max-width: 1300px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-control);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: filter .12s ease, background .12s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-2);
}
.btn-ghost:hover { border-color: var(--text-3); color: var(--text); }

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(235,87,87,0.12); }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- cards / forms ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
}

.card + .card { margin-top: 16px; }

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

input[type="text"], input[type="password"], input[type="time"],
input[type="number"], select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 14px;
}
input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 140px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-2);
}
.checkbox-row input { width: auto; }

.help-text { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-control);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error { background: rgba(235,87,87,0.12); border-color: var(--danger); color: #ffb4b4; }
.alert-success { background: rgba(39,166,68,0.12); border-color: var(--success); color: #a7f0b6; }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card { width: 100%; max-width: 360px; }
.login-title { text-align: center; margin-bottom: 24px; }
.login-title .brand-mark { margin: 0 auto 12px; }

/* ---------- pill / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ---------- table (admin) ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-3); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }

.color-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.color-option {
  width: 32px; height: 32px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
}
.color-option input { display: none; }
.color-option.selected { border-color: var(--text); }

/* ---------- month calendar ---------- */
.month-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.month-nav { display: flex; gap: 8px; align-items: center; }
.weekday-row, .week-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.weekday-row { margin-bottom: 8px; }
.weekday-row div {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); text-align: center; padding-bottom: 4px;
}
.week-row { margin-bottom: 8px; }
.day-cell {
  aspect-ratio: 1 / 0.8;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 8px;
  text-decoration: none;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 13px;
  transition: border-color .12s ease;
}
.day-cell:hover { border-color: var(--border-strong); }
.day-cell.empty { background: transparent; border-color: transparent; }
.day-cell.today { border-color: var(--accent); }
.day-num { font-weight: 500; }
.day-dot {
  width: 6px; height: 6px; border-radius: 999px; background: var(--accent);
  align-self: flex-end;
}

/* ---------- day schedule grid ---------- */
.day-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.day-toolbar h2 { font-size: 20px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.schedule-scroll {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: auto;
  max-height: 70vh;
  background: var(--surface);
}

.schedule-grid {
  display: grid;
  grid-template-columns: 56px repeat(4, 1fr);
  position: relative;
  min-width: 640px;
}

.grid-corner {
  position: sticky; top: 0; left: 0; z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.lane-header {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.hour-col {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.hour-label {
  height: 60px;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 2px 8px 0 0;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.lane-col {
  position: relative;
  border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(
    to bottom, transparent, transparent 59px, var(--border) 59px, var(--border) 60px
  );
  cursor: pointer;
}

.lane-col:hover { background-color: rgba(228, 242, 34, 0.03); }

.booking-block {
  position: absolute;
  left: 3px; right: 3px;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
  cursor: default;
}
.booking-block .b-name { font-weight: 600; display: block; }
.booking-block .b-time { font-family: var(--font-mono); font-variant-numeric: tabular-nums; opacity: .85; }
.booking-block .b-del {
  position: absolute; top: 2px; right: 4px;
  background: rgba(0,0,0,0.25);
  border: none; border-radius: 999px;
  width: 16px; height: 16px;
  font-size: 11px; line-height: 1;
  cursor: pointer; color: inherit;
  display: none;
}
.booking-block:hover .b-del { display: block; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close { background: none; border: none; color: var(--text-3); font-size: 20px; cursor: pointer; line-height: 1; }

/* ---------- public display screen ---------- */
.display-shell {
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.display-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.display-header h1 { font-size: 26px; }
.display-clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  color: var(--text-2);
}
.display-grid-wrap { flex: 1; display: flex; min-height: 0; }
.display-grid-wrap .schedule-scroll { max-height: none; flex: 1; min-height: 0; }

@media (max-width: 720px) {
  main { padding: 20px 14px 48px; }
  .schedule-grid { grid-template-columns: 44px repeat(4, minmax(110px, 1fr)); }
  .topbar { flex-wrap: wrap; }
}
