/*
 * shared.css — the one top-level header/nav + Masterlist modal, used
 * identically by all four sections (Raportointi/index.html, Masterlist
 * popup, Laskutus, Tilastot). Added 2026-07-19 to replace three different
 * header styles that had drifted apart (blue bar vs light bar, different
 * link sets showing/hiding per page).
 *
 * Fully self-contained: every variable below is prefixed --nav-* so this
 * file never collides with or depends on each page's own local :root
 * tokens (index.html/tilastot.html/laskutus.html each have their own
 * --blue/--primary/--border/etc. for their page-specific content, which
 * this file intentionally leaves untouched).
 */

:root {
  --nav-blue:     #1a6fc4;
  --nav-blue-dk:  #155a9e;
  --nav-green:    #1e7e34;
  --nav-green-lt: #d4edda;
  --nav-red:      #c0392b;
  --nav-red-lt:   #fde8e6;
  --nav-orange-lt:#fef3e2;
  --nav-grey:     #6c757d;
  --nav-grey-lt:  #f4f5f7;
  --nav-border:   #dee2e6;
  --nav-radius:   6px;
  --nav-shadow:   0 1px 4px rgba(0,0,0,.1);
}

/* ── Header / top nav ──
 * Three-zone grid (left / center / right) so the section nav sits dead
 * center regardless of what's in the outer zones — the two 1fr columns
 * always split the remaining space equally. Left zone holds the brand
 * plus the logout control (logout is account-level, not a section of the
 * app, so it's deliberately kept out of .app-nav — added 2026-07-19).
 * Right zone is a spacer, and doubles as a slot for #header-week on
 * pages that use it. */
.app-header {
  background: var(--nav-blue);
  color: #fff;
  padding: 12px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  box-shadow: var(--nav-shadow);
}
.app-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.app-header .app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}
.app-header .app-brand img { height: 22px; width: 22px; display: block; }
.app-header-right { justify-self: end; }
.app-header #header-week { opacity: .75; font-size: 12px; }

.app-logout {
  background: transparent;
  border: none;
  color: #fff;
  opacity: .7;
  font-size: .8rem;
  font-family: inherit;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}
.app-logout:hover { opacity: 1; text-decoration: underline; }

.app-nav { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.app-nav-link {
  font-size: .85rem;
  color: #fff;
  opacity: .85;
  font-family: inherit;
  text-decoration: none;
  padding: 5px 12px;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 5px;
  transition: opacity .15s, background .15s, color .15s;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}
.app-nav-link:hover { opacity: 1; background: rgba(255,255,255,.15); }
.app-nav-link.active {
  opacity: 1;
  background: #fff;
  color: var(--nav-blue);
  font-weight: 600;
  border-color: #fff;
}

/* ── Masterlist modal (used from every page's nav) ── */
#modal-root:empty { display: none; }
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-box {
  background: #fff;
  border-radius: var(--nav-radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--nav-border);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-header p { font-size: 12.5px; color: var(--nav-grey); margin: 0; }
.modal-body {
  padding: 8px 22px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--nav-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--nav-grey-lt);
}
.modal-empty { padding: 30px 0; text-align: center; color: var(--nav-grey); font-size: 13px; }

.ml-row {
  display: grid;
  grid-template-columns: 1fr 170px;
  gap: 4px 14px;
  align-items: center;
  padding: 10px 0 10px 10px;
  border-top: 1px solid var(--nav-border);
  border-left: 3px solid transparent;
}
.ml-row:first-child { border-top: none; }
.ml-row .ml-name { font-size: 13.5px; font-weight: 600; }
.ml-row .ml-note {
  grid-column: 1 / -1;
  font-size: 12px;
  margin-top: 2px;
  padding: 4px 8px;
  border-radius: var(--nav-radius);
  background: var(--nav-orange-lt);
  color: #8a5215;
}

/* Palvelutuote value color coding — reflects the CURRENTLY selected value,
   not whether it matches the import (that's a separate signal, below):
   Ostopalvelu / Palveluseteli / Itsemaksava = green, Ongelma! = red, Passiivinen = grey */
.ml-row select.ml-select {
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border-radius: var(--nav-radius);
  border: 1px solid var(--nav-border);
  background: #fff;
}
select.ml-select.value-green { border-color: var(--nav-green); background: var(--nav-green-lt); color: var(--nav-green); }
select.ml-select.value-red   { border-color: var(--nav-red);   background: var(--nav-red-lt);   color: var(--nav-red); }
select.ml-select.value-grey  { border-color: var(--nav-grey);  background: var(--nav-grey-lt);  color: var(--nav-grey); }
.ml-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px;
}
.ml-dot.value-green { background: var(--nav-green); }
.ml-dot.value-red   { background: var(--nav-red); }
.ml-dot.value-grey  { background: var(--nav-grey); }

/* "Differs from Masterlist / brand new customer" — gate popup only, an
   accent independent of the value color above so both signals read clearly. */
.ml-row.diff-amber { border-left-color: #e67e22; }

.ml-search {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--nav-border);
  border-radius: var(--nav-radius);
  margin-bottom: 6px;
  font-family: inherit;
}

/* Generic secondary button, used in modal footers on pages that don't
   already define .btn-secondary themselves (index.html has its own,
   visually identical, copy for the rest of its page). */
.modal-footer .btn-secondary {
  background: #fff;
  color: #212529;
  border: 1px solid var(--nav-border);
  padding: 7px 14px;
  border-radius: var(--nav-radius);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.modal-footer .btn-secondary:hover:not(:disabled) { background: var(--nav-grey-lt); border-color: #aaa; }
