﻿/* ============================
   DASHBOARD COMPONENTS
   ============================ */

.platforma-dashboard {
    /* HF 2026-05-11: was max-width: 1200px which centered content with
       large whitespace gutters on wider monitors (1600+, 21" admin
       displays, ultra-wide tenant operator screens). Widened to 1600px
       to use 33% more horizontal real estate without going edge-to-edge
       (the latter hurts readability at typical desktop widths). Stat
       cards / data tables now breathe better and reduce the
       "centered-document-on-a-blank-page" feel that several admin
       surfaces had. */
    max-width: 1600px;
    margin: 0 auto;
}

/* DESIGN-CONSISTENCY (2026-09-09, audit M11) — canonical page wrapper.
   This class was used as a page root in ~42 views but had NO rule, so those
   pages rendered edge-to-edge while dashboard pages capped at 1600. Give it the
   SAME cap/centering so a list/settings page reads at one width regardless of
   which wrapper the author reached for. The other no-op page roots migrate onto
   this class rather than getting their own divergent rule. */
.platforma-page-content {
    max-width: 1600px;
    margin: 0 auto;
}

/* ============================
   PAGE HEADER (compact alternative)
   ============================
   16.A.16 — Pages that aren't a welcome/landing surface (settings,
   list views, edit forms) shouldn't burn a third of the viewport on
   a gradient banner. Use .platforma-page-header instead of
   .platforma-welcome-section for these surfaces.

   Drop-in replacement: same DOM structure, no gradient, just a
   compact title row with optional inline action slot. Future
   admin pages can opt in.
*/
.platforma-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.5rem 0 1rem 0;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--platforma-gray-200);
}

.platforma-page-header__content {
    min-width: 0;
    flex: 1;
}

.platforma-page-header__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: var(--platforma-gray-900);
    line-height: 1.25;
}

.platforma-page-header__subtitle {
    margin: 0;
    color: var(--platforma-gray-600);
    font-size: 0.95rem;
    max-width: 720px;
}

.platforma-page-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Welcome Section
   HF 2026-05-11: replaced tenant-primary→tenant-secondary gradient with
   the canonical --platforma-page-banner-platform token. Reason: welcome-
   section was rendering DIFFERENT colors on every page depending on
   whether a tenant context was active and which tenant theme was
   selected (Malmöhus11 = red→tan, no-tenant SuperAdmin = red→purple,
   etc.) — visible as 4+ banner variants across SuperAdmin pages.
   Now ALL welcome-section instances use the same Platforma red→
   pressed-red gradient as PageBanner ViewComponent's platform variant.
   Tenant-specific branding still applies inside tenant portals via
   --tenant-* tokens on per-tenant chrome (BrandThemeRegistry); the
   chrome-level admin headers stay platform-branded. */
.platforma-welcome-section {
    /* CONSIST-2b (2026-09-09): flat chrome-less header — was a navy gradient
       hero (var(--platforma-page-banner-platform)) with white text on ~90
       tenant module pages. Now transparent + one bottom hairline + dark text,
       identical to _AdminPageHeader / PageBanner ("ét hoved i hele appen"). */
    background: transparent;
    color: var(--pf-color-text-primary);
    border: 0;
    border-bottom: 1px solid var(--pf-color-border-subtle);
    border-radius: 0;
    padding: 0.4rem 0 1.15rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
}

.platforma-welcome-title {
    /* CONSIST-2b: sans page-title (Metronic-true), was a serif headline. All
       three headers (_AdminPageHeader / PageBanner / welcome-section) now
       share the sans face on a flat surface. */
    font-family: var(--platforma-font-sans);
    font-size: clamp(1.35rem, 2vw, 1.6rem);
    font-weight: 700;
    margin-bottom: 0.3rem;
    word-break: break-word;
    overflow-wrap: break-word;
    letter-spacing: -0.015em;
}

