/* =============================================
   The Reports & Communication Center
   (admin/reports/, communications.py): its
   views' toggle; Sent Emails' filters, chips
   and table; an email's page and its preview;
   Email Types' templates, and an email type's
   preview. Then Daily Summary:
   the missed dates, the last report, Manual
   Send and its preview of the emails, the
   log's status, trigger and counts, and its
   details pop-up. Stat tiles, callouts and the
   pager are components.css's.
   ============================================= */

/* Phones: the three views share the width, each label wrapping if it must */
@media (max-width: 767.98px) {
    .report-views .segmented__btn {
        padding: 6px 8px;
        white-space: normal;
        text-align: center;
    }
}

/* ----- Sent Emails: a search, then a type, status and period, each
   showing at once ----- */
.report-filters {
    justify-content: flex-start;
    margin: 0;
}

.report-filters__search {
    flex: 1 1 240px;
    max-width: 380px;
}

.report-filters__select {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--in-border-input);
    border-radius: 6px;
    background-color: var(--in-surface);
    color: var(--in-text);
    font-size: 0.82rem;
    cursor: pointer;
}

.report-filters__select:focus {
    border-color: var(--in-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--in-focus);
}

/* What a link filtered by (an address, login, company, facility or run),
   each with its x to clear it */
.report-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--in-border-soft);
}

.report-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border: 1px solid var(--in-border);
    border-radius: 999px;
    background-color: var(--in-accent-wash);
    color: var(--in-accent);
    font-size: 0.78rem;
    font-weight: 600;
}

.report-chip:hover,
.report-chip:focus {
    border-color: var(--in-accent);
    color: var(--in-accent-hover);
    text-decoration: none;
}

.report-sent__to {
    max-width: 260px;
    overflow-wrap: anywhere;
}

/* A failed email, in the table and on its page */
.report-failed {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background-color: var(--in-danger-wash);
    color: var(--in-danger);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: 1px;
    white-space: nowrap;
}

.page-hero__tag.report-failed {
    margin-left: 0;
    font-size: 0.72rem;
}

/* A template's path, or SES's message id */
.report-template {
    display: inline-block;
    padding: 0 5px;
    border-radius: 4px;
    background-color: var(--in-wash);
    color: var(--in-text-2);
    font-size: 0.76rem;
    overflow-wrap: anywhere;
}

.report-types .report-template {
    margin: 0 4px 3px 0;
}

