/*
 * Matches the Amazon Connect agent workspace, which uses Cloudscape's visual refresh theme.
 * Values are the workspace's own design tokens (contact-handling stylesheet).
 */
:root {
    --font-family-base: "Open Sans", "Helvetica Neue", Roboto, Arial, sans-serif;
    --color-text-body-default: #0f141a;
    --color-text-body-secondary: #424650;
    --color-text-empty: #656871;
    --color-border-divider-default: #c6c6cd;
    --color-border-divider-secondary: #ebebf0;
    --color-background-container: #ffffff;
    --color-button-normal: #006ce0;
    --color-button-normal-hover: #002b66;
    --color-background-button-normal-hover: #f0fbff;
    --color-interactive-disabled: #b4b4bb;
    --color-status-error: #db0000;
    --color-status-warning: #855900;
    --color-status-info: #006ce0;
    --color-status-success: #00802f;
    --color-background-status-error: #fff5f5;
    --color-background-status-warning: #fffef0;
    --color-background-status-info: #f0fbff;
    --color-background-status-success: #effff1;
    --border-radius-alert: 12px;
    --color-background-page: #f4f6fa;
    --color-background-row-hover: #f6f9fd;
    --color-red-cross: #ed1b2e;
    --shadow-container: 0 0 1px 1px #e9ebed, 0 1px 8px 2px rgba(0, 7, 22, 0.12);
    --border-radius-container: 16px;
    --border-radius-button: 20px;
}

[hidden] { display: none !important; }

body {
    margin: 0;
    padding: 20px;
    font-family: var(--font-family-base);
    font-size: 14px;
    line-height: 20px;
    color: var(--color-text-body-default);
    /* A faint tint behind the white cards, so they stand out */
    background: var(--color-background-page);
}

h1 { font-size: 20px; line-height: 24px; font-weight: 700; margin: 0; }
h2 { font-size: 18px; line-height: 22px; font-weight: 700; margin: 0 0 12px; }