.platforma-welcome-subtitle {
    color: var(--pf-color-text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 60ch;
}

/* Badges inside the welcome section: subtle light treatment (was white-glass
   on the retired navy surface). */
.platforma-welcome-subtitle .platforma-badge {
    background: var(--pf-color-surface-sunken);
    color: var(--pf-color-text-secondary);
    border: 1px solid var(--pf-color-border-subtle);
}

/* Welcome section button overrides — buttons inside the gradient header need adapted colors */
.platforma-welcome-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

/* Prevent welcome section from overflowing — allow content to shrink */
.platforma-welcome-content {
    min-width: 0;
    flex: 1;
}

/* CONSIST-2b (2026-09-09): the white-on-navy button overrides are retired with
   the flat header. Buttons inside .platforma-welcome-section now fall back to
   the normal .platforma-btn-* styles, which are designed for light surfaces —
   right-aligned action row, primary = navy accent, exactly like the header
   actions on _AdminPageHeader. */

/* Stats Grid */
.platforma-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.platforma-stat-card {
    background: var(--platforma-white);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--platforma-shadow);
    border: 1px solid var(--platforma-gray-200);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

    .platforma-stat-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--platforma-shadow-lg);
    }

.platforma-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.platforma-stat-icon-primary {
    background: var(--platforma-primary-light);
    color: var(--platforma-primary);
}

.platforma-stat-icon-success {
    background: var(--platforma-success-light);
    color: var(--platforma-success);
}

.platforma-stat-icon-warning {
    background: var(--platforma-warning-light);
    color: var(--platforma-warning);
}

.platforma-stat-icon-info {
    background: var(--platforma-info-light);
    color: var(--platforma-info);
}

.platforma-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--platforma-gray-900);
    line-height: 1;
}

.platforma-stat-label {
    color: var(--platforma-gray-600);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.platforma-stat-change {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.platforma-stat-change-positive {
    /* SA-14a (2026-09-27): the success FILL as 12px text measured 3.77:1 on the Home stat tile ("All systems
       operational"); the -fg member of the same family is the text role (it flips with the theme). */
    color: var(--pf-color-status-success-fg);
}

.platforma-stat-change-neutral {
    color: var(--platforma-gray-500);
}

/* Dashboard Grid */
.platforma-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.platforma-dashboard-card {
    background: var(--platforma-white);
    /* WAVE0-F2b (2026-09-09): demo10 flat — 8px (was 12px) + micro-shadow. */
    border-radius: var(--pf-radius-lg, 8px);
    box-shadow: var(--platforma-shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.06));
    border: 1px solid var(--platforma-gray-200);
}

/* WAVE0-F1 (2026-09-09): .platforma-content-card was referenced by ~26 tenant/
   security views but NEVER defined → they rendered as bare, unstyled divs. Define
   it as a self-contained padded card (demo10 flat: 8px radius, hairline, micro-shadow,
   20px padding). Loaded on admin + portal via platforma-dashboard.css. */
.platforma-content-card {
    background: var(--pf-color-surface-raised, var(--platforma-white));
    color: var(--platforma-ink-primary, #1a1d2b);
    border: 1px solid var(--pf-color-border-subtle, var(--platforma-gray-200));
    border-radius: var(--platforma-radius-md, 8px);
    box-shadow: var(--platforma-shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.06));
    padding: var(--platforma-space-5, 20px);
}

.platforma-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--platforma-gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.platforma-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--platforma-gray-900);
}

.platforma-card-content {
    padding: 1.5rem;
}

/* Activity List */
.platforma-activity-list {
}

.platforma-activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--platforma-gray-100);
}

    .platforma-activity-item:last-child {
        border-bottom: none;
    }

.platforma-activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.platforma-activity-icon-success {
    background: var(--platforma-success-light);
    color: var(--platforma-success);
}

.platforma-activity-icon-info {
    background: var(--platforma-info-light);
    color: var(--platforma-info);
}

.platforma-activity-title {
    font-weight: 600;
    color: var(--platforma-gray-900);
    font-size: 0.875rem;
}