/* Email Types: its templates were updated since the last one went */
.report-updated {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    background-color: var(--in-amber-wash);
    color: var(--in-amber-text);
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ----- An email's page: what the log has, then the email rebuilt, in a
   frame as tall as it is, or its text ----- */
.report-email__fields {
    max-width: 860px;
}

.report-email__fields .record-fields__row {
    grid-template-columns: 110px minmax(0, 1fr);
}

/* An email type's preview: its versions, wrapping on a narrow screen */
.report-versions {
    flex-wrap: wrap;
}

.report-email__frame {
    display: block;
    width: 100%;
    height: 1400px;
    border: 0;
    background-color: #f1f2f0;
}

.report-email__text {
    margin: 0;
    padding: 16px;
    background-color: var(--in-sheet);
    color: var(--in-text);
    font-size: 0.82rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.report-hint {
    color: var(--in-text-muted);
    font-size: 0.8rem;
}

/* A weekday without a report: pick it to fill in Manual Send */
.report-missed-date {
    padding: 2px 10px;
    border: 1px solid var(--in-amber-border);
    border-radius: 999px;
    background-color: var(--in-surface);
    color: var(--in-accent);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.report-missed-date:hover,
.report-missed-date:focus {
    border-color: var(--in-accent);
    outline: none;
    background-color: var(--in-accent-wash);
}

/* ----- Last Report, Last Successful ----- */
.report-summary {
    color: var(--in-text);
    font-size: 0.9rem;
}

.report-summary__line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
}

.report-summary__sub {
    display: block;
    margin-top: 4px;
    color: var(--in-text-muted);
    font-size: 0.82rem;
}

.report-summary__none {
    color: var(--in-text-faint);
    font-style: italic;
}

/* ----- Manual Send: the date, the range it covers, and Send ----- */
.report-send {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
}

.report-send__date {
    flex: 0 1 220px;
}

.report-send__preview {
    margin: 0;
    padding-bottom: 10px;
    color: var(--in-text-muted);
    font-size: 0.85rem;
}

.report-send__range {
    color: var(--in-accent);
    font-weight: 600;
}

.report-send__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Preview Emails: a login who wouldn't get one, and why */
.report-dry-run__skipped td {
    color: var(--in-text-muted);
}

.report-send__sending {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    color: var(--in-text-muted);
    font-size: 0.86rem;
}

.report-send__sending[hidden] {
    display: none;
}

/* How the send went */
.report-result {
    margin-top: 16px;
    padding: 12px 16px;
    border: 1px solid var(--in-border-soft);
    border-radius: 8px;
    background-color: var(--in-sheet);
    color: var(--in-text-muted);
    font-size: 0.88rem;
}

.report-result--success {
    border-color: var(--in-complete);
    background-color: var(--in-complete-wash);
    color: var(--in-complete-text);
}

.report-result--error {
    border-color: var(--in-danger-border);
    background-color: var(--in-danger-wash);
    color: var(--in-danger);
}

.report-result__detail {
    font-size: 0.82rem;
}

/* ----- The log: a status dot, how the report was sent, its counts ----- */
.report-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.report-dot {
    display: inline-block;
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--in-idle);
}

.report-dot--success {
    background-color: var(--in-complete);
}

.report-dot--failed {
    background-color: var(--in-danger-border);
}

.report-dot--no_activity {
    background-color: var(--in-text-placeholder);
}

.report-dot--partial {
    background-color: var(--in-amber);
}

.report-trigger {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    background-color: var(--in-accent-wash);
    color: var(--in-accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.report-trigger--manual {
    background-color: var(--in-wash);
    color: var(--in-text-muted);
}

.report-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.report-metric {
    padding: 1px 8px;
    border-radius: 999px;
    background-color: var(--in-wash);
    color: var(--in-text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.report-metric.is-set {
    background-color: var(--in-accent-wash);
    color: var(--in-accent);
}

.report-error {
    margin: 0;
    color: var(--in-danger);
    font-size: 0.82rem;
}

/* ----- A report's details, in the pop-up ----- */
.report-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.report-detail {
    min-width: 0;
    padding: 10px 12px;
    border-radius: 8px;
    background-color: var(--in-sheet);
}

.report-detail--wide {
    grid-column: 1 / -1;
}

.report-detail--error {
    background-color: var(--in-danger-wash);
}

.report-detail__label {
    margin-bottom: 4px;
    color: var(--in-text-faint);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.report-detail__value {
    color: var(--in-text);
    font-size: 0.92rem;
    font-weight: 600;
}

.report-detail__value--error {
    color: var(--in-danger);
    font-size: 0.82rem;
    font-weight: 400;
    word-break: break-word;
}

.report-detail__sub {
    display: block;
    margin-top: 2px;
    color: var(--in-text-muted);
    font-size: 0.78rem;
    font-weight: 400;
}

.report-recipients {
    margin: 2px 0 0;
    padding: 0;
    font-size: 0.82rem;
    font-weight: 400;
    list-style: none;
}

.report-recipients li {
    padding: 2px 0;
}

.report-recipient-tag {
    display: inline-block;
    margin-right: 6px;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.report-recipient-tag--admin {
    background-color: var(--in-amber-wash);
    color: var(--in-amber-text);
}

.report-recipient-tag--installer {
    background-color: var(--in-accent-wash);
    color: var(--in-accent);
}

@media (max-width: 767.98px) {
    .report-send__date {
        flex-basis: 100%;
    }

    .report-send__actions {
        flex: 1 1 100%;
    }

    .report-send .portal-btn {
        flex: 1 1 100%;
    }

    .report-filters__search {
        flex-basis: 100%;
        max-width: none;
    }

    .report-filters__select {
        flex: 1 1 140px;
    }

    .report-sent__to {
        max-width: none;
    }

    .report-details {
        grid-template-columns: minmax(0, 1fr);
    }
}
