/* Shared hero + KPI-row + card wrapper for the "row 1 hero / row 2 KPI tiles" layout. */

.emma-page-wrapper {
    padding: 1rem 1.25rem 1.5rem;
    overflow-y: auto;
    height: calc(100vh - 65px);
}

.emma-page-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(var(--bs-primary-rgb), 0.15), rgba(var(--bs-primary-rgb), 0.03));
    border-left: 5px solid var(--bs-primary);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.emma-page-hero-icon {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-primary);
    color: #fff;
    font-size: 1.6rem;
    flex-shrink: 0;
}

/* emma-icon uses a mask; force white inside the primary circle. */
.emma-page-hero-icon .emma-icon {
    background-color: #fff !important;
    width: 1.6rem;
    height: 1.6rem;
}

.emma-page-hero-title {
    font-size: 1.25rem;
    font-weight: 700;
    /* Mail subjects can be one unbroken token (MRN/MRN/MRN offers no break
       opportunity), which overflows the flex row and gets clipped. */
    overflow-wrap: anywhere;
}
/* Step the title down for long titles (e.g. a mail subject as the hero title)
   so the hero doesn't balloon. Bucketed by length in PageHeroComponent. */
.emma-page-hero-title.is-long   { font-size: 1.05rem; line-height: 1.3; }
.emma-page-hero-title.is-xlong  { font-size: 0.95rem; line-height: 1.3; }
.emma-page-hero-title.is-xxlong { font-size: 0.85rem; line-height: 1.35; }

.emma-page-hero-sub {
    font-size: 0.9rem;
    color: var(--bs-secondary-color);
    margin-top: 0.15rem;
}

.emma-page-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.emma-page-kpi-tile {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-left: 4px solid var(--bs-border-color);
    border-radius: 6px;
    padding: 0.85rem 1rem;
}

.emma-page-kpi-tile.tone-success { border-left-color: var(--bs-success); }
.emma-page-kpi-tile.tone-warning { border-left-color: var(--bs-warning); }
.emma-page-kpi-tile.tone-danger  { border-left-color: var(--bs-danger); }
.emma-page-kpi-tile.tone-info    { border-left-color: var(--bs-info); }
.emma-page-kpi-tile.tone-primary { border-left-color: var(--bs-primary); }

.emma-page-kpi-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
}

/* Colour key in front of a label, matching a chart series. */
.emma-page-kpi-swatch {
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 2px;
    margin-right: 0.35rem;
}

.emma-page-kpi-label-icon {
    margin-left: 0.3rem;
    color: var(--bs-secondary-color);
    cursor: help;
}

.emma-page-kpi-label-icon.is-warn {
    color: var(--bs-warning-text-emphasis);
}

.emma-page-kpi-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    margin-top: 0.15rem;
}

.emma-page-kpi-sub {
    font-size: 0.72rem;
    color: var(--bs-secondary-color);
    margin-top: 0.15rem;
}

/* A comparison sits to the right of the value, so the tile keeps its height. */
.emma-page-kpi-tile.has-change {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    column-gap: 0.75rem;
}

.emma-page-kpi-change {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    font-size: 0.72rem;
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.emma-page-kpi-progress {
    height: 8px;
    background: rgba(var(--bs-secondary-rgb), 0.15);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.35rem;
}

.emma-page-kpi-progress-fill {
    height: 100%;
    background: var(--bs-success);
    transition: width 300ms;
}

/* Compact: one tight line of tiles above a grid that fills the rest of the page. */
/* Always one row, the tiles share the width: the page above a grid reserves exactly one row's height
   (.main-view-wrapper.has-summary), so a wrapped second row would push the grid off the screen. */
.emma-page-kpi-row--compact {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0.5rem;
    margin: 0.35rem 0 0.4rem;
}
.emma-page-kpi-row--compact .emma-page-kpi-tile { padding: 0.35rem 0.75rem; min-width: 0; overflow: hidden; }
.emma-page-kpi-row--compact .emma-page-kpi-label,
.emma-page-kpi-row--compact .emma-page-kpi-sub,
.emma-page-kpi-row--compact .emma-page-kpi-change { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emma-page-kpi-row--compact .emma-page-kpi-label { font-size: 0.65rem; }
.emma-page-kpi-row--compact .emma-page-kpi-value { font-size: 1.15rem; margin-top: 0; }
.emma-page-kpi-row--compact .emma-page-kpi-sub { font-size: 0.68rem; margin-top: 0; }

/* Do NOT add overflow:hidden here — DxLoadingPanel wraps children in its own
   container without inheriting flex, so overflow:hidden makes the grid vanish
   when the loading panel doesn't supply an explicit height. */
.emma-page-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 6px;
    padding: 0.85rem 1rem;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.emma-page-card-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
