/* =========================================================
   2GM Eiendom – Bestillingsportal
   ========================================================= */

:root {
  --c-brand: #1B4F72;
  --c-brand-dark: #143a55;
  --c-brand-light: #2a6a98;

  --c-text: #1f2937;
  --c-muted: #6b7280;
  --c-border: #e5e7eb;
  --c-bg: #f5f7fa;
  --c-surface: #ffffff;

  --c-green-bg: #EAF3DE;
  --c-green-fg: #3B6D11;
  --c-amber-bg: #FAEEDA;
  --c-amber-fg: #854F0B;
  --c-red-bg:   #FCEBEB;
  --c-red-fg:   #A32D2D;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.06);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

* { box-sizing: border-box; }

/* HTML hidden-attributtet må vinne over senere display:flex/grid-regler */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button { font: inherit; cursor: pointer; }
input, select, button { font-family: inherit; }

/* =========================================================
   Topbar
   ========================================================= */
.topbar {
  background: var(--c-brand);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: .2px;
}
.topbar-logo { font-size: 18px; }
.topbar-divider { opacity: .55; }
.topbar-app { font-weight: 500; opacity: .92; }

.topbar-right .badge-customer {
  background: rgba(255,255,255,.14);
  color: #fff;
  border: 1px solid rgba(255,255,255,.28);
  padding: 6px 12px;
  font-weight: 500;
}

/* =========================================================
   Layout
   ========================================================= */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }
}

.panel {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--c-brand-dark);
}

/* =========================================================
   Legende
   ========================================================= */
.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--c-muted);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.dot-green { background: var(--c-green-bg); border: 1px solid var(--c-green-fg); }
.dot-amber { background: var(--c-amber-bg); border: 1px solid var(--c-amber-fg); }
.dot-red   { background: var(--c-red-bg);   border: 1px solid var(--c-red-fg); }

/* =========================================================
   Kalender
   ========================================================= */
.cal-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}
.cal-month {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-transform: capitalize;
  min-width: 180px;
  text-align: center;
}

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-weekdays {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.cal-weekdays span {
  text-align: center;
  padding: 4px 0;
}

.cal-cell {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--c-surface);
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: transform .08s ease, box-shadow .08s ease;
  min-height: 64px;
}
.cal-cell:hover:not(.cal-cell-empty):not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.cal-cell:focus-visible {
  outline: 2px solid var(--c-brand-light);
  outline-offset: 2px;
}
.cal-cell-empty {
  background: transparent;
  cursor: default;
  pointer-events: none;
}
.cal-cell .cal-date {
  font-weight: 600;
  font-size: 14px;
}
.cal-cell .cal-rooms {
  font-size: 11px;
  font-weight: 500;
  opacity: .85;
}
.cal-cell.is-today .cal-date::after {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--c-brand);
  vertical-align: middle;
}
.cal-cell.is-selected,
.cal-cell.is-range-from,
.cal-cell.is-range-to {
  outline: 2px solid var(--c-brand);
  outline-offset: -2px;
  box-shadow: 0 2px 6px rgba(27,79,114,.18);
}
.cal-cell.is-range-from::before,
.cal-cell.is-range-to::before {
  content: attr(data-endpoint);
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  background: var(--c-brand);
  color: #fff;
  padding: 1px 5px;
  border-radius: 8px;
  pointer-events: none;
}
.cal-cell.is-in-range {
  outline: 1px dashed rgba(27,79,114,.45);
  outline-offset: -2px;
  background-image: linear-gradient(rgba(27,79,114,.08), rgba(27,79,114,.08));
}
.cal-cell { position: relative; }

.cal-cell.lvl-green {
  background: var(--c-green-bg);
  color: var(--c-green-fg);
  border-color: rgba(59,109,17,.18);
}
.cal-cell.lvl-amber {
  background: var(--c-amber-bg);
  color: var(--c-amber-fg);
  border-color: rgba(133,79,11,.18);
}
.cal-cell.lvl-red {
  background: var(--c-red-bg);
  color: var(--c-red-fg);
  border-color: rgba(163,45,45,.18);
  cursor: not-allowed;
}

.cal-footnote {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--c-muted);
}

/* =========================================================
   Skjema
   ========================================================= */
.booking-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="tel"],
input[type="date"],
input[type="number"],
select {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #fff;
  color: var(--c-text);
  width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--c-brand-light);
  box-shadow: 0 0 0 3px rgba(27,79,114,.15);
}

/* Open-ended checkbox under Til-dato */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--c-muted);
  cursor: pointer;
  user-select: none;
}
.checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--c-brand);
  cursor: pointer;
}
.checkbox span { line-height: 1.3; }

input[type="date"]:disabled {
  background: #f1f3f5;
  color: #9aa5b1;
  cursor: not-allowed;
}