/* Line icons, drawn in the text colour */
.icon {
    width: 20px;
    height: 20px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Header: a gradient banner in the workspace's blues, with a Red Cross red stripe */
.hero {
    position: relative;
    overflow: hidden;
    padding: 24px;
    border-top: 4px solid var(--color-red-cross);
    border-radius: var(--border-radius-container);
    background:
        radial-gradient(circle at 85% -20%, rgba(255, 255, 255, 0.18), transparent 45%),
        linear-gradient(135deg, #0f141a 0%, #002b66 55%, #006ce0 100%);
    color: #ffffff;
    box-shadow: var(--shadow-container);
}

.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero-title { display: flex; align-items: center; gap: 14px; }
.hero h1 { font-size: 26px; line-height: 32px; letter-spacing: -0.01em; }
.hero-subtitle { margin: 2px 0 0; color: rgba(255, 255, 255, 0.78); }

.hero-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.hero-icon .icon { width: 26px; height: 26px; }

/* Counts as frosted tiles inside the banner */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 20px 0 0; }
.stat {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.stat .icon { grid-row: span 2; width: 22px; height: 22px; padding: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }
.stat dt { color: rgba(255, 255, 255, 0.78); font-size: 12px; line-height: 16px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.stat dd { margin: 0; font-size: 24px; line-height: 30px; font-weight: 700; }
.stat-inbound .icon { color: #b3f5c4; }
.stat-outbound .icon { color: #ffe9a8; }
.stat-missed .icon { color: #ffb3b9; }
.stat-voicemail .icon { color: #b8e1ff; }
.stat-updated .icon { color: #ffffff; }
.stat-updated dd { font-size: 18px; }

/* Refresh, in white for the dark banner; the icon spins while the list loads */
.button-inverted {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-color: rgba(255, 255, 255, 0.85);
    background: transparent;
    color: #ffffff;
}
.button-inverted:hover { border-color: #ffffff; background: #ffffff; color: #002b66; }
.button-inverted:focus-visible { outline-color: #ffffff; }
.button-inverted:disabled { border-color: rgba(255, 255, 255, 0.5); background: transparent; color: rgba(255, 255, 255, 0.7); }
.button-inverted .icon { width: 16px; height: 16px; }
.button-inverted:disabled .icon { animation: spin 0.9s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Normal button, like the workspace's Apps button */
button {
    padding: 4px 20px;
    border: 2px solid var(--color-button-normal);
    border-radius: var(--border-radius-button);
    background: var(--color-background-container);
    color: var(--color-button-normal);
    font-family: inherit;
    font-size: 14px;
    line-height: 20px;
    font-weight: 700;
    cursor: pointer;
}

button:hover {
    border-color: var(--color-button-normal-hover);
    background: var(--color-background-button-normal-hover);
    color: var(--color-button-normal-hover);
}

button:focus-visible {
    outline: 2px solid var(--color-button-normal);
    outline-offset: 2px;
}

button:disabled {
    border-color: var(--color-interactive-disabled);
    background: var(--color-background-container);
    color: var(--color-interactive-disabled);
    cursor: default;
}

#status { color: var(--color-text-body-secondary); margin: 12px 4px 0; }
#status:empty { display: none; }

.container {
    margin: 16px 0 0;
    padding: 16px 20px;
    border-radius: var(--border-radius-container);
    background: var(--color-background-container);
    box-shadow: var(--shadow-container);
    animation: rise 0.35s ease-out both;
}
.list-outbound { animation-delay: 0.05s; }
.list-missed { animation-delay: 0.1s; }
.list-voicemail { animation-delay: 0.15s; }

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* The app's tab can be narrow beside the softphone, so wide tables scroll inside their card */
.table-scroll { position: relative; overflow-x: auto; }

/* Section titles with an icon and a count */
.list h2 { display: flex; align-items: center; gap: 10px; }
.section-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; }
.section-icon .icon { width: 18px; height: 18px; }
.list-inbound .section-icon { background: var(--color-background-status-success); color: var(--color-status-success); }
.list-outbound .section-icon { background: var(--color-background-status-warning); color: var(--color-status-warning); }
.list-missed .section-icon { background: var(--color-background-status-error); color: var(--color-status-error); }
.list-voicemail .section-icon { background: var(--color-background-status-info); color: var(--color-status-info); }

.count-pill {
    min-width: 24px;
    padding: 0 8px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 22px;
    text-align: center;
}
.list-inbound .count-pill { background: var(--color-status-success); color: #ffffff; }
.list-outbound .count-pill { background: var(--color-status-warning); color: #ffffff; }
.list-missed .count-pill { background: var(--color-status-error); color: #ffffff; }
.list-voicemail .count-pill { background: var(--color-status-info); color: #ffffff; }
.list .count-pill.is-zero { background: var(--color-border-divider-secondary); color: var(--color-text-body-secondary); }

@media (prefers-reduced-motion: reduce) {
    .container, .button-inverted:disabled .icon { animation: none; }
}

table { width: 100%; border-collapse: collapse; }

th, td {
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--color-border-divider-secondary);
}

th {
    color: var(--color-text-body-secondary);
    font-weight: 700;
    border-bottom-color: var(--color-border-divider-default);
    white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:not(.player):hover td { background: var(--color-background-row-hover); }

/* Nothing in the list: a green check, so an empty list reads as good news */
td.empty { padding: 20px 12px; color: var(--color-text-empty); text-align: center; }
td.empty::before {
    content: "\2713";
    display: block;
    width: 28px;
    height: 28px;
    margin: 0 auto 6px;
    border-radius: 50%;
    background: var(--color-background-status-success);
    color: var(--color-status-success);
    font-weight: 700;
    line-height: 28px;
}
tbody tr:hover td.empty { background: none; }

/* Call back progress */
.callback h2 { margin: 0; }

.steps {
    display: flex;
    margin: 20px 0 12px;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.steps li {
    position: relative;
    flex: 1;
    padding-top: 32px;
    text-align: center;
    color: var(--color-text-empty);
    font-weight: 700;
    counter-increment: step;
}

/* Line to the previous step */
.steps li + li::after {
    content: "";
    position: absolute;
    top: 11px;
    right: calc(50% + 16px);
    left: calc(-50% + 16px);
    height: 2px;
    background: var(--color-border-divider-default);
}
.steps li.done::after, .steps li.current::after, .steps li.failed::after { background: var(--color-status-info); }

/* Step marker: number, check, or cross */
.steps li::before {
    content: counter(step);
    position: absolute;
    top: 0;
    left: calc(50% - 12px);
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border-divider-default);
    border-radius: 50%;
    background: var(--color-background-container);
    color: var(--color-text-empty);
    font-size: 12px;
    line-height: 20px;
}
.steps li.done { color: var(--color-text-body-default); }
.steps li.done::before {
    content: "\2713";
    border-color: var(--color-status-info);
    background: var(--color-status-info);
    color: var(--color-background-container);
}
.steps li.current { color: var(--color-status-info); }
.steps li.current::before {
    border-color: var(--color-status-info);
    color: var(--color-status-info);
    animation: step-pulse 1.5s ease-in-out infinite;
}
.steps li.failed { color: var(--color-status-error); }
.steps li.failed::before {
    content: "\2715";
    border-color: var(--color-status-error);
    background: var(--color-status-error);
    color: var(--color-background-container);
}

/* Narrow tabs: smaller labels that can wrap, so all four steps fit */
@media (max-width: 420px) {
    .steps li { min-width: 0; padding: 32px 2px 0; font-size: 12px; line-height: 16px; overflow-wrap: anywhere; }
}

@keyframes step-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 108, 224, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(0, 108, 224, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .steps li.current::before { animation: none; }
}

/* What's happening now, like the workspace's alerts: a tinted box with an icon, title and description */
.callout {
    --tone: var(--color-status-info);
    position: relative;
    padding: 12px 16px 12px 48px;
    border: 2px solid var(--tone);
    border-radius: var(--border-radius-alert);
    background: var(--tone-background, var(--color-background-status-info));
}
.callout::before {
    position: absolute;
    top: 12px;
    left: 14px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--tone);
    color: var(--color-background-container);
    font-size: 14px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}
.callout strong { display: block; color: var(--tone); font-size: 16px; line-height: 22px; }
.callout p { margin: 2px 0 0; color: var(--color-text-body-default); }

.callout-info { --tone: var(--color-status-info); --tone-background: var(--color-background-status-info); }
.callout-info::before { content: "i"; font-family: Georgia, serif; font-style: italic; }
.callout-warning { --tone: var(--color-status-warning); --tone-background: var(--color-background-status-warning); }
.callout-warning::before { content: "!"; }
.callout-success { --tone: var(--color-status-success); --tone-background: var(--color-background-status-success); }
.callout-success::before { content: "\2713"; }
.callout-error { --tone: var(--color-status-error); --tone-background: var(--color-background-status-error); }
.callout-error::before { content: "\2715"; }

/* The step the agent has to act on draws the eye */
.callout-warning { animation: callout-attention 1.2s ease-in-out 3; }
@keyframes callout-attention {
    0%, 100% { box-shadow: 0 0 0 0 rgba(133, 89, 0, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(133, 89, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .callout-warning { animation: none; }
}

/* The greeting the customer is hearing, like a quoted prompt */
.callback-greeting {
    margin: 12px 0 0;
    padding: 8px 12px;
    border-left: 4px solid var(--color-status-info);
    border-radius: 0 8px 8px 0;
    background: var(--color-background-button-normal-hover);
}
.callback-greeting figcaption { color: var(--color-status-info); font-size: 12px; line-height: 16px; font-weight: 700; }
.callback-greeting blockquote { margin: 4px 0 0; font-style: italic; }
.callback-greeting blockquote::before { content: "\201C"; }
.callback-greeting blockquote::after { content: "\201D"; }

/* Row actions: smaller normal buttons, kept on one line at the end of the row */
td.actions { text-align: right; white-space: nowrap; padding-top: 6px; padding-bottom: 6px; }
td.actions button { padding: 0 12px; }
td.actions button + button { margin-left: 8px; }

/* Voicemail player, shown under its row */
tr.player td { padding-top: 0; }
tr.player audio { display: block; width: 100%; height: 40px; }
tbody tr:has(+ tr.player) td { border-bottom: none; }

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

/* Status indicators */
td.status { font-weight: 700; white-space: nowrap; }
td:nth-child(1), td:nth-child(3) { white-space: nowrap; }
td.status::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border-radius: 50%;
    background: currentColor;
    vertical-align: 1px;
}
td.status-inbound { color: var(--color-status-success); }
td.status-outbound { color: var(--color-status-info); }
td.status-missed { color: var(--color-status-warning); }
td.status-rejected { color: var(--color-status-error); }
td.status-voicemail { color: var(--color-status-info); }
