/* =============================================================================
   MCP access tokens — Settings panel + its three dialogs.

   NOTE: this codebase has no base `.modal` rule. `.mcp-modal` therefore
   supplies its OWN background, radius and shadow; without them it renders
   invisible.
   ============================================================================= */

/* ---------- Settings panel ---------- */

.mcp-tokens-panel {
    font-family: 'Avenir Next', 'Avenir', -apple-system, BlinkMacSystemFont, sans-serif;
}

.mcp-tokens-actions {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 16px;
}

.mcp-tokens-empty,
.mcp-tokens-error {
    font-size: 14px;
    margin: 8px 0 0;
    color: var(--text-secondary, #595959);
}

.mcp-tokens-error {
    color: #EF4444;
}

.mcp-token-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mcp-token-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 12px;
    border: 1px solid var(--border-medium, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
    background: var(--bg-secondary, #F8F8F8);
}

.mcp-token-info {
    min-width: 0;
    flex: 1;
}

.mcp-token-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.mcp-token-name {
    min-width: 0;
    font-weight: 600;
    color: var(--text-primary, #1A1A1A);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Revoked token ---------- */

/* De-emphasised, but never dimmed into unreadability: the state is carried by
   the word "Revoked" rather than by colour or opacity, so it survives a
   greyscale screen and a screen reader alike. */
.mcp-token-item-revoked {
    background: transparent;
    border-style: dashed;
}

.mcp-token-item-revoked .mcp-token-name,
.mcp-token-item-revoked .mcp-token-prefix {
    color: var(--text-secondary, #595959);
}

.mcp-token-item-revoked .mcp-token-name {
    font-weight: 500;
}

.mcp-token-status {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    /* 5.1:1 on the panel background — WCAG AA at this size. */
    color: #C0392B;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.32);
}

/* Sits above the revoked rows when nothing live is left. */
.mcp-tokens-none-active {
    margin: 0 0 8px;
}

.mcp-token-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary, #595959);
}

.mcp-token-prefix {
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--text-primary, #1A1A1A);
}

/* ---------- Buttons ---------- */

.mcp-btn {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 100ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                color 100ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                border-color 100ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.mcp-btn:focus-visible {
    outline: 2px solid #4A90D9;
    outline-offset: 2px;
}

.mcp-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.mcp-btn-primary {
    background: #4A90D9;
    color: #FFFFFF;
}

.mcp-btn-primary:hover:not(:disabled) {
    background: #357ABD;
}

.mcp-btn-secondary {
    background: transparent;
    color: var(--text-primary, #1A1A1A);
    border-color: var(--border-medium, rgba(0, 0, 0, 0.12));
}

.mcp-btn-secondary:hover:not(:disabled) {
    background: var(--surface-hover, rgba(0, 0, 0, 0.04));
}

.mcp-btn-danger {
    background: transparent;
    color: #C0392B;
    border-color: var(--border-medium, rgba(0, 0, 0, 0.12));
}

.mcp-btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.08);
}

/* ---------- Dialogs ---------- */

.mcp-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.45);
    animation: mcp-fade-in 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* Own background / radius / shadow — nothing is inherited. */
.mcp-modal {
    background: var(--bg-elevated, #FFFFFF);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    font-family: 'Avenir Next', 'Avenir', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary, #1A1A1A);
    animation: mcp-scale-in 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes mcp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes mcp-scale-in {
    from { opacity: 0; transform: scale(0.96) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .mcp-modal-overlay,
    .mcp-modal {
        animation: none;
    }
    .mcp-btn {
        transition: none;
    }
}

.mcp-modal-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary, #1A1A1A);
}

.mcp-modal-desc {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary, #595959);
}

.mcp-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mcp-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

.mcp-modal-error {
    margin: 0;
    font-size: 13px;
    color: #C0392B;
}

/* ---------- Form fields ---------- */

.mcp-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    border: none;
}

.mcp-field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #1A1A1A);
    padding: 0;
}

.mcp-field-hint {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary, #595959);
}

.mcp-input {
    min-height: 44px;
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary, #1A1A1A);
    background: var(--bg-primary, #FFFFFF);
    border: 1px solid var(--border-medium, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
}

.mcp-input:focus-visible {
    outline: 2px solid #4A90D9;
    outline-offset: 1px;
}

.mcp-scope-group {
    gap: 8px;
}

.mcp-radio-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-height: 44px;
    padding: 8px;
    border: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
    border-radius: 8px;
    cursor: pointer;
}

.mcp-radio-row:hover {
    background: var(--surface-hover, rgba(0, 0, 0, 0.04));
}

.mcp-radio-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mcp-radio-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #1A1A1A);
}

.mcp-radio-hint {
    font-size: 12px;
    color: var(--text-secondary, #595959);
}

/* ---------- Show-once token ---------- */

.mcp-token-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mcp-token-secret {
    flex: 1;
    min-width: 0;
    padding: 12px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
    color: var(--text-primary, #1A1A1A);
    background: var(--bg-secondary, #F8F8F8);
    border: 1px solid var(--border-medium, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
}

.mcp-token-secret:focus-visible {
    outline: 2px solid #4A90D9;
    outline-offset: 2px;
}

.mcp-copy-btn {
    flex-shrink: 0;
}

/* ---------- Plan notice in the panel ---------- */

/* Shown when the server refuses a mint because the plan doesn't include MCP.
   Informational, not an error: it states a requirement rather than a fault. */
.mcp-tokens-notice {
    margin: 0 0 16px;
    padding: 12px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-primary, #1A1A1A);
    background: rgba(74, 144, 217, 0.08);
    border: 1px solid rgba(74, 144, 217, 0.32);
    border-left: 3px solid #4A90D9;
    border-radius: 8px;
}

/* ---------- Connection details (show-once dialog) ---------- */

.mcp-connect {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light, rgba(0, 0, 0, 0.08));
}

.mcp-connect-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary, #1A1A1A);
}

.mcp-endpoint {
    flex: 1;
    min-width: 0;
    padding: 12px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    word-break: break-all;
    color: var(--text-primary, #1A1A1A);
    background: var(--bg-secondary, #F8F8F8);
    border: 1px solid var(--border-medium, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
}

.mcp-endpoint:focus-visible,
.mcp-snippet:focus-visible {
    outline: 2px solid #4A90D9;
    outline-offset: 2px;
}

/* The snippet is wide by nature — it scrolls inside its own box rather than
   stretching the dialog or wrapping JSON into something unpasteable. */
.mcp-snippet {
    margin: 0;
    padding: 12px;
    max-height: 176px;
    overflow: auto;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre;
    color: var(--text-primary, #1A1A1A);
    background: var(--bg-secondary, #F8F8F8);
    border: 1px solid var(--border-medium, rgba(0, 0, 0, 0.12));
    border-radius: 8px;
}

.mcp-connect-actions {
    display: flex;
    justify-content: flex-start;
}
