:root {
    color-scheme: light;

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    --background: #f2f1ee;
    --surface: #ffffff;
    --surface-muted: #f7f6f3;
    --text: #1d1d1b;
    --text-muted: #676762;
    --border: #d9d7d0;
    --accent: #c51b33;
    --accent-hover: #a81228;

    --available-background: #e6f5eb;
    --available-text: #176433;

    --paused-background: #fff2ce;
    --paused-text: #755200;

    --busy-background: #e7eefb;
    --busy-text: #254f91;

    --offline-background: #f0f0ef;
    --offline-text: #575752;

    --success-background: #eaf6ee;
    --success-text: #21683a;

    --error-background: #fdecee;
    --error-text: #9d1e31;

    --shadow: 0 24px 70px rgb(30 27 22 / 12%);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;

    background:
        radial-gradient(
            circle at top left,
            rgb(197 27 51 / 9%),
            transparent 34rem
        ),
        var(--background);

    color: var(--text);
}

button,
input {
    font: inherit;
}

button {
    touch-action: manipulation;
}

.page-shell {
    width: min(100% - 2rem, 44rem);
    min-height: 100vh;
    margin: 0 auto;
    padding: 3rem 0 2rem;

    display: flex;
    flex-direction: column;
    justify-content: center;
}

.portal-card {
    overflow: hidden;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: var(--shadow);
}

.portal-header {
    display: flex;
    align-items: center;
    gap: 1rem;

    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 3.25rem;
    height: 3.25rem;

    display: grid;
    place-items: center;
    flex: 0 0 auto;

    border-radius: 0.75rem;
    background: var(--accent);
    color: white;

    font-weight: 800;
    letter-spacing: -0.04em;
}

.eyebrow,
.panel-eyebrow {
    margin: 0 0 0.15rem;

    color: var(--text-muted);

    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(1.4rem, 4vw, 1.8rem);
}

h2 {
    margin-bottom: 0.35rem;
    font-size: 1.45rem;
}

h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.view {
    padding: 1.75rem;
}

.section-heading {
    margin-bottom: 1.5rem;
}

.section-heading p {
    margin-bottom: 0;
    color: var(--text-muted);
    line-height: 1.55;
}

.dashboard-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.dashboard-heading .section-heading {
    margin-bottom: 1.25rem;
}

form {
    display: grid;
    gap: 0.65rem;
}

label {
    margin-top: 0.4rem;

    font-size: 0.9rem;
    font-weight: 700;
}

input {
    width: 100%;
    padding: 0.85rem 0.95rem;

    border: 1px solid var(--border);
    border-radius: 0.65rem;

    background: white;
    color: var(--text);
    outline: none;
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(197 27 51 / 14%);
}

button {
    min-height: 2.9rem;
    padding: 0.75rem 1rem;

    border: 1px solid transparent;
    border-radius: 0.65rem;

    cursor: pointer;
    font-weight: 750;
}