/* Counter (rom +/-) */
.counter {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 6px;
  align-items: stretch;
  max-width: 200px;
}
.counter input {
  text-align: center;
  font-weight: 600;
  -moz-appearance: textfield;
}
.counter input::-webkit-outer-spin-button,
.counter input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.counter-btn {
  border: 1px solid var(--c-border);
  background: #fff;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 600;
  color: var(--c-brand);
  transition: background .12s ease;
}
.counter-btn:hover { background: #f3f6fa; }
.counter-btn:active { background: #e6ecf2; }

/* Gjester */
.guests {
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 0;
}
.guests legend {
  padding: 0 6px;
}
.guests-hint {
  margin: -4px 0 8px;
  font-size: 12px;
  color: var(--c-muted);
}
.guests-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.guest-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: #fafbfc;
}
.guest-row-main {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 8px;
  align-items: center;
}
.guest-num {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
}
.guest-toggle {
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12px;
  color: var(--c-brand);
  white-space: nowrap;
}
.guest-toggle:hover { background: #f0f4f8; }
.guest-row.has-own-dates .guest-toggle {
  background: var(--c-brand);
  color: #fff;
  border-color: var(--c-brand);
}
.guest-summary {
  margin: 0 0 0 78px;
  font-size: 12px;
  color: var(--c-muted);
}
.guest-summary.is-custom {
  color: var(--c-brand);
  font-weight: 600;
}
.guest-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 4px 0 0 78px;
  padding: 8px;
  background: #fff;
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-sm);
}
.guest-dates .field-label { font-size: 12px; }
.guest-dates .checkbox { grid-column: 1 / -1; margin-top: 2px; }

/* "Bruk fellesperioden i stedet" — vises bare når gjesten faktisk har
   egne datoer satt, ikke under den første utfyllingen. */
.guest-reset {
  grid-column: 1 / -1;
  align-self: start;
  background: transparent;
  border: none;
  padding: 4px 0 0;
  font-size: 12px;
  color: var(--c-brand);
  text-decoration: underline;
  cursor: pointer;
  text-align: left;
  display: none;
}
.guest-row.has-own-dates .guest-reset {
  display: inline;
}

@media (max-width: 480px) {
  .guest-summary,
  .guest-dates { margin-left: 0; }
  .guest-dates { grid-template-columns: 1fr; }
}

/* =========================================================
   Knapper / badges
   ========================================================= */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 600;
  transition: background .12s ease, transform .08s ease;
}
.btn-primary {
  background: var(--c-brand);
  color: #fff;
}
.btn-primary:hover { background: var(--c-brand-light); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled {
  background: #9aa5b1;
  cursor: not-allowed;
}
.btn-submit { margin-top: 4px; }

.btn-ghost {
  background: transparent;
  color: var(--c-brand);
  border: 1px solid var(--c-border);
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}
.btn-ghost:hover { background: #f3f6fa; }

.btn-link {
  background: none;
  border: none;
  color: var(--c-brand);
  text-decoration: underline;
  padding: 4px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef2f6;
  color: var(--c-muted);
  border: 1px solid var(--c-border);
}
.badge.lvl-green { background: var(--c-green-bg); color: var(--c-green-fg); border-color: rgba(59,109,17,.25); }
.badge.lvl-amber { background: var(--c-amber-bg); color: var(--c-amber-fg); border-color: rgba(133,79,11,.25); }
.badge.lvl-red   { background: var(--c-red-bg);   color: var(--c-red-fg);   border-color: rgba(163,45,45,.25); }

.form-message {
  margin: 4px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.form-message.is-ok {
  background: var(--c-green-bg);
  color: var(--c-green-fg);
}
.form-message.is-error {
  background: var(--c-red-bg);
  color: var(--c-red-fg);
}
.form-message.has-warning {
  background: var(--c-amber-bg);
  color: var(--c-amber-fg);
}
.form-warning {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: rgba(255,255,255,.55);
  border-left: 3px solid currentColor;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
}
.form-submsg {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: .85;
  font-weight: 500;
}

/* =========================================================
   Footer
   ========================================================= */
.footer {
  text-align: center;
  padding: 18px;
  color: var(--c-muted);
  font-size: 12px;
}

/* =========================================================
   Auth-skjerm
   ========================================================= */
.auth-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, var(--c-brand) 0%, var(--c-brand-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.auth-card {
  background: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-logo {
  font-weight: 700;
  color: var(--c-brand);
  font-size: 14px;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.auth-title {
  margin: 4px 0 8px;
  font-size: 22px;
  color: var(--c-brand-dark);
}
.auth-sub {
  margin: 0 0 20px;
  color: var(--c-muted);
  font-size: 14px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-hint {
  margin: 0;
  font-size: 12px;
  color: var(--c-muted);
  text-align: center;
}
.auth-error {
  margin: 12px 0 0;
  padding: 10px;
  background: var(--c-red-bg);
  color: var(--c-red-fg);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
