/* ============================================================================
   admin-group-emails.css — Group emails (Group-Email-v1 WF-98 to WF-104): the
   list, the email page's header, its Write, Audience, and Preview tabs, the
   confirm (a full-screen sheet on a phone), a send's progress, and its record.
   The shell, tables, tabs, panels, and move buttons come from chrome.css,
   admin-editors.css, and admin-feedback.css; this file lays out what is new.
   The preview frames' widths are the design's own numbers (a desktop mail
   window, and the 390 px phone the wireframes draw), not stray literals.
   ========================================================================== */

/* --- The list (WF-98) --- */
.gem-table__subject a {
    overflow-wrap: anywhere;
}

.gem-table__act {
    text-align: right;
}

/* Below 768 px each row is a card: subject, then kind and date, then the status with its count, Copy at the right. */
@media (max-width: 767px) {
    .gem-table {
        min-width: 0;
    }

    .gem-table thead {
        display: none;
    }

    .gem-table,
    .gem-table tbody,
    .gem-table tr,
    .gem-table td {
        display: block;
        width: 100%;
    }

    .gem-table tr {
        position: relative;
        padding: 12px 88px 12px 14px;
        border-bottom: 1px solid var(--border-hairline);
    }

    .gem-table td {
        height: auto;
        padding: 2px 0;
        border: 0;
    }

    .gem-table td.gem-table__kind,
    .gem-table td.gem-table__when {
        display: inline;
        width: auto;
        color: var(--text-secondary);
        font-size: var(--font-size--1);
    }

    .gem-table td.gem-table__kind::after {
        content: " · ";
    }

    .gem-table td.gem-table__status,
    .gem-table td.gem-table__sent {
        display: inline-block;
        width: auto;
        margin-right: var(--space-sm);
    }

    .gem-table td.gem-table__act {
        position: absolute;
        top: 10px;
        right: 8px;
        width: auto;
    }
}

/* --- The email page's header (WF-99, WF-102) --- */
.gem-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.gem-head__title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
}

.gem-head__subject {
    margin: 0;
    font-size: var(--font-size-1);
    overflow-wrap: anywhere;
}

.gem-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.gem-head__line {
    margin: var(--space-xs) 0 var(--space-md);
    color: var(--text-secondary);
    font-size: var(--font-size--1);
}

/* Phone: Save draft and Send a test sit in a bar at the bottom of the screen (WF-99's phone note). */
@media (max-width: 767px) {
    .gem-head__actions {
        position: sticky;
        bottom: 0;
        z-index: 2;
        order: 3;
        width: 100%;
        padding: var(--space-sm) 0;
        border-top: 1px solid var(--border-hairline);
        background-color: var(--surface-page);
    }
}

/* --- Write (WF-99) --- */
.gem-write {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    max-width: 760px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.gem-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.gem-group__legend {
    margin-bottom: var(--space-xs);
    padding: 0;
    font-weight: 600;
}

.gem-radio {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: var(--space-sm);
    align-items: baseline;
}

.gem-radio input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.gem-radio__hint {
    grid-column: 2;
    margin: 0;
}

.gem-about {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.gem-about__add {
    width: 28ch;
    max-width: 100%;
}

.gem-subject .input {
    width: 100%;
}

.gem-names {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.gem-names__line {
    margin: 0;
}

.gem-names__acts {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-xs);
}

.gem-block {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--container-pad-dense);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-container);
    background-color: var(--surface-raised);
}

.gem-block__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
}