.platforma-activity-description {
    color: var(--platforma-gray-600);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.platforma-activity-time {
    color: var(--platforma-gray-500);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Status List */
.platforma-status-list {
}

.platforma-status-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
}

.platforma-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.platforma-status-online {
    background: var(--platforma-success);
    box-shadow: 0 0 0 3px var(--platforma-success-light);
}

/* AUDIT-HEALTH-1 (2026-09-16) — until now the only state this dot had was green, which is the
   whole story of the block it lives in: the dashboard PAINTED system status with no data behind
   it, so a colour for "not fine" was never needed. These two are its siblings, built from the
   same token pair so they flip with the theme exactly as the green one does. */
.platforma-status-offline {
    background: var(--pf-color-status-danger);
    box-shadow: 0 0 0 3px var(--pf-color-status-danger-soft);
}

.platforma-status-unknown {
    background: var(--pf-color-text-tertiary);
    box-shadow: 0 0 0 3px var(--pf-color-surface-sunken);
}

.platforma-status-title {
    font-weight: 600;
    color: var(--platforma-gray-900);
    font-size: 0.875rem;
}

.platforma-status-description {
    color: var(--platforma-gray-600);
    font-size: 0.875rem;
    margin-top: 0.125rem;
}

/* Responsive tweaks for dashboard */
@media (max-width: 1024px) {
    .platforma-welcome-section {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

@media (max-width: 767.98px) {
    .platforma-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .platforma-welcome-section {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.4rem 0 1rem;
        gap: 0.75rem;
    }

    .platforma-welcome-actions {
        width: 100%;
    }

    .platforma-welcome-title {
        font-size: 1.25rem;
    }

    .platforma-welcome-subtitle {
        font-size: 0.8125rem;
    }

    .platforma-stat-value {
        font-size: 1.25rem;
    }

    .platforma-stat-label {
        font-size: 0.75rem;
    }

    .platforma-card-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .platforma-card-title {
        font-size: 0.9rem;
    }

    .platforma-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .platforma-stats-grid {
        grid-template-columns: 1fr;
    }

    .platforma-welcome-section {
        padding: 0.4rem 0;
    }
}

/* ═══════════════════════════════════════════════════════════
   Shared card-gallery responsive behaviour
   Used by template-picker galleries across Tenants/Create,
   Facilities/Create, Tasks/Create, ProspectDataSources/Create,
   TenantEmailSettings/Index.
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .pf-card-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Also collapse module + language grids and stat tiles on mobile */
@media (max-width: 480px) {
    .pf-module-grid,
    .pf-lang-grid,
    .pf-role-gallery,
    .pf-home-quick-actions,
    .platforma-crm-stats,
    .platforma-stats-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   Stat-grid unification — single source of truth
   Home uses .platforma-stats-grid (icon stat cards)
   TenantWorkspace uses .platforma-stats-row (clickable tile cards)
   CRM + Tenant Context pages use .platforma-crm-stats (value+label tiles)
   All three are grid containers with identical breakpoint behaviour.
   ═══════════════════════════════════════════════════════════ */
.platforma-crm-stats,
.platforma-stats-grid,
.platforma-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--platforma-space-4, 1rem);
    margin-bottom: var(--platforma-space-4, 1rem);
}

@media (max-width: 640px) {
    .platforma-crm-stats,
    .platforma-stats-grid,
    .platforma-stats-row {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 0.75rem;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   DL-03 / DL-04 — SuperAdmin & tenant-admin home action counters and
   quick-link tiles. Relocated out of Views/Home/Index.cshtml's inline
   <style> so the DS-3 / DL-11 ratchets cover them and they follow theme.
   Card surfaces use the raised role (was a bare white surface literal); the icon
   tile palettes are the PF status trios (was inline pastel/ink hex). */
.pf-action-counters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
}
.pf-action-counter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    background: var(--pf-color-surface-raised);
    border: 1px solid var(--pf-color-border-subtle);
    border-radius: var(--pf-radius-md);
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
}
.pf-action-counter:hover {
    border-color: var(--pf-color-action-primary);
    box-shadow: var(--pf-color-shadow-md);
    transform: translateY(-1px);
}
.pf-action-counter-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--pf-color-text-tertiary);
}
.pf-action-counter--active .pf-action-counter-value { color: var(--pf-color-action-primary); }
.pf-action-counter--alert .pf-action-counter-value { color: var(--pf-color-status-danger); }
.pf-action-counter--alert {
    border-left: 4px solid var(--pf-color-status-danger);
}
.pf-action-counter-label {
    font-size: .92rem;
    font-weight: 600;
    color: var(--pf-color-text-secondary);
}
.pf-action-counter-cta {
    font-size: .78rem;
    color: var(--pf-color-text-tertiary);
    margin-top: 4px;
}

