/* ==========================================================================
   MIN SIDE (HJEMMESKJERMEN)
   --------------------------------------------------------------------------
   Dette er utseendet til /home:

   1. Øverst: en hilsen med firmanavn og dato.
   2. Under: små knapper (chips) som viser/skjuler hver sin boks.
   3. Til slutt: boksene med innhold, i et rutenett.

   Rutenettet tilpasser seg selv:
   - bred skjerm: flere bokser side om side
   - nettbrett: to bokser
   - mobil: én boks i bredden

   Farger hentes fra temaet, så dette virker i lyst, grått og mørkt tema.
   ========================================================================== */

.home {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

/* ---------- Hilsen øverst ---------- */

.home-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 16px 18px;
    border: 1px solid var(--app-border, #e4e6e8);
    border-radius: 6px;
    background: var(--app-surface, #ffffff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.home-hero-text {
    min-width: 0;
}

.home-title {
    margin: 0;
    color: var(--app-text, #333333);
    font-size: 20px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.home-hero-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
    color: var(--app-muted, #6b7280);
    font-size: 12.5px;
}

.home-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .home-meta-item .rzi {
        font-size: 16px;
    }

.home-meta-sep {
    opacity: 0.5;
}

.home-hero-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

    .home-hero-actions .rz-button {
        height: 32px !important;
        min-height: 32px !important;
        padding: 0 12px !important;
    }

/* ---------- Tilpass Min side ---------- */

.home-tools {
    display: flex;
    justify-content: flex-end;
    margin-bottom: -4px;
}

.home-settings {
    position: relative;
}

.home-settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--app-border, #e4e6e8);
    border-radius: 4px;
    background: var(--app-surface, #ffffff);
    color: var(--app-muted, #6b7280);
    font-size: 17px;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

    .home-settings-btn:hover,
    .home-settings-btn:focus-visible,
    .home-settings-btn[aria-expanded="true"] {
        border-color: var(--p-border-strong, #c5ccc7);
        background: var(--p-surface-muted, #f6f7f6);
        color: var(--app-text, #333333);
    }

.home-settings-backdrop {
    position: fixed;
    inset: 0;
    z-index: 390;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: default;
}

.home-settings-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 400;
    width: 220px;
    padding: 4px;
    border: 1px solid var(--app-border, #e4e6e8);
    border-radius: 6px;
    background: var(--app-surface, #ffffff);
    box-shadow: var(--app-shadow, 0 4px 12px rgba(20, 28, 23, 0.08));
}

.home-settings-title {
    padding: 7px 8px 5px;
    color: var(--app-muted, #6b7280);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.home-settings-option {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--app-muted, #6b7280);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

    .home-settings-option:hover,
    .home-settings-option:focus-visible {
        background: var(--app-hover-bg, rgba(0, 0, 0, 0.05));
        color: var(--app-text, #333333);
    }

    .home-settings-option .rzi {
        font-size: 17px;
        color: var(--app-muted, #6b7280);
    }

    .home-settings-option.is-on {
        color: var(--app-text, #333333);
        font-weight: 600;
    }

    .home-settings-option.is-on .rzi {
        color: var(--app-text, #333333);
    }

/* ---------- Rutenett med bokser ---------- */

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 16px;
    align-items: start;
}

.home-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--app-border, #e4e6e8);
    border-radius: 6px;
    background: var(--app-surface, #ffffff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

.home-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--app-border, #e4e6e8);
}

.home-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--app-text, #333333);
    font-size: 13px;
    letter-spacing: -0.01em;
}

.home-panel-title .rzi {
    font-size: 16px;
}

.home-panel-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    border-radius: 4px;
    background: var(--app-hover-bg, rgba(0, 0, 0, 0.06));
    color: var(--app-muted, #6b7280);
    font-size: 10.5px;
    font-weight: 700;
}

.home-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
}

/* ---------- Én rad i en boks ---------- */

.home-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

    .home-row:hover {
        background: var(--app-hover-bg, rgba(0, 0, 0, 0.05));
    }

.home-thumb {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--app-border, #e4e6e8);
    border-radius: 4px;
    background-color: var(--p-surface-muted, #f0f4f1);
    background-position: center;
    background-size: cover;
    color: var(--app-muted, #6b7280);
    cursor: pointer;
    overflow: hidden;
}

    .home-thumb .rzi {
        font-size: 22px;
    }

.home-row-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1 1 auto;
    min-width: 0;
}

.home-row-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.home-row-title {
    min-width: 0;
    color: var(--app-text, #333333);
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home-status {
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.home-row-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    color: var(--app-muted, #6b7280);
    font-size: 12px;
}

.home-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--app-hover-bg, rgba(0, 0, 0, 0.06));
    color: var(--app-muted, #6b7280);
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.home-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--app-active-text, #2b6b4a);
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

    .home-link:hover {
        text-decoration: underline;
    }

.home-row-action {
    flex: 0 0 auto;
}

    .home-row-action .rz-button {
        height: 28px !important;
        min-height: 28px !important;
        padding: 0 8px !important;
        font-size: 11.5px !important;
    }

/* ---------- Tomme bokser ---------- */

.home-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 16px;
    color: var(--app-muted, #6b7280);
    font-size: 13px;
    text-align: center;
}

    .home-empty .rzi {
        font-size: 26px;
        opacity: 0.55;
    }

.home-empty-page {
    min-height: 180px;
    border: 1px dashed var(--app-border, #e4e6e8);
    border-radius: 6px;
    background: var(--app-surface, #ffffff);
}

    .home-empty-page .rz-button {
        margin-top: 6px;
    }

/* ---------- Laster inn (skeleton) ---------- */

.home-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--app-muted, #6b7280);
    font-size: 12.5px;
}

.home-loading-spinner {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    border: 2px solid var(--app-border, #e4e6e8);
    border-top-color: var(--app-accent, #327a55);
    border-radius: 50%;
    animation: home-loading-spin 0.9s linear infinite;
}

.home-skeleton {
    display: block;
    border-radius: 4px;
    background: linear-gradient(
        90deg,
        var(--app-hover-bg, rgba(0, 0, 0, 0.05)) 25%,
        var(--app-border, #e4e6e8) 37%,
        var(--app-hover-bg, rgba(0, 0, 0, 0.05)) 63%);
    background-size: 400% 100%;
    animation: home-skeleton-shimmer 1.3s ease infinite;
}

.home-skeleton-title {
    width: 46%;
    height: 12px;
}

.home-skeleton-count {
    width: 24px;
    height: 16px;
}

.home-skeleton-thumb {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
}

.home-skeleton-line {
    height: 10px;
}

.home-skeleton-line.is-wide {
    width: 68%;
}

.home-skeleton-line.is-narrow {
    width: 42%;
}

@keyframes home-loading-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes home-skeleton-shimmer {
    0% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-loading-spinner,
    .home-skeleton {
        animation: none;
    }
}

/* ---------- Kapasitet (abonnementskvote) ---------- */

.home-capacity {
    padding: 14px 16px 16px;
    border: 1px solid var(--app-border, #e4e6e8);
    border-radius: 6px;
    background: var(--app-surface, #ffffff);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.home-capacity-head {
    margin-bottom: 12px;
}

.home-capacity-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--app-text, #333333);
    font-size: 13px;
    letter-spacing: -0.01em;
}

.home-capacity-title .rzi {
    font-size: 16px;
}

.home-capacity-subtitle {
    margin: 3px 0 0;
    color: var(--app-muted, #6b7280);
    font-size: 12px;
}

.home-capacity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 16px;
}

.home-capacity-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.home-capacity-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
}

.home-capacity-label {
    color: var(--app-muted, #6b7280);
    font-weight: 600;
}

.home-capacity-value {
    color: var(--app-text, #333333);
    font-weight: 600;
    white-space: nowrap;
}

.home-capacity-bar {
    height: 4px;
    overflow: hidden;
    border-radius: 2px;
    background: var(--app-hover-bg, rgba(0, 0, 0, 0.06));
}

    .home-capacity-bar span {
        display: block;
        height: 100%;
        border-radius: inherit;
        background: var(--app-accent, #327a55);
    }

    .home-capacity-bar.is-near span {
        background: var(--p-warning, #a06f24);
    }

    .home-capacity-bar.is-full span {
        background: var(--p-danger, #a94a4a);
    }

/* ---------- Tilpasning til mindre skjermer ---------- */

@media (max-width: 900px) {
    .home-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .home {
        gap: 12px;
    }

    .home-hero {
        padding: 14px;
    }

    .home-title {
        font-size: 19px;
    }

    .home-hero-actions {
        width: 100%;
    }

    .home-thumb {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
    }

    .home-row {
        gap: 10px;
        padding: 7px;
    }

    .home-row-action .rz-button {
        padding: 0 8px !important;
    }

    .home-capacity {
        padding: 12px;
    }

    .home-capacity-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 8px 12px;
    }
}