.gem-block__label {
    color: var(--text-secondary);
    font-size: var(--font-size--1);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.gem-block__moves {
    display: flex;
    gap: var(--space-xs);
}

.gem-block__text {
    min-height: 8rem;
}

.gem-block__image-facts {
    font-family: var(--font-numeric);
}

.gem-block__button {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: var(--space-md);
}

.gem-block__button .input {
    width: 100%;
}

@media (max-width: 767px) {
    .gem-block__button {
        grid-template-columns: minmax(0, 1fr);
    }
}

.gem-add {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.gem-size {
    margin: 0;
    color: var(--text-secondary);
    font-family: var(--font-numeric);
    font-size: var(--font-size--1);
}

.gem-size--over {
    color: var(--status-danger-text);
}

/* --- Preview (WF-101) --- */
.gem-preview {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    min-width: 0;
}

.gem-preview__meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin: 0;
    font-size: var(--font-size--1);
}

.gem-preview__meta div {
    display: flex;
    gap: var(--space-sm);
}

.gem-preview__meta dt {
    min-width: 8ch;
    color: var(--text-secondary);
}

.gem-preview__meta dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.gem-preview__frames {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--space-lg);
}

/* Each frame keeps its device width and scrolls inside its own box when the screen is narrower. */
.gem-preview__frame {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-container);
    background-color: #FFFFFF;
}

.gem-preview__frame iframe {
    display: block;
    height: 720px;
    border: 0;
    background-color: #FFFFFF;
}

.gem-preview__frame--desktop iframe {
    width: 720px;
}

.gem-preview__frame--phone iframe {
    width: 390px;
}

/* The phone's own tabs show on a phone only (GroupEmailPreviewTab). */
.gem-preview__tabs--narrow {
    display: none;
}

/* Phone: Preview opens at the phone's own width (NWS-R43); the desktop frame and its tab are for wider screens. */
@media (max-width: 767px) {
    .gem-preview__tabs--wide,
    .gem-preview__frame--desktop {
        display: none;
    }

    .gem-preview__tabs--narrow {
        display: flex;
    }

    .gem-preview__frame--phone {
        width: 100%;
    }

    .gem-preview__frame--phone iframe {
        width: 100%;
    }
}

.gem-preview__text {
    max-width: 720px;
    margin: 0;
    padding: var(--container-pad-dense);
    overflow-x: auto;
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-container);
    background-color: var(--surface-raised);
    font-size: var(--font-size--1);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* --- Audience (WF-100) --- */
.gem-aud {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    max-width: 760px;
    min-width: 0;
}

.gem-aud__lede,
.gem-aud__note {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-size--1);
}

.gem-aud__picks {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* One row: the group, its product's menu, its count, Remove. */
.gem-pick {
    display: grid;
    grid-template-columns: 18ch minmax(0, 1fr) 8ch auto;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--container-pad-dense);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-container);
    background-color: var(--surface-raised);
}

.gem-pick__group {
    grid-column: 1;
    font-weight: 600;
}

/* Everyone and All testers name no product: the group's words take the product's column too. */
.gem-pick--plain .gem-pick__group {
    grid-column: 1 / 3;
}

.gem-pick__product {
    grid-column: 2;
    min-width: 0;
    max-width: 32ch;
    overflow-wrap: anywhere;
}

.gem-pick__count {
    grid-column: 3;
    font-family: var(--font-numeric);
    text-align: right;
}

.gem-pick__remove {
    grid-column: 4;
}

.gem-aud__add {
    width: 28ch;
    max-width: 100%;
}

.gem-aud__sum,
.gem-aud__left {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-width: 44ch;
    margin: 0;
}

.gem-aud__row {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
}

.gem-aud__row dt {
    color: var(--text-secondary);
}

.gem-aud__row dd {
    margin: 0;
    font-family: var(--font-numeric);
}

.gem-aud__head {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-size--1);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.gem-aud__will {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    max-width: 44ch;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-hairline);
    font-weight: 600;
}

.gem-aud__will strong {
    font-family: var(--font-numeric);
}