.pf-home-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
}
.pf-quick-action-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--pf-color-surface-raised);
    border: 1px solid var(--pf-color-border-subtle);
    border-radius: var(--pf-radius-md);
    text-decoration: none;
    color: inherit;
    transition: all 0.15s ease;
}
.pf-quick-action-card:hover {
    border-color: var(--pf-color-action-primary);
    box-shadow: var(--pf-color-shadow-md);
    transform: translateY(-1px);
}
.pf-quick-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--pf-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
/* DL-04 — icon-tile palettes on the PF status trios (was inline pastel/ink hex) */
.pf-quick-icon--info    { background: var(--pf-color-status-info-soft);    color: var(--pf-color-status-info-fg); }
.pf-quick-icon--warning { background: var(--pf-color-status-warning-soft); color: var(--pf-color-status-warning-fg); }
.pf-quick-icon--success { background: var(--pf-color-status-success-soft); color: var(--pf-color-status-success-fg); }
.pf-quick-icon--primary { background: var(--pf-color-action-primary-soft); color: var(--pf-color-action-primary); }
.pf-quick-title { font-weight: 700; font-size: 0.9rem; color: var(--pf-color-text-primary); }
.pf-quick-sub   { font-size: 0.75rem; color: var(--pf-color-text-tertiary); margin-top: 2px; }

/* PORTAL-01 — resident-portal quick-action tile icons (were platform-dependent
   emoji). The Icon component paints in currentColor; give it a calm secondary
   tone that follows the theme instead of an OS emoji colour. */
.portal-tile-icon {
    color: var(--pf-color-text-secondary);
    flex-shrink: 0;
}

/* PORTAL-05 — resident-portal quick-action tiles gain the hover/focus
   affordance + trailing chevron the shared .platforma-dashboard-card lacks
   (an additive class so the bookings/tasks/info container cards are
   untouched). Token-only — the .pf-quick-action-card recipe, so the DS-3
   baselines do not grow. */
.portal-quick-tile:hover {
    border-color: var(--pf-color-action-primary);
    box-shadow: var(--pf-color-shadow-md);
}
.portal-quick-tile:focus-visible {
    outline: none;
    box-shadow: var(--pf-focus-ring);
}
.portal-tile-chevron {
    margin-inline-start: auto;
    color: var(--pf-color-text-tertiary);
    flex-shrink: 0;
}
@media (prefers-reduced-motion: no-preference) {
    .portal-quick-tile {
        transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    }
    .portal-quick-tile:hover {
        transform: translateY(-1px);
    }
}

/* ============================================================
   WAVE0-H1 (2026-09-10) — fill undefined-orphan classes that
   left admin surfaces unstyled (the colorless-badge defect class,
   caught by the Wave 0 defect-audit). All were BaselineKnownOrphans.
   ============================================================ */

/* Compact vertical KPI tile (value over label) used in .platforma-stats-row,
   e.g. TenantAuditLog. The icon-row flavour is .platforma-stat-card above. */
.platforma-stat {
    background: var(--platforma-white);
    border: 1px solid var(--platforma-gray-200);
    border-radius: var(--pf-radius-lg, 8px);
    padding: var(--platforma-space-4, 16px);
    box-shadow: var(--platforma-shadow-sm);
}
.platforma-stat__value {
    font-size: var(--platforma-text-2xl, 1.5rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--platforma-gray-900);
}
.platforma-stat__label {
    margin-top: 2px;
    font-size: var(--platforma-text-sm);
    color: var(--platforma-muted, var(--platforma-gray-600));
}

/* User identity cell (avatar + name/email) used across Users / Tenants /
   Facilities lists. .platforma-user-name is already defined in platforma-layout.css. */
.platforma-user-cell {
    display: inline-flex;
    align-items: center;
    gap: var(--platforma-space-2, 8px);
}
.platforma-user-avatar-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 28px;
    block-size: 28px;
    flex-shrink: 0;
    border-radius: var(--pf-radius-full, 999px);
    background: var(--pf-color-surface-sunken, var(--platforma-gray-100));
    color: var(--pf-color-text-secondary, var(--platforma-gray-700));
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
    user-select: none;
}
.platforma-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.platforma-user-id {
    font-size: var(--platforma-text-xs, 0.75rem);
    color: var(--platforma-muted, var(--platforma-gray-600));
}
