/* =========================================================
   NMMPrimus – app.css
   Basis UI og layout
   ========================================================= */

/* Reset / base */
* {
    box-sizing: border-box;
}

:root {
    --blue-deep: #0f4b87;
    --blue-strong: #0a61af;
    --blue-head: #acf3fc;
    --blue-light: #f2f6fb;
    --text-light: #f8fafc;
    --link-yellow: #ffd400;
    --page-bg: #f1f5fb;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    color: #222;
    background: var(--page-bg);
}

/* Layout */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem;
}

.container-fluid {
    padding: 1rem;
}

/* Typography */
h1, h2, h3 {
    margin-top: 0;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

/* Cards */
.card {
    background: #d2e9fd;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    font-weight: 600;
}

.card-body {
    padding: 1rem;
}

/* Header */
.site-header {
    color: var(--text-light);
    background: var(--blue-deep);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.site-header-top {
    background: var(--blue-deep);
}

.site-header-bottom {
    background: var(--blue-strong);
}

.site-header-row,
.site-header-bottom-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
}

.site-header-bottom-inner {
    justify-content: center;
}

.site-brand {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.site-brand-title {
    color: var(--text-light);
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.2px;
}

.site-brand-sub {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-user {
    color: var(--text-light);
    font-size: 0.95rem;
}

.btn-link.nav-cta {
    background: transparent;
    border-color: transparent;
    color: var(--text-light);
    padding: 0.25rem 0.5rem;
    text-decoration: underline;
}

.site-lockup {
    color: var(--text-light);
    font-weight: 600;
    letter-spacing: 0.2px;
    padding: 0.35rem 0;
}

/* Footer */
.site-footer {
    background: var(--blue-strong);
    color: var(--text-light);
    padding: 0.3rem 0;
    margin-top: 0.5rem;
}

.site-footer-inner {
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.6;
}

.footer-link {
    color: var(--link-yellow);
    font-weight: 600;
}

/* Forms */
label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    font-size: 1rem;
}

textarea {
    resize: vertical;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.form-check input {
    margin: 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.45rem 0.8rem;
    border-radius: 3px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #e5e7eb;
    color: #111;
}

.btn-link {
    background: transparent;
    color: #2563eb;
    border-color: transparent;
}

/* Utility */
.text-muted {
    color: #666;
}

/* =================================================
   Hendelsesmodus – horisontal layout
   ================================================= */
.hendelser-rad {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.hendelser-rad .form-check {
    white-space: nowrap;
}

/* =================================================
   Primus tabs (uten Bootstrap)
   ================================================= */
.primus-tabs {
    margin-top: 1rem;
}

.primus-tabbar {
    display: flex;
    gap: 0.5rem;
    border-bottom: 1px solid #cfcfcf;
    margin-bottom: 0.75rem;
}

.primus-tab {
    background: #f3f3f3;
    border: 1px solid #cfcfcf;
    border-bottom: none;
    padding: 0.4rem 0.9rem;
    cursor: pointer;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
}

.primus-tab.is-active {
    background: #fff;
    font-weight: 600;
}

.primus-pane {
    display: none;
}

.primus-pane.is-active {
    display: block;
}

/* =================================================
   iCh – VISUELL STATUS (robust, deterministisk)
   ================================================= */

/* AKTIVE felt */
input[data-foto-state="aktiv"],
textarea[data-foto-state="aktiv"],
select[data-foto-state="aktiv"] {
    border: 2px solid #198754 !important;
    background-color: #f6fffa !important;
    color: #222;
    opacity: 1;
}

/* INAKTIVE felt */
input[data-foto-state="inaktiv"],
textarea[data-foto-state="inaktiv"],
select[data-foto-state="inaktiv"] {
    border: 2px solid #dc3545 !important;
    background-color: #fff5f5 !important;
    color: #222;
    opacity: 1;
}

/* Finjustering Primus-skjema */
.primus-pane hr {
    margin: 1rem 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}

/* =================================================
   Layout utilities
   ================================================= */
.flex-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.flex-row-space-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.flex-row-end {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.flex-row-start {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.flex-wrap {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.flex-wrap-end {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.inline-form {
    display: inline-block;
    margin: 0;
}

.inline-form-with-margin {
    display: inline-block;
    margin-right: 10px;
}

/* =================================================
   Width utilities
   ================================================= */
.w-100px {
    width: 100px;
}

.w-7ch {
    flex: 0 0 7ch;
}

.w-15ch {
    flex: 0 0 15ch;
    width: 100%;
}

.w-420px {
    width: 420px;
}

.w-420px-form {
    width: 420px;
    margin: 0;
}

.flex-auto {
    flex: 1 1 auto;
    min-width: 300px;
}

.flex-fixed-420 {
    width: 420px;
    flex: 0 0 auto;
}

.flex-min-520 {
    flex: 1 1 auto;
    min-width: 520px;
}

.max-w-600 {
    max-width: 600px;
    margin: 30px auto;
}

.max-w-40ch {
    max-width: 40ch;
    width: 100%;
}

/* =================================================
   Text utilities
   ================================================= */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-center-label {
    text-align: center;
    display: block;
}

.text-large-bold {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    font-family: Arial, sans-serif;
    width: 100%;
}

.text-info {
    margin-bottom: 12px;
    color: #666;
    font-size: 0.95em;
}

.text-small-muted {
    font-size: 0.85em;
    font-weight: normal;
    opacity: 0.7;
}

.text-hint {
    font-size: 12px;
    opacity: 0.7;
}

.nowrap {
    white-space: nowrap;
}

.m-0 {
    margin: 0;
}

/* =================================================
   Modal
   ================================================= */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    position: relative;
    max-width: 500px;
    margin: 100px auto;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* =================================================
   Tables
   ================================================= */
.table-scroll-container {
    max-height: 25em;
    overflow-y: auto;
    border: 1px solid #ddd;
}

.table-sticky-header {
    margin-bottom: 0;
}

.table-sticky-header thead {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.table-scroll-520 {
    max-height: 520px;
    overflow: auto;
    border: 1px solid #ddd;
    padding: 6px;
}

.table-scroll-520 table {
    margin: 0;
}

.table-scroll-520 thead {
    position: sticky;
    top: 0;
    background: #fff;
}

.kandidat-rad {
    cursor: pointer;
}

/* =================================================
   Buttons
   ================================================= */
.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-success {
    background: #198754;
    color: #fff;
}

.btn-success:hover {
    background: #157347;
}

.btn-warning {
    background: #ffc107;
    color: #000;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.6rem 1.2rem;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

/* =================================================
   Flexbox utilities for alignment
   ================================================= */
.align-items-end {
    display: flex;
    align-items: flex-end;
}

.flex-col-gap {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* =================================================
   Card header variants
   ================================================= */
.card-header-blue {
    background: var(--blue-head);
}

/* =================================================
   Misc utilities
   ================================================= */
.inactive-hint {
    opacity: 0.7;
}

/* =================================================
   Tidsfilter
   ================================================= */
.primus-date-filter {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 1rem;
    padding: 0.5rem;
}

.btn-toggle-filter {
    background: #fff;
    border: 1px solid #ccc;
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
}

.btn-toggle-filter:hover {
    background: #e9ecef;
}

.filter-active-badge {
    background: #28a745;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin-left: 8px;
}

.date-filter-panel {
    padding: 1rem;
    border-top: 1px solid #dee2e6;
    margin-top: 0.5rem;
}

.date-filter-form {
    margin: 0;
}

.filter-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
}

.filter-field-selector {
    display: flex;
    gap: 0.5rem;
    flex-direction: column;
}

.filter-field-selector label {
    margin: 0;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

.filter-field-selector input[type="radio"] {
    margin: 0;
    width: auto;
}

.filter-date-inputs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.filter-date-inputs label {
    margin: 0;
    white-space: nowrap;
}

.filter-date-inputs input[type="date"] {
    padding: 0.375rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    width: auto;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.filter-actions .btn-primary {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}

.filter-actions .btn-primary:hover {
    background: #0056b3;
}

.filter-actions .btn-secondary {
    background: #6c757d;
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    display: inline-block;
}

.filter-actions .btn-secondary:hover {
    background: #545b62;
}

.filter-status {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    color: #0c5460;
    font-size: 14px;
}
