/* Ekens samfällighetsförening – app styles on top of Fluent UI Blazor.
   Colors come from the Fluent design tokens so the app follows the Fluent theme. */

/* Montserrat Medium (the logo font), self-hosted. From @fontsource/montserrat 5.3.0, SIL Open Font License
   (fonts/Montserrat-OFL.txt). The latin subset covers Swedish å, ä, ö. */
@font-face {
    font-family: Montserrat;
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("fonts/montserrat-latin-500-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
        U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --eken-gap: 16px;
    --eken-radius: var(--borderRadiusLarge, 8px);
    --eken-danger: var(--colorPaletteRedForeground1, #b10e1c);
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: var(--fontFamilyBase, "Segoe UI", system-ui, sans-serif);
    font-size: var(--fontSizeBase300, 14px);
    line-height: var(--lineHeightBase300, 20px);
    color: var(--colorNeutralForeground1, var(--eken-fallback-foreground));
    background: var(--colorNeutralBackground2, var(--eken-fallback-background));
}

/* Used only until Fluent UI has set its color tokens, so a dark page does not flash white while loading.
   html[data-theme] is set by the script in App.razor (Utseende choice or the system setting). */
:root { --eken-fallback-background: #fafafa; --eken-fallback-foreground: #242424; }
[data-theme="dark"] { --eken-fallback-background: #1f1f1f; --eken-fallback-foreground: #ffffff; }

h1, h2, h3 {
    margin: 0;
    font-weight: var(--fontWeightSemibold, 600);
}

h1 { font-size: var(--fontSizeHero700, 28px); line-height: 1.25; }
h2 { font-size: var(--fontSizeBase500, 20px); line-height: 1.3; }
h3 { font-size: var(--fontSizeBase400, 16px); margin-bottom: 8px; }

h1:focus { outline: none; }

.muted { color: var(--colorNeutralForeground3, #616161); }

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

/* ---------- Shell ---------- */

/* Neutral header (not Fluent's brand-blue default) so the green/brown logo keeps its colors. */
.shell-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 var(--eken-gap);
    background: var(--colorNeutralBackground1, #fff) !important;
    color: var(--colorNeutralForeground1, #242424) !important;
    border-bottom: 1px solid var(--colorNeutralStroke2, #e0e0e0);
}

/* Header brand: the official oak symbol with the association's name in Montserrat (the logo font). */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    text-decoration: none;
}

.brand img { display: block; height: 40px; width: auto; flex: none; }

.brand-name {
    display: flex;
    flex-wrap: wrap;
    column-gap: .3em;
    font-family: Montserrat, var(--fontFamilyBase, "Segoe UI", system-ui, sans-serif);
    font-weight: 500;
    font-size: 22px;
    line-height: 1.15;
    letter-spacing: .01em;
    color: #626f3a;
}

[data-theme="dark"] .brand-name { color: #ffffff; }

/* Fluent draws the mobile menu button in white for its brand-colored header; ours is neutral. */
.shell-header .fluent-layout-hamburger fluent-button {
    color: var(--colorNeutralForeground1, #242424) !important;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.user-menu form { margin: 0; }

.user-name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--colorNeutralForeground2, #424242);
}

.content-inner {
    padding: 24px clamp(16px, 3vw, 40px) 48px;
    max-width: 1280px;
}

/* ---------- Page building blocks ---------- */

.page-header { margin-bottom: 20px; }
.page-header p { margin: 4px 0 0; }

.page-message { margin-bottom: 12px; }

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    color: var(--colorNeutralForeground3, #616161);
}

.card { padding: 20px; margin-bottom: var(--eken-gap); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 16px;
}

.card-header h2 a { color: inherit; }

.form-panel {
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--colorNeutralStroke2, #e0e0e0);
    border-radius: var(--eken-radius);
    background: var(--colorNeutralBackground2, #fafafa);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 16px 0;
    color: var(--colorNeutralForeground2, #424242);
}

.empty-state p { margin: 0; }

.two-columns {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(320px, 2fr);
    gap: var(--eken-gap);
    align-items: start;
}

/* ---------- Overview ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--eken-gap);
    margin-bottom: 24px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 20px;
}

.stat-value {
    font-size: var(--fontSizeHero800, 32px);
    line-height: 1.1;
    font-weight: var(--fontWeightSemibold, 600);
}

.stat-label { color: var(--colorNeutralForeground3, #616161); }

.row-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--eken-gap);
}

.house-row-card { padding: 16px 20px; }
.house-row-card .card-header { flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: 8px; }

.house-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.house-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--colorNeutralStroke3, #f0f0f0);
}

.house-list li:first-child { border-top: 0; }

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 12px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 16px;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    width: 100%;
}

.danger { color: var(--eken-danger) !important; }

.validation-message {
    color: var(--eken-danger);
    font-size: 12px;
}

.select-small {
    font: inherit;
    padding: 4px 8px;
    border-radius: var(--borderRadiusMedium, 4px);
    border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
    background: var(--colorNeutralBackground1, #fff);
    color: inherit;
}

/* ---------- Static (SSR) account pages: plain HTML styled to match Fluent ---------- */

.account-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
    box-sizing: border-box;
}

.account-card {
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
    padding: 28px;
    border-radius: var(--eken-radius);
    background: var(--colorNeutralBackground1, #fff);
    box-shadow: var(--shadow8, 0 4px 8px rgba(0, 0, 0, .14), 0 0 2px rgba(0, 0, 0, .12));
}

.account-card h1 { font-size: 24px; margin-bottom: 16px; }

.account-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 24px;
}

.account-brand img { display: block; width: 100%; max-width: 300px; height: auto; }
.account-brand small {
    color: var(--colorNeutralForeground3, #616161);
    letter-spacing: .08em;
    text-transform: uppercase;
    font-size: 12px;
}

.account-footer { margin: 16px 0 0; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: var(--fontWeightSemibold, 600); }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input:not([type]) {
    font: inherit;
    padding: 6px 10px;
    min-height: 32px;
    box-sizing: border-box;
    border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
    border-bottom-color: var(--colorNeutralStrokeAccessible, #616161);
    border-radius: var(--borderRadiusMedium, 4px);
    background: var(--colorNeutralBackground1, #fff);
    color: inherit;
}

.field input:focus-visible {
    outline: none;
    border-bottom: 2px solid var(--colorCompoundBrandStroke, #0f6cbd);
}

.field input.invalid { border-color: var(--eken-danger); }

.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.field-inline label { font-weight: normal; }

.btn {
    font: inherit;
    font-weight: var(--fontWeightSemibold, 600);
    min-height: 32px;
    padding: 5px 12px;
    border-radius: var(--borderRadiusMedium, 4px);
    border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
    background: var(--colorNeutralBackground1, #fff);
    color: inherit;
    cursor: pointer;
}

.btn-primary {
    border-color: transparent;
    background: var(--colorBrandBackground, #0f6cbd);
    color: var(--colorNeutralForegroundOnBrand, #fff);
}

.btn-primary:hover { background: var(--colorBrandBackgroundHover, #115ea3); }

.btn-block { width: 100%; }

.alert {
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: var(--borderRadiusMedium, 4px);
    border: 1px solid;
}

.alert-success {
    background: var(--colorPaletteGreenBackground1, #f1faf1);
    border-color: var(--colorPaletteGreenBorder1, #9fd89f);
}

.alert-error {
    background: var(--colorPaletteRedBackground1, #fdf3f4);
    border-color: var(--colorPaletteRedBorder1, #eeacb2);
}

.alert-info {
    background: var(--colorPaletteYellowBackground1, #fffef5);
    border-color: var(--colorPaletteYellowBorder1, #fef7b2);
}

/* Utseende and Logga ut in the side menu (narrow screens). */
.nav-account {
    padding: 8px 12px 16px;
    border-top: 1px solid var(--colorNeutralStroke2, #e0e0e0);
    margin-top: 8px;
}

@media (max-width: 768px) {
    .nav-account.narrow-only { display: flex !important; flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ---------- History ---------- */

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.history-list > li {
    padding: 8px 0;
    border-bottom: 1px solid var(--colorNeutralStroke2, #e0e0e0);
}

.history-list > li:last-child { border-bottom: none; }

.history-meta {
    font-size: 0.85em;
    color: var(--colorNeutralForeground3, #616161);
}

.history-changes {
    margin: 4px 0 0;
    padding-left: 20px;
    font-size: 0.95em;
    overflow-wrap: anywhere;
}

.history-changes del { color: var(--colorNeutralForeground3, #616161); }

.history-changes ins { text-decoration: none; font-weight: 600; }

/* ---------- Blazor error UI ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1000;
    padding: 10px 16px;
    background: var(--colorPaletteYellowBackground1, #fffef5);
    border-top: 1px solid var(--colorPaletteYellowBorder1, #fef7b2);
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 10px; }

/* ---------- Small screens ---------- */

.narrow-only { display: none !important; }

@media (max-width: 768px) {
    .narrow-only { display: block !important; }
    a.fluent-navitem.narrow-only { display: flex !important; }
    .wide-only { display: none !important; }
}

@media (max-width: 768px) {
    .two-columns { grid-template-columns: 1fr; }
    .user-name { display: none; }
    .shell-header { gap: 8px; padding: 0 10px; }
    .brand { gap: 8px; }
    .brand img { height: 32px; }
    .brand-name { font-size: 14px; line-height: 1.1; }
    .card { padding: 16px; }
}

/* Data grid cells that may hold long text (addresses, e-mail) wrap instead of being cut off. */
.wrap-cells td[role="gridcell"] {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    height: auto !important;
    min-height: 32px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.card-header h2 fluent-link { font-size: inherit; font-weight: inherit; }

/* ---------- Share links (admin) ---------- */

.share-created { border-left: 4px solid var(--colorPaletteGreenBorder2, #107c10); }
.share-created h2 { margin-bottom: 8px; }

.share-url {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.share-url-input {
    flex: 1;
    min-width: 0;
    font: 13px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
    padding: 6px 10px;
    border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
    border-radius: var(--borderRadiusMedium, 4px);
    background: var(--colorNeutralBackground2, #fafafa);
    color: inherit;
}

/* ---------- Resident directory (start page) ---------- */

.directory-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 24px;
}

.directory-tools {
    display: flex;
    gap: 8px;
    align-items: center;
    width: min(100%, 440px);
}

.directory-search { flex: 1; min-width: 0; }

/* Search/PDF row with the "Simulering" switch below it. Always at the right edge, also when the header
   wraps and the block gets a line of its own. */
.directory-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    margin-left: auto;
    max-width: 100%;
}

.directory-actions .directory-tools { width: 440px; max-width: 100%; }

.simulation-control {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 32px;
}

/* The year dropdown keeps Fluent's own width (160px, fixed inside the component). Making it narrower only
   shrinks the outer box and the visible control spills out to the right. */

.directory {
    width: 100%;
    border-collapse: collapse;
    background: var(--colorNeutralBackground1, #fff);
    border-radius: var(--eken-radius);
    overflow: hidden;
    box-shadow: var(--shadow2, 0 1px 2px rgba(0, 0, 0, .14));
}

.directory thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    text-align: left;
    font-weight: var(--fontWeightSemibold, 600);
    color: var(--colorNeutralForeground2, #424242);
    background: var(--colorNeutralBackground3, #f5f5f5);
    padding: 10px 12px;
    border-bottom: 1px solid var(--colorNeutralStroke1, #d1d1d1);
}

.directory td,
.directory tbody th {
    padding: 6px 12px;
    vertical-align: top;
    text-align: left;
    font-weight: normal;
    overflow-wrap: anywhere;
}

.directory-house { border-top: 1px solid var(--colorNeutralStroke2, #e0e0e0); }
.directory-house:first-of-type { border-top: 0; }
.directory-house tr:first-child > * { padding-top: 10px; }
.directory-house tr:last-child > * { padding-bottom: 10px; }

.directory .col-address { white-space: nowrap; }
.directory .col-address a { font-weight: var(--fontWeightSemibold, 600); }
.directory .col-number { color: var(--colorNeutralForeground3, #616161); white-space: nowrap; width: 1%; }
.directory .col-phone { white-space: nowrap; }
.directory .col-number .label { display: none; }

.directory a { color: var(--colorBrandForegroundLink, #115ea3); text-decoration: none; }
.directory a:hover { text-decoration: underline; }

.directory-house.is-empty td.muted { font-style: italic; }

/* Houses in odd house rows (Huslänga 1, 3, 5 …): a light tint of the logo green, in light and dark mode. */
.directory-house.is-odd-row { background: rgba(98, 111, 58, .07); }

[data-theme="dark"] .directory-house.is-odd-row { background: rgba(167, 181, 111, .12) !important; }

@media (max-width: 700px) {
    .directory thead { display: none; }
    .directory, .directory tbody, .directory tr, .directory td, .directory tbody th { display: block; }
    .directory { background: transparent; box-shadow: none; }

    .directory-house {
        margin-bottom: 10px;
        padding: 10px 14px;
        border: 1px solid var(--colorNeutralStroke2, #e0e0e0) !important;
        border-radius: var(--eken-radius);
        background: var(--colorNeutralBackground1, #fff);
    }

    .directory-house.is-odd-row { background: rgba(98, 111, 58, .07); }

    .directory td, .directory tbody th { padding: 0 !important; }
    .directory .col-address { display: inline-block; font-size: 16px; margin-right: 8px; }
    .directory .col-number { display: inline-block; width: auto; }
    .directory .col-number .label { display: inline; }
    .directory .col-name { margin-top: 8px; font-weight: var(--fontWeightSemibold, 600); }
    .directory .col-phone:empty, .directory .col-email:empty { display: none; }
    .directory-house.is-empty td.muted { margin-top: 6px; }
}

/* ---------- Städansvar ---------- */

.maintenance-year { white-space: nowrap; }
.maintenance-year.is-this-year { font-weight: var(--fontWeightSemibold, 600); }
.maintenance-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 0; }
.house-name { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.directory .col-maint, .directory .col-zone { white-space: nowrap; width: 1%; }
.directory .col-maint .label, .directory .col-zone .label { display: none; }

.schedule-scroll { overflow-x: auto; }

.schedule {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.schedule th, .schedule td {
    padding: 6px 10px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--colorNeutralStroke2, #e0e0e0);
    white-space: nowrap;
}

.schedule thead th {
    background: var(--colorNeutralBackground3, #f5f5f5);
    color: var(--colorNeutralForeground2, #424242);
}

.schedule tbody th { font-weight: var(--fontWeightSemibold, 600); }
.schedule tbody th .muted { display: block; font-weight: normal; font-size: 12px; }
.schedule .is-current { background: var(--colorPaletteGreenBackground1, #f1faf1); }
.schedule thead th.is-current { background: var(--colorPaletteGreenBackground2, #e0f2e0); }
.schedule a { color: var(--colorBrandForegroundLink, #115ea3); text-decoration: none; }

@media (max-width: 700px) {
    .directory .col-maint, .directory .col-zone { display: inline-block; width: auto; margin-left: 8px; }
    .directory .col-maint .label, .directory .col-zone .label { display: inline; color: var(--colorNeutralForeground3, #616161); }
}

/* ---------- Print: the content only ---------- */

@media print {
    .shell-header, .nav, .directory-tools, .simulation-control, .breadcrumb, .page-message, #blazor-error-ui { display: none !important; }
    body, .content, .content-inner { background: #fff !important; color: #000 !important; padding: 0 !important; }
    .directory { box-shadow: none; }
    .directory thead th { position: static; }
    .directory-house { break-inside: avoid; }
    .directory a { color: inherit; }
}
