/* ============================================================
   Røde Kors Vaktsystem – Stylesheet
   Fargepalett: Rød #E8001C, Hvit #FFFFFF, Mørk #1A1A1A
   ============================================================ */

:root {
  --rk-red:        #E8001C;
  --rk-red-dark:   #B0001A;
  --rk-red-light:  #FDECEA;
  --rk-white:      #FFFFFF;
  --rk-black:      #1A1A1A;
  --rk-gray-50:    #F7F7F7;
  --rk-gray-100:   #EDEDED;
  --rk-gray-200:   #D8D8D8;
  --rk-gray-500:   #767676;
  --rk-gray-700:   #444444;
  --rk-green:      #1A7C3E;
  --rk-green-light:#EBF7F0;
  --rk-orange:     #E07B00;
  --rk-orange-light:#FFF4E0;
  --rk-blue:       #0055A5;
  --rk-blue-light: #E5F0FF;

  --radius:        4px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.10);
  --shadow:        0 2px 8px rgba(0,0,0,0.12);
  --transition:    0.18s ease;

  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.55;
  color: var(--rk-black);
  background: var(--rk-gray-50);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--rk-red); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--rk-red-dark); }

/* ── HEADER ── */
.site-header {
  background: var(--rk-red);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  flex-wrap: wrap;
}
.header-brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.brand-link { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-link:hover { text-decoration: none; opacity: 0.9; }
.rk-cross { width: 36px; height: 36px; flex-shrink: 0; }
.brand-name { font-size: 1.2rem; font-weight: 700; letter-spacing: 0.02em; color: #fff; }
.brand-sub { font-size: 0.72rem; color: rgba(255,255,255,0.80); font-weight: 400; margin-left: 4px; white-space: nowrap; }
.main-nav { display: flex; align-items: center; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav-link {
  color: rgba(255,255,255,0.88);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  text-decoration: none;
}
.header-user { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.user-name { font-size: 0.83rem; color: rgba(255,255,255,0.85); }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; padding: 4px 8px; }

/* ── MAIN & CONTAINER ── */
.site-main { flex: 1; padding: 24px 0 40px; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 780px; margin: 0 auto; padding: 0 20px; }

/* ── PAGE TITLE ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--rk-black); }
.page-subtitle { font-size: 0.88rem; color: var(--rk-gray-500); margin-top: 2px; }

/* ── CARDS ── */
.card {
  background: var(--rk-white);
  border: 1px solid var(--rk-gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  background: var(--rk-gray-50);
  border-bottom: 1px solid var(--rk-gray-200);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--rk-black); }
.card-body { padding: 20px; }
.card + .card { margin-top: 20px; }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--rk-gray-700); margin-bottom: 5px; }
.form-control {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font-size: 0.93rem;
  font-family: var(--font-main);
  color: var(--rk-black);
  background: #fff;
  border: 1px solid var(--rk-gray-200);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--rk-red);
  box-shadow: 0 0 0 3px rgba(232,0,28,0.12);
}
textarea.form-control { min-height: 90px; resize: vertical; }
.form-hint { font-size: 0.78rem; color: var(--rk-gray-500); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 0.88rem;
  font-family: var(--font-main);
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), opacity var(--transition);
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: 0.88; }
.btn-primary { background: var(--rk-red); color: #fff; }
.btn-primary:hover { background: var(--rk-red-dark); opacity: 1; }
.btn-secondary { background: var(--rk-gray-100); color: var(--rk-black); border: 1px solid var(--rk-gray-200); }
.btn-success  { background: var(--rk-green); color: #fff; }
.btn-warning  { background: var(--rk-orange); color: #fff; }
.btn-danger   { background: #c0392b; color: #fff; }
.btn-outline  { background: transparent; color: var(--rk-red); border: 1px solid var(--rk-red); }
.btn-outline:hover { background: var(--rk-red); color: #fff; opacity: 1; }
.btn-outline-white { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.6); font-size: 0.8rem; padding: 5px 12px; }
.btn-outline-white:hover { background: rgba(255,255,255,0.15); opacity: 1; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--rk-gray-100);
  vertical-align: middle;
}
.data-table th {
  background: var(--rk-gray-50);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rk-gray-500);
  border-bottom: 2px solid var(--rk-gray-200);
}
.data-table tr:hover td { background: var(--rk-gray-50); }
.data-table td:last-child { white-space: nowrap; }
.data-table .empty-row td { text-align: center; color: var(--rk-gray-500); font-style: italic; padding: 32px; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 20px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-aktiv    { background: var(--rk-green-light); color: var(--rk-green); }
.badge-avsluttet{ background: var(--rk-gray-100);   color: var(--rk-gray-500); }
.badge-ok       { background: var(--rk-green-light); color: var(--rk-green); }
.badge-ibruk    { background: var(--rk-orange-light);color: var(--rk-orange); }
.badge-ute      { background: #fde;                  color: #c0392b; }
.badge-lav      { background: var(--rk-blue-light);  color: var(--rk-blue); }
.badge-høy      { background: var(--rk-orange-light);color: var(--rk-orange); }
.badge-kritisk  { background: #c0392b; color: #fff; animation: blink 1s step-end infinite; }
.badge-default  { background: var(--rk-gray-100);   color: var(--rk-gray-700); }
.badge-role     { background: rgba(255,255,255,0.2); color: #fff; font-size: 0.65rem; }

@keyframes blink { 50% { opacity: 0.6; } }

/* ── LOG KATEGORI ── */
.log-cat {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 3px;
  text-transform: uppercase;
}
.cat-hendelse { background: var(--rk-red-light);    color: var(--rk-red); }
.cat-ressurs  { background: var(--rk-blue-light);   color: var(--rk-blue); }
.cat-status   { background: var(--rk-orange-light); color: var(--rk-orange); }
.cat-melding  { background: var(--rk-green-light);  color: var(--rk-green); }
.cat-annet    { background: var(--rk-gray-100);     color: var(--rk-gray-500); }

/* ── ALERTS ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
  border-left: 4px solid;
}
.alert-success { background: var(--rk-green-light); border-color: var(--rk-green); color: #155724; }
.alert-danger   { background: #fdecea; border-color: var(--rk-red); color: #721c24; }
.alert-warning  { background: var(--rk-orange-light); border-color: var(--rk-orange); color: #7a4f00; }
.alert-info     { background: var(--rk-blue-light); border-color: var(--rk-blue); color: #004085; }

/* ── STATS GRID ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--rk-white);
  border: 1px solid var(--rk-gray-200);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-number { font-size: 2.2rem; font-weight: 800; color: var(--rk-red); line-height: 1; }
.stat-label  { font-size: 0.78rem; color: var(--rk-gray-500); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── LOG TIMELINE ── */
.log-timeline { list-style: none; position: relative; padding: 0; }
.log-timeline::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--rk-gray-200);
}
.log-entry {
  position: relative;
  padding: 0 0 20px 50px;
}
.log-dot {
  position: absolute;
  left: 10px;
  top: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--rk-red);
  border: 3px solid var(--rk-white);
  box-shadow: 0 0 0 2px var(--rk-gray-200);
}
.log-entry:last-child { padding-bottom: 0; }
.log-meta { font-size: 0.78rem; color: var(--rk-gray-500); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-body { background: var(--rk-white); border: 1px solid var(--rk-gray-200); border-radius: var(--radius); padding: 10px 14px; font-size: 0.9rem; }

/* ── OPPDRAG HEADER STRIP ── */
.oppdrag-strip {
  background: var(--rk-white);
  border: 1px solid var(--rk-gray-200);
  border-left: 5px solid var(--rk-red);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.oppdrag-strip.avsluttet { border-left-color: var(--rk-gray-500); }
.oppdrag-strip.kritisk   { border-left-color: #c0392b; }
.oppdrag-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 0.8rem; color: var(--rk-gray-500); margin-top: 6px; }

/* ── MAP ── */
#map { height: 520px; border-radius: var(--radius); border: 1px solid var(--rk-gray-200); }
.map-toolbar {
  background: var(--rk-white);
  border: 1px solid var(--rk-gray-200);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── LOGIN ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rk-red);
}
.login-card {
  background: var(--rk-white);
  border-radius: 6px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}
.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-logo svg { width: 52px; height: 52px; }
.login-logo .rk-cross-red rect { fill: var(--rk-red); }
.login-title { font-size: 1.4rem; font-weight: 800; color: var(--rk-black); }
.login-sub   { font-size: 0.82rem; color: var(--rk-gray-500); margin-top: 2px; text-align: center; }

/* ── DASHBOARD GRID ── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dash-full { grid-column: 1 / -1; }

/* ── FILTER BAR ── */
.filter-bar {
  background: var(--rk-white);
  border: 1px solid var(--rk-gray-200);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }

/* ── RESOURCE STATUS PANEL ── */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.res-card {
  background: var(--rk-white);
  border: 1px solid var(--rk-gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-top: 3px solid var(--rk-gray-200);
  box-shadow: var(--shadow-sm);
}
.res-card.tilgjengelig { border-top-color: var(--rk-green); }
.res-card.i_bruk       { border-top-color: var(--rk-orange); }
.res-card.ute_av_drift { border-top-color: #c0392b; }
.res-name { font-weight: 700; font-size: 0.95rem; }
.res-type { font-size: 0.75rem; color: var(--rk-gray-500); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── FOOTER ── */
.site-footer {
  background: var(--rk-black);
  color: rgba(255,255,255,0.6);
  font-size: 0.78rem;
  padding: 14px 0;
  margin-top: auto;
}
.site-footer .container {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.footer-time { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ── PAGINATION ── */
.pagination { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--rk-gray-200);
  border-radius: var(--radius);
  background: var(--rk-white);
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--rk-black);
  text-decoration: none;
}
.page-btn.active { background: var(--rk-red); color: #fff; border-color: var(--rk-red); }
.page-btn:hover:not(.active) { background: var(--rk-gray-50); text-decoration: none; }

/* ── UTILITY ── */
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.text-muted { color: var(--rk-gray-500); font-size: 0.85rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.fw-bold { font-weight: 700; }
.section-title { font-size: 1rem; font-weight: 700; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid var(--rk-gray-100); }
hr.divider { border: none; border-top: 1px solid var(--rk-gray-200); margin: 20px 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .main-nav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--rk-red-dark); flex-direction: column; padding: 8px; z-index: 99; }
  .main-nav.open { display: flex; }
  .nav-toggle { display: block; }
  .header-user { gap: 6px; }
  .user-name { display: none; }
  .form-row, .form-row-3, .two-col, .three-col, .dash-grid { grid-template-columns: 1fr; }
  .site-header { position: relative; }
  .page-header { flex-direction: column; }
}