/* Phone: the group and its count on one line, the product's menu under them, Remove at the right. */
@media (max-width: 767px) {
    .gem-pick {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .gem-pick__group,
    .gem-pick--plain .gem-pick__group {
        grid-column: 1;
        grid-row: 1;
    }

    .gem-pick__count {
        grid-column: 2;
        grid-row: 1;
    }

    .gem-pick__product {
        grid-column: 1;
        grid-row: 2;
        max-width: none;
    }

    .gem-pick__remove {
        grid-column: 2;
        grid-row: 2;
    }
}

/* --- The confirm (WF-103) --- */
.gem-confirm__facts {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin: 0;
}

.gem-confirm__fact {
    display: grid;
    grid-template-columns: 9ch minmax(0, 1fr);
    gap: var(--space-sm);
}

.gem-confirm__fact dt {
    color: var(--text-secondary);
}

.gem-confirm__fact dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.gem-confirm__moved {
    margin: 0;
    color: var(--status-warning-text);
    font-weight: 600;
}

.gem-confirm__final {
    font-weight: 600;
}

/* Phone: a full-screen sheet, its buttons stacked full width at the bottom. */
@media (max-width: 767px) {
    .adm-modal.gem-confirm {
        padding: 0;
    }

    .gem-confirm .adm-modal__panel {
        max-width: none;
        height: 100%;
        max-height: none;
        border: 0;
        border-radius: 0;
    }

    .gem-confirm__fact {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .gem-confirm .adm-modal__actions {
        flex-direction: column;
        margin-top: auto;
    }

    .gem-confirm .adm-modal__actions > * {
        width: 100%;
    }

    /* A toast from the save that opened the sheet would sit on its buttons: the sheet covers the page it speaks for. */
    .adm-modal.gem-confirm ~ .adm-toast {
        display: none;
    }
}

/* --- While sending (WF-104's top) --- */
.gem-progress {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-width: 44rem;
    margin-top: var(--space-xs);
}

.gem-progress__line {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.gem-progress__bar {
    width: 100%;
    height: 8px;
    accent-color: var(--accent);
}

/* --- The record (WF-104) --- */
.gem-rec {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    max-width: 56rem;
}

/* Six counts in a row; two columns on a phone (NWS-R43). */
.gem-rec__counts {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--space-sm);
    margin: 0;
}

.gem-rec__count {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-hairline);
    border-radius: var(--radius-container);
}

.gem-rec__count dt {
    color: var(--text-secondary);
    font-size: var(--font-size--1);
}

.gem-rec__count dd {
    margin: 0;
    font-family: var(--font-numeric);
    font-size: var(--font-size-1);
    font-weight: 600;
}

.gem-rec__facts {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin: 0;
}

.gem-rec__fact {
    display: grid;
    grid-template-columns: 9ch minmax(0, 1fr);
    gap: var(--space-sm);
}

.gem-rec__fact dt {
    color: var(--text-secondary);
}

.gem-rec__fact dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.gem-rec__lines {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gem-rec__section {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.gem-rec__head {
    margin: 0;
    font-size: var(--font-size-0);
}

.gem-rec__note {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-size--1);
}

.gem-rec__find {
    max-width: 24rem;
}

.gem-rec-table {
    width: 100%;
    border-collapse: collapse;
}

.gem-rec-table th,
.gem-rec-table td {
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid var(--border-hairline);
    text-align: left;
    vertical-align: top;
}

.gem-rec-table th {
    color: var(--text-secondary);
    font-size: var(--font-size--1);
    font-weight: 600;
}

.gem-rec-table__email,
.gem-rec-table__reason {
    overflow-wrap: anywhere;
}

@media (max-width: 767px) {
    .gem-rec__counts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .gem-rec__fact {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    /* Each recipient a card: the address, then its state and when. */
    .gem-rec-table thead {
        display: none;
    }

    .gem-rec-table,
    .gem-rec-table tbody,
    .gem-rec-table tr,
    .gem-rec-table td {
        display: block;
        width: 100%;
    }

    .gem-rec-table tr {
        padding: var(--space-sm) 0;
        border-bottom: 1px solid var(--border-hairline);
    }

    .gem-rec-table td {
        padding: 0;
        border: 0;
    }

    .gem-rec-table td.gem-rec-table__state,
    .gem-rec-table td.gem-rec-table__when {
        display: inline;
        width: auto;
        color: var(--text-secondary);
        font-size: var(--font-size--1);
    }

    .gem-rec-table td.gem-rec-table__state::after {
        content: " · ";
    }
}
