/* Fokusportal - grunnleggende, tilgjengelig og responsivt stilsett.
   Ingen eksterne fonter, ikonpakker eller CDN-avhengigheter. */

:root {
    --color-bg: #f4f6fb;
    --color-surface: #ffffff;
    --color-text: #1a1f36;
    --color-muted: #6b7280;
    --color-border: #e5e8f0;
    --color-primary: #2454d1;
    --color-primary-dark: #1a3fa8;
    --color-primary-soft: #eaf0fe;
    --color-danger: #dc2626;
    --color-danger-soft: #fdecec;
    --color-success: #16a34a;
    --color-success-soft: #e7f8ed;
    --color-info: #2563eb;
    --color-info-soft: #eaf1fb;

    --sidebar-width: 264px;
    --sidebar-bg: #16224f;
    --sidebar-bg-active-strip: #0f1a3f;
    --sidebar-text: #aab4e6;
    --sidebar-text-active: #ffffff;
    --sidebar-item-hover: rgba(255, 255, 255, .07);
    --sidebar-item-active: rgba(255, 255, 255, .14);
    --sidebar-border: rgba(255, 255, 255, .08);

    --focus-ring: 3px solid #1a73e8;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 4px rgba(16, 24, 40, .07);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    line-height: 1.55;
    font-size: 15.5px;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1rem;
}

.container-narrow {
    max-width: 480px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-dark); }

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: #fff;
    padding: .75rem 1rem;
    z-index: 200;
}
.skip-link:focus { left: 0; }

:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
}

/* =======================================================================
   Innlogget: venstre sidemeny + hovedinnhold
   ======================================================================= */

/* Visuelt skjult, men fortsatt i tabulatorrekkefølgen og fokuserbar med
   tastatur (display:none/visibility:hidden ville fjernet den helt). */
.sidebar-toggle-checkbox {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.35rem 1.5rem;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -.01em;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar__brand a {
    color: var(--sidebar-text-active);
    text-decoration: none;
}
.sidebar-close { display: none; }

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: 1rem .85rem;
}
.sidebar__nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: .95rem;
}
.sidebar__nav a:hover {
    background: var(--sidebar-item-hover);
    color: var(--sidebar-text-active);
}
.sidebar__nav a.is-active {
    background: var(--sidebar-item-active);
    color: var(--sidebar-text-active);
    box-shadow: inset 3px 0 0 0 #6f8dfb;
}
.nav-icon { width: 19px; height: 19px; flex-shrink: 0; }

.sidebar__user {
    margin-top: auto;
    border-top: 1px solid var(--sidebar-border);
    padding: .85rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.sidebar__user-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
    color: var(--sidebar-text-active);
    flex: 1 1 auto;
    min-width: 0;
    padding: .4rem;
    border-radius: var(--radius-sm);
}
.sidebar__user-link:hover, .sidebar__user-link.is-active { background: var(--sidebar-item-hover); }
.sidebar__user-info { min-width: 0; display: flex; flex-direction: column; }
.sidebar__user-name {
    font-size: .88rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar__user-role { font-size: .75rem; color: var(--sidebar-text); }
.sidebar__logout {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: .5rem;
    border-radius: var(--radius-sm);
    display: flex;
}
.sidebar__logout:hover { background: var(--sidebar-item-hover); color: var(--sidebar-text-active); }

.app-main {
    flex: 1 1 auto;
    min-width: 0;
}

.mobile-topbar {
    display: none;
    align-items: center;
    gap: .85rem;
    background: var(--sidebar-bg);
    color: #fff;
    padding: .85rem 1rem;
    position: sticky;
    top: 0;
    z-index: 30;
}
.mobile-topbar__brand { color: #fff; text-decoration: none; font-weight: 700; }
.mobile-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 22px;
    cursor: pointer;
}
.mobile-menu-btn span { display: block; height: 2px; background: #fff; border-radius: 2px; }

.sidebar-backdrop { display: none; }

.main-content {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem 2rem 3rem;
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 0 0 9999px transparent;
    }
    .sidebar-close { display: block; background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; line-height: 1; }
    .mobile-topbar { display: flex; }
    .main-content { padding: 1.25rem 1rem 2.5rem; }

    #sidebar-toggle:checked ~ .app-shell .sidebar { transform: translateX(0); }
    #sidebar-toggle:checked ~ .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(10, 14, 30, .45);
        z-index: 35;
    }
    body:has(#sidebar-toggle:focus-visible) .mobile-menu-btn { outline: var(--focus-ring); outline-offset: 2px; }
}

/* =======================================================================
   Gjestesider (innlogging, registrering, passord)
   ======================================================================= */
.guest-content {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--color-bg);
    text-align: center;
}
.guest-content .form-narrow,
.guest-content form { text-align: left; }
.guest-content h1 { margin-bottom: 1.5rem; }
.guest-content p { margin: .35rem 0; }

/* =======================================================================
   Fellesinnhold
   ======================================================================= */

