/*
 * Styles of the application.
 *
 * The colours, fonts, the reset & the light / dark mode come from the
 * corporate design theme (https://assets.confirm.ch/theme.css), so only its
 * --theme-* tokens are used here (never hard-coded colours).
 */

/* Layout */

body {
    display: flex;
    flex-direction: column;
}

.main {
    flex: 1;
    width: 100%;
    max-width: var(--theme-content-width);
    margin: 0 auto;
    padding: var(--theme-space-2xl) var(--theme-space);
}

.muted {
    color: var(--theme-text-muted);
}

.ui-icon {
    width: 1.2em;
    height: 1.2em;
    flex-shrink: 0;
    fill: currentcolor;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--theme-space-sm);
    padding: var(--theme-space-sm) var(--theme-space-lg);
    border-radius: var(--theme-radius);
    background: var(--theme-primary);
    color: var(--theme-primary-contrast);
    font-weight: var(--theme-font-weight-medium);
    text-decoration: none;
    transition: background var(--theme-transition);
}

.btn:hover {
    background: var(--theme-primary-hover);
    color: var(--theme-primary-contrast);
}

.header-button {
    display: inline-flex;
    align-items: center;
    gap: var(--theme-space-xs);
    padding: var(--theme-space-sm);
    border: none;
    border-radius: var(--theme-radius);
    background: none;
    color: var(--theme-text-muted);
    cursor: pointer;
    transition: color var(--theme-transition), background var(--theme-transition);
}

.header-button:hover {
    background: var(--theme-surface);
    color: var(--theme-text);
}

/* Header */

.header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--theme-space);
    padding: var(--theme-space) var(--theme-space-xl);
    border-bottom: 1px solid var(--theme-border);
    background: var(--theme-surface);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--theme-space-sm);
    color: var(--theme-text);
    font-size: var(--theme-font-size-lg);
    font-weight: var(--theme-font-weight-semibold);
    text-decoration: none;
}

.header-brand:hover {
    color: var(--theme-text);
}

.header-logo {
    width: 2rem;
    height: 2rem;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--theme-space-sm);
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: var(--theme-space-xs);
    color: var(--theme-text);
    text-decoration: none;
}

.header-divider {
    width: 1px;
    height: 1.5rem;
    background: var(--theme-border);
}

/* Theme toggle: the icon of the current theme is shown. */

.theme-icon {
    display: none;
}

:root[data-theme="auto"] .theme-icon-auto,
:root[data-theme="light"] .theme-icon-light,
:root[data-theme="dark"] .theme-icon-dark {
    display: contents;
}

/* User (with the Gravatar of the email address) */

.user {
    display: inline-flex;
    align-items: center;
    gap: var(--theme-space-sm);
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: var(--theme-radius-round);
    border: 2px solid var(--theme-primary);
}

/* Toasts (flashed messages) */

.toast-container {
    display: flex;
    flex-direction: column;
    gap: var(--theme-space-sm);
    max-width: var(--theme-content-width);
    margin: var(--theme-space) auto 0;
    padding: 0 var(--theme-space);
    width: 100%;
}

.toast {
    padding: var(--theme-space-sm) var(--theme-space);
    border-radius: var(--theme-radius);
    background: var(--theme-info-subtle);
    color: var(--theme-text);
}

.toast.success {
    background: var(--theme-success-subtle);
}

.toast.error {
    background: var(--theme-error-subtle);
}

/* Pages */

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--theme-space);
    padding: var(--theme-space-2xl) 0;
    text-align: center;
}

.hero h1 {
    font-size: calc(var(--theme-font-size-3xl) * 1.5);
}

.hero strong {
    color: var(--theme-primary-text);
}

.actions {
    display: flex;
    gap: var(--theme-space);
    margin-top: var(--theme-space);
}

.card {
    display: flex;
    gap: var(--theme-space-xl);
    align-items: flex-start;
    max-width: 48rem;
    margin: 0 auto;
    padding: var(--theme-space-xl);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-lg);
    background: var(--theme-surface);
    box-shadow: var(--theme-shadow);
}