button:focus-visible {
    outline: 3px solid rgb(197 27 51 / 25%);
    outline-offset: 2px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.primary-button {
    margin-top: 1rem;

    background: var(--accent);
    color: white;
}

.primary-button:hover:not(:disabled) {
    background: var(--accent-hover);
}

.secondary-button {
    width: 100%;
    margin-top: 1.5rem;

    border-color: var(--border);
    background: white;
    color: var(--text);
}

.secondary-button:hover:not(:disabled) {
    background: var(--surface-muted);
}

.icon-button {
    width: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0;

    display: grid;
    place-items: center;

    border-color: var(--border);
    background: white;
    color: var(--text);

    font-size: 1.35rem;
    line-height: 1;
}

.icon-button:hover:not(:disabled) {
    background: var(--surface-muted);
}

.status-message {
    margin: 1rem 1.75rem 0;
    padding: 0.8rem 0.95rem;

    border-radius: 0.65rem;
    line-height: 1.4;
}

.status-message.success {
    background: var(--success-background);
    color: var(--success-text);
}

.status-message.error {
    background: var(--error-background);
    color: var(--error-text);
}

.loading-view {
    min-height: 13rem;

    display: grid;
    place-items: center;
    align-content: center;
    gap: 1rem;

    color: var(--text-muted);
}

.spinner {
    width: 2rem;
    height: 2rem;

    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;

    animation: rotate 0.8s linear infinite;
}

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

.welcome-line {
    margin-bottom: 0.15rem !important;
    font-size: 0.9rem;
}

.user-details,
.agent-details {
    display: grid;
    gap: 0;

    margin: 0;

    border: 1px solid var(--border);
    border-radius: 0.75rem;

    overflow: hidden;
}

.user-details div,
.agent-details div {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 1rem;

    padding: 0.85rem 1rem;
    background: var(--surface-muted);
}

.user-details div + div,
.agent-details div + div {
    border-top: 1px solid var(--border);
}

.user-details dt,
.agent-details dt {
    color: var(--text-muted);

    font-size: 0.85rem;
    font-weight: 700;
}

.user-details dd,
.agent-details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.agent-panel {
    margin-top: 1.5rem;
    padding: 1.25rem;

    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: #fbfbfa;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;

    margin-bottom: 1rem;
}

.panel-heading h3 {
    margin-bottom: 0;
}

.agent-state-badge {
    padding: 0.48rem 0.75rem;

    border-radius: 999px;

    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.agent-state-badge.available {
    background: var(--available-background);
    color: var(--available-text);
}

.agent-state-badge.paused {
    background: var(--paused-background);
    color: var(--paused-text);
}

.agent-state-badge.in_call,
.agent-state-badge.inuse,
.agent-state-badge.ringing {
    background: var(--busy-background);
    color: var(--busy-text);
}

.agent-state-badge.unavailable,
.agent-state-badge.logged_out,
.agent-state-badge.unknown {
    background: var(--offline-background);
    color: var(--offline-text);
}

.agent-controls {
    margin-top: 1.25rem;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.control-button {
    min-height: 3.2rem;

    border-color: var(--border);
    background: white;
    color: var(--text);
}

.control-button:hover:not(:disabled) {
    border-color: #bdbab1;
    background: var(--surface-muted);
}

.control-login {
    background: var(--available-background);
    color: var(--available-text);
}

.control-logout {
    background: var(--error-background);
    color: var(--error-text);
}

.control-resume {
    grid-column: 1 / -1;

    background: var(--available-background);
    color: var(--available-text);
}

.control-hint {
    min-height: 2.6rem;
    margin: 0.85rem 0 0;

    color: var(--text-muted);

    font-size: 0.86rem;
    line-height: 1.45;
}

.last-updated {
    margin: 1rem 0 0;

    color: var(--text-muted);

    font-size: 0.78rem;
    text-align: right;
}

.roles-section {
    margin-top: 1.5rem;
}

.roles-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.role-badge {
    padding: 0.4rem 0.65rem;

    border-radius: 999px;
    background: #eceaf7;
    color: #494071;

    font-size: 0.82rem;
    font-weight: 750;
}

footer {
    padding: 1.25rem 0;

    color: var(--text-muted);

    font-size: 0.78rem;
    text-align: center;
}

[hidden] {
    display: none !important;
}

@media (max-width: 38rem) {
    .page-shell {
        width: min(100% - 1rem, 44rem);
        padding: 0.5rem 0;

        justify-content: flex-start;
    }

    .portal-card {
        border-radius: 0.9rem;
    }

    .portal-header,
    .view {
        padding: 1.25rem;
    }

    .status-message {
        margin-inline: 1.25rem;
    }

    .dashboard-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .agent-state-badge {
        align-self: flex-start;
    }

    .user-details div,
    .agent-details div {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .control-grid {
        grid-template-columns: 1fr;
    }

    .control-resume {
        grid-column: auto;
    }
}

/* M6.7a-Demo: sichtbare Agentenstatuskarte */

.agent-state-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 0 0 1.25rem;
    padding: 1.15rem;
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    background: var(--surface-muted);
}

.agent-state-hero-icon {
    display: grid;
    flex: 0 0 3.4rem;
    width: 3.4rem;
    height: 3.4rem;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    font-size: 1.7rem;
    font-weight: 800;
}

.agent-state-hero-copy {
    min-width: 0;
}

.agent-state-hero-eyebrow {
    margin: 0 0 0.15rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.agent-state-hero-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
}

.agent-state-hero-detail {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    line-height: 1.45;
}

.agent-state-hero.ready {
    border-color: #8ec39e;
    background: var(--available-background);
    color: var(--available-text);
}

.agent-state-hero.paused {
    border-color: #d8bd64;
    background: var(--paused-background);
    color: var(--paused-text);
}

.agent-state-hero.busy {
    border-color: #d99797;
    background: var(--busy-background);
    color: var(--busy-text);
}

.agent-state-hero.ringing,
.agent-state-hero.warning {
    border-color: #d4af55;
    background: #fff4d6;
    color: #704c00;
}

.agent-state-hero.offline,
.agent-state-hero.unknown {
    border-color: var(--border);
    background: var(--offline-background);
    color: var(--offline-text);
}

@media (max-width: 560px) {
    .agent-state-hero {
        align-items: flex-start;
    }

    .agent-state-hero-icon {
        flex-basis: 2.8rem;
        width: 2.8rem;
        height: 2.8rem;
        font-size: 1.35rem;
    }
}