/* --- Flash-meldinger --- */
.flash {
    padding: .75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
    font-size: .92rem;
}
.flash--success { background: var(--color-success-soft); color: var(--color-success); border-color: #bfe8cc; }
.flash--error { background: var(--color-danger-soft); color: var(--color-danger); border-color: #f5c6c6; }
.flash--info { background: var(--color-info-soft); color: var(--color-info); border-color: #c3d6f0; }

h1 { font-size: 1.6rem; letter-spacing: -.01em; margin: 0 0 1.25rem; }
h2 { font-size: 1.15rem; letter-spacing: -.005em; }

/* --- Kort / seksjoner --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.5rem;
}
.card h2 { margin-top: 0; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 720px) {
    .grid-2 { grid-template-columns: 1fr; }
}

.card-grid {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 1rem;
}
.card-grid .card, .card-grid > li { margin-bottom: 0; }

/* --- Skjema --- */
.form-narrow { max-width: 420px; }
.form-group { margin-bottom: 1rem; }
.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.form-row .form-group { flex: 1 1 160px; }
label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input:not([type]), select, textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    background: #fff;
    color: var(--color-text);
}
input:focus, select:focus, textarea:focus { outline: var(--focus-ring); outline-offset: 1px; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin-bottom: 1rem; }
.checkbox-label input { width: auto; }
.hint { color: var(--color-muted); font-size: .87rem; }

/* --- Knapper --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.05rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--color-surface);
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--color-border); color: var(--color-text); }
.btn-secondary:hover { background: #f4f6fb; }
.btn-small { padding: .3rem .65rem; font-size: .82rem; }
.btn-large { padding: .85rem 1.5rem; font-size: 1.05rem; }
.btn-text { background: none; border: none; color: var(--color-primary); text-decoration: underline; padding: .4rem 0; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-button { background: none; border: none; color: var(--color-text); cursor: pointer; text-decoration: underline; padding: 0; font-size: 1rem; }

.inline-form { display: inline-block; margin: 0; }
.button-row { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1rem 0; }

/* --- Avatarer --- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: .02em;
}
.avatar--0 { background: #2454d1; }
.avatar--1 { background: #7c3aed; }
.avatar--2 { background: #d97706; }
.avatar--3 { background: #db2777; }
.avatar--4 { background: #16a34a; }
.avatar--5 { background: #0891b2; }

/* --- Lister --- */
.task-list, .project-list, .stat-list { list-style: none; padding: 0; margin: 0; }
.task-list li, .project-list li { padding: .6rem 0; border-bottom: 1px solid var(--color-border); }
.stat-list li { padding: .3rem 0; }
.stat-number { font-weight: 700; font-size: 1.2rem; color: var(--color-primary); }

.subtask-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 0;
    border-bottom: 1px solid var(--color-border);
}
.subtask-main { flex: 1 1 auto; min-width: 0; }
.subtask-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.is-done { text-decoration: line-through; color: var(--color-muted); }

.drag-handle {
    cursor: grab;
    color: var(--color-muted);
    padding: 0 .25rem;
    user-select: none;
}
.reorder-buttons { display: flex; flex-direction: column; gap: .1rem; }
.reorder-buttons button {
    border: 1px solid var(--color-border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
    padding: .15rem .4rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .72rem;
    font-weight: 600;
    padding: .15rem .55rem;
    border-radius: 999px;
    background: #eef0f5;
    color: var(--color-muted);
    vertical-align: middle;
}
.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
}
.status-badge--open { background: var(--color-info-soft); color: var(--color-info); }
.status-badge--completed { background: var(--color-success-soft); color: var(--color-success); }
.status-badge--archived { background: #eef0f5; color: var(--color-muted); }

.tab-nav { display: flex; gap: 1.5rem; margin: 1rem 0 1.5rem; border-bottom: 1px solid var(--color-border); }
.tab-nav a { padding: .5rem 0; text-decoration: none; color: var(--color-muted); font-weight: 500; font-size: .92rem; }
.tab-nav a.is-active { color: var(--color-text); border-bottom: 2px solid var(--color-primary); font-weight: 700; }

.muted { color: var(--color-muted); font-size: .88rem; }

.pagination { display: flex; gap: .4rem; margin-top: 1rem; }
.pagination a { padding: .3rem .65rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); text-decoration: none; font-size: .88rem; }
.pagination a.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.table-wrap { overflow-x: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-muted);
    font-weight: 700;
}
.data-table td { text-align: left; padding: .65rem 1rem; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfe; }
.table-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.name-cell { display: flex; align-items: center; gap: .6rem; }

.search-form { display: flex; gap: .5rem; margin: 1rem 0; flex-wrap: wrap; }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* --- Fokusmodus: minimalistisk, distraksjonsfri (egen, enkel side) --- */
.focus-mode-body {
    background: var(--color-bg);
    margin: 0;
}
.focus-mode {
    text-align: center;
    padding-top: 3rem;
}
.focus-mode__counter { color: var(--color-muted); margin-bottom: .5rem; }
.focus-mode__breadcrumb { color: var(--color-muted); margin-bottom: 0; }
.focus-mode h1 { margin-top: .25rem; font-size: 1.8rem; }
.focus-mode__estimate { color: var(--color-muted); }
.focus-mode__actions { display: flex; flex-direction: column; gap: .75rem; align-items: center; margin: 2rem 0; }
.focus-mode__nav { display: flex; justify-content: space-between; margin-top: 1rem; }
.focus-mode__exit { margin-top: 2rem; }

.progress-bar {
    height: 8px;
    background: #e6e6e2;
    border-radius: 999px;
    overflow: hidden;
    margin: 0 auto 1.5rem;
}
.progress-bar__fill {
    height: 100%;
    background: var(--color-primary);
}

/* --- Mørk modus (respekterer systeminnstilling) --- */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #12141c;
        --color-surface: #1b1e29;
        --color-text: #e8e8e6;
        --color-muted: #a3a8ac;
        --color-border: #2c303c;
        --color-primary: #6f8dfb;
        --color-primary-dark: #90a8ff;
        --color-primary-soft: #1c2440;
        --sidebar-bg: #0d1230;
        --sidebar-bg-active-strip: #090c22;
    }
    input, select, textarea { background: #232733; color: var(--color-text); }
    .btn-secondary { background: #232733; }
    .btn-primary { color: #0c1211; }
    .progress-bar { background: #2c303c; }
    .data-table tbody tr:hover { background: #20242f; }
}

@media (max-width: 600px) {
    .card { padding: 1.1rem 1.15rem; }
}