.card-avatar {
    width: 5rem;
    height: 5rem;
    border-radius: var(--theme-radius-round);
    border: 3px solid var(--theme-primary);
}

.details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--theme-space-xs) var(--theme-space-lg);
}

.details dt {
    color: var(--theme-text-muted);
}

/* Dialogs (e.g. how to connect an AI agent via MCP) */

.dialog {
    width: min(48rem, calc(100% - 2rem));
    margin: auto;
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-lg);
    background: var(--theme-surface);
    box-shadow: var(--theme-shadow);
    color: var(--theme-text);
}

.dialog::backdrop {
    background: color-mix(in srgb, var(--theme-background) 70%, transparent);
}

.dialog-body {
    padding: var(--theme-space-lg);
}

.dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--theme-space-sm);
}

.dialog-head h2 {
    display: flex;
    align-items: center;
    gap: var(--theme-space-sm);
    font-size: var(--theme-font-size-lg);
}

.dialog-close,
.code-copy {
    flex: none;
    border: none;
    background: none;
    color: var(--theme-text-muted);
    cursor: pointer;
    transition: color var(--theme-transition);
}

.dialog-close:hover,
.code-copy:hover {
    color: var(--theme-text);
}

.code-copy.copied {
    color: var(--theme-success-text);
}

.dialog h3 {
    margin: var(--theme-space-lg) 0 var(--theme-space-sm);
    color: var(--theme-text-muted);
    font-size: var(--theme-font-size-sm);
    font-weight: var(--theme-font-weight-medium);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dialog p {
    margin-bottom: var(--theme-space-sm);
}

.code {
    display: flex;
    align-items: center;
    gap: var(--theme-space-sm);
    padding: var(--theme-space-sm) var(--theme-space);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    background: var(--theme-background);
}

.code code {
    flex: 1;
    overflow-x: auto;
    padding: 0;
    background: none;
    white-space: nowrap;
}

.dialog-notes dt {
    font-weight: var(--theme-font-weight-medium);
}

.dialog-notes dd {
    color: var(--theme-text-muted);
}

/* A tool: its name with a chevron (which turns when it's collapsed), and its description. */
.dialog-tools summary {
    display: flex;
    align-items: center;
    gap: var(--theme-space-xs);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.dialog-tools summary::-webkit-details-marker {
    display: none;
}

.dialog-tools summary .ui-icon {
    transition: transform var(--theme-transition);
}

.dialog-tools details:not([open]) summary .ui-icon {
    transform: rotate(-90deg);
}

.dialog-tools details p {
    margin: var(--theme-space-xs) 0 0;
    color: var(--theme-text-muted);
}

.dialog-tools details + details {
    margin-top: var(--theme-space-sm);
}

/* Footer: the logo matching the (effective) theme is shown. */

.footer {
    display: flex;
    align-items: center;
    gap: var(--theme-space-lg);
    padding: var(--theme-space-lg) var(--theme-space-xl);
    border-top: 1px solid var(--theme-border);
    background: var(--theme-surface);
    font-size: var(--theme-font-size-sm);
}

.footer-logo {
    height: 2rem;
    width: auto;
}

:root[data-theme="light"] .footer-logo-dark,
:root[data-theme="dark"] .footer-logo-light {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] .footer-logo-light {
        display: none;
    }
}

@media (prefers-color-scheme: light) {
    :root[data-theme="auto"] .footer-logo-dark {
        display: none;
    }
}

/* Small screens */

@media (width <= 640px) {
    .header {
        padding: var(--theme-space-sm) var(--theme-space);
    }

    .user-email,
    .header-button-label {
        display: none;
    }

    .card {
        flex-direction: column;
        align-items: center;
        padding: var(--theme-space-lg);
    }

    .footer {
        flex-direction: column;
        text-align: center;
    }
}
