/* ──────────────────────────────────────────
   Settings Panel — light theme, matches FlowPicker
   ────────────────────────────────────────── */
.settings-panel {
    width: min(880px, 92vw);
    max-height: 82vh;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
    animation: panel-enter 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.settings-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.settings-header .button-link {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85em;
    color: var(--color-text-secondary);
}

.settings-header .button-link:hover {
    background: #f0f2f7;
    color: var(--color-primary);
}

.settings-body {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 1.25rem;
    overflow: hidden;
    min-height: 360px;
}

.settings-rail {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-right: 1rem;
    border-right: 1px solid var(--border-color);
}

.settings-rail-item {
    position: relative;
    appearance: none;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.settings-rail-item:hover {
    background: #f0f4ff;
    color: var(--color-text);
}

.settings-rail-item.is-active {
    background: #eaf0ff;
    color: var(--color-primary);
    border-color: rgba(42, 109, 244, 0.18);
    font-weight: 600;
}

.settings-rail-item.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    bottom: 7px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--color-primary);
}

/* Back button — chevron + label */
.settings-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 4px 10px 4px 8px !important;
}

.settings-back svg {
    flex-shrink: 0;
    opacity: 0.85;
    transition: transform 0.18s ease, opacity 0.12s ease;
}

.settings-back:hover svg {
    opacity: 1;
    transform: translateX(-2px);
}

.settings-content {
    overflow-y: auto;
    min-width: 0;
}

/* ──────────────────────────────────────────
   Credentials section
   ────────────────────────────────────────── */
.credentials-section h4 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.credentials-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.credentials-header .button-primary {
    padding: 7px 14px;
    font-size: 0.8rem;
    font-weight: 600;
}

.credentials-section [data-role="list"] {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 60px;
}

.credentials-section [data-role="list"] > .muted,
.credentials-section [data-role="list"] > .error-text {
    display: block;
    padding: 1.25rem 0;
    text-align: center;
    font-size: 0.85rem;
}

.credential-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.75rem;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: background 0.12s ease, border-color 0.12s ease;
    animation: panel-enter 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.credential-row > div:first-of-type {
    min-width: 0;
}

.credential-row:hover {
    background: #f0f4ff;
    border-color: rgba(42, 109, 244, 0.15);
}

.credential-mode-badge {
    display: inline-block;
    font-family: 'IBM Plex Mono', 'Courier New', monospace;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 4px;
    vertical-align: 2px;
    margin-left: 6px;
}

/* Demo = paper money: blue. Live = real money: orange.
 * Green / red are reserved for OK / Fail test badges so the row's
 * mode tint is never confused with its test status. */
.credential-mode-badge.is-demo {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}

.credential-mode-badge.is-live {
    background: rgba(234, 88, 12, 0.12);
    color: #9a3412;
}

.credential-row[data-mode="demo"] {
    border-left: 3px solid rgba(37, 99, 235, 0.5);
    background: rgba(37, 99, 235, 0.025);
}

.credential-row[data-mode="demo"]:hover {
    background: rgba(37, 99, 235, 0.06);
    border-color: rgba(37, 99, 235, 0.5);
}

.credential-row[data-mode="demo"] .service-monogram {
    border-left-color: #2563eb;
    border-left-width: 3px;
}

.credential-row[data-mode="live"] {
    border-left: 3px solid rgba(234, 88, 12, 0.45);
    background: rgba(234, 88, 12, 0.025);
}

.credential-row[data-mode="live"]:hover {
    background: rgba(234, 88, 12, 0.06);
    border-color: rgba(234, 88, 12, 0.45);
}

.credential-row[data-mode="live"] .service-monogram {
    border-left-color: #ea580c;
    border-left-width: 3px;
}

.credential-row strong {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
}

.credential-row .muted {
    color: var(--color-text-muted);
    font-size: 0.85em;
    font-weight: 400;
}

.credential-row .meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 2px;
    color: var(--color-text-muted);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.credential-row .meta > span:first-child {
    letter-spacing: 0.04em;
}

.credential-row .button-link {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    opacity: 0;
    transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.credential-row .button.icon-button {
    opacity: 0;
    transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.credential-row:hover .button-link,
.credential-row:hover .button.icon-button,
.credential-row:focus-within .button-link,
.credential-row:focus-within .button.icon-button,
.credential-row .button.icon-button:focus-visible {
    opacity: 1;
}

.credential-row .button-link:hover {
    background: rgba(42, 109, 244, 0.08);
}

.credential-row-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    flex-shrink: 0;
}

.delete-confirm-label {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-right: 4px;
    white-space: nowrap;
}

.button-danger {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    background: var(--color-danger);
    color: #fff;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.12s ease;
}

.button-danger:hover {
    opacity: 0.85;
}

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

/* ──────────────────────────────────────────
   Status badges — pill + leading dot
   ────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 2px 8px 2px 7px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid transparent;
    line-height: 1.4;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    background: currentColor;
}

.status-badge.ok {
    background: rgba(34, 197, 94, 0.10);
    color: #15803d;
    border-color: rgba(34, 197, 94, 0.20);
}

.status-badge.fail {
    background: var(--color-danger-muted);
    color: var(--color-danger);
    border-color: rgba(217, 48, 37, 0.22);
}

.status-badge.untested {
    background: #f0f2f7;
    color: var(--color-text-muted);
    border-color: var(--border-color);
}

/* Untested badges nudge — slow dot pulse */
.status-badge.untested::before {
    animation: badge-untested-pulse 2.4s ease-in-out infinite;
}

@keyframes badge-untested-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.32; }
}

/* ──────────────────────────────────────────
   Service monogram tile (shared with editor overlay picker)
   ────────────────────────────────────────── */
.service-monogram {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: #eef1f7;
    color: var(--color-primary);
    border: 1px solid rgba(42, 109, 244, 0.18);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    text-transform: uppercase;
    user-select: none;
}

.service-monogram[data-service="bybit"] {
    background: #fff1d9;
    color: #a05a00;
    border-color: rgba(160, 90, 0, 0.18);
}

/* ──────────────────────────────────────────
   Empty state — framed call-to-action
   ────────────────────────────────────────── */
.credentials-empty {
    margin-top: 0.5rem;
    padding: 1.5rem 1.5rem 1.6rem;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background:
        repeating-linear-gradient(
            -45deg,
            transparent 0 8px,
            rgba(42, 109, 244, 0.025) 8px 9px
        ),
        #fafbfd;
    text-align: center;
    animation: panel-enter 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.credentials-empty-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.01em;
    margin-bottom: 0.35rem;
}

.credentials-empty-body {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    line-height: 1.55;
    max-width: 36ch;
    margin: 0 auto;
}

/* ──────────────────────────────────────────
   CredentialForm
   ────────────────────────────────────────── */
.credential-form-inline {
    border: 1px solid var(--color-primary);
    border-radius: 8px;
    overflow: hidden;
    animation: panel-enter 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.credential-form-inline .credential-form {
    margin-top: 0;
    border: none;
    border-radius: 0;
    background: #f0f4ff;
}

.credential-form {
    margin-top: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fafbfd;
    animation: panel-enter 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.credential-form h5 {
    margin: 0 0 0.5rem 0;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-secondary);
}

.credential-form .form-field {
    margin-bottom: 6px;
}

.credential-form .form-field input,
.credential-form .form-field select {
    padding: 6px 10px;
}

.credential-form .form-field label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.credential-form .form-field input,
.credential-form .form-field select {
    width: 100%;
    box-sizing: border-box;
}

.credential-form .form-field.is-secret input {
    border-left: 3px solid #d97706;
    padding-left: 10px;
}

.secret-input-wrap {
    position: relative;
    display: block;
}

.secret-input-wrap input {
    padding-right: 36px;
}

.secret-input-toggle {
    appearance: none;
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.secret-input-toggle:hover {
    background: #f0f2f7;
    color: var(--color-text-secondary);
}

.secret-input-toggle:focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(42, 109, 244, 0.18);
}

.secret-input-toggle svg {
    width: 15px;
    height: 15px;
    display: block;
}

.secret-input-toggle[aria-pressed="true"] {
    color: var(--color-primary);
}

.credential-form-actions [data-action="test"] {
    margin-left: auto;
}

.credential-form .form-field.is-secret input:focus {
    border-left-color: #b45309;
}

.credential-form .form-field.is-secret label::after {
    content: 'sensitive';
    margin-left: 0.5rem;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(217, 119, 6, 0.10);
    color: #b45309;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: 1px;
}

.credential-form .form-field span.error-text:empty {
    display: none;
}

.credential-form .form-actions {
    margin-top: 0.5rem;
}

/* Native <select> styled to match the existing <input> */
.form-field select {
    appearance: none;
    padding: 9px 32px 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font: inherit;
    font-size: 0.9rem;
    background-color: #fafbfd;
    color: var(--color-text);
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%235a6a80' d='M0 0l5 6 5-6z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(42, 109, 244, 0.12);
    background-color: var(--color-surface);
}

.form-field select:disabled {
    background-color: #f0f2f7;
    color: var(--color-text-muted);
    cursor: not-allowed;
}


/* ──────────────────────────────────────────
   Mode selector — demo / live radio cards
   ────────────────────────────────────────── */
.mode-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 2px;
}

.mode-card {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--color-bg);
    text-align: left;
    cursor: pointer;
    font: inherit;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.mode-card:hover {
    border-color: var(--color-text-muted);
    background: var(--color-surface);
}

.mode-card-label {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    transition: color 0.15s ease;
}

.mode-card-desc {
    font-size: 0.71rem;
    color: var(--color-text-muted);
    line-height: 1.3;
}

/* Demo — paper money: blue */
.mode-card--demo .mode-card-label {
    color: #2563eb;
}

.mode-card--demo:hover {
    border-color: #2563eb;
    background: #f5f9ff;
}

.mode-card--demo.is-active {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.mode-card--demo.is-active .mode-card-label {
    color: #1d4ed8;
}

/* Live — real money: orange */
.mode-card--live .mode-card-label {
    color: #ea580c;
}

.mode-card--live:hover {
    border-color: #ea580c;
    background: #fff8f1;
}

.mode-card--live.is-active {
    border-color: #ea580c;
    background: #fff7ed;
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.12);
}

.mode-card--live.is-active .mode-card-label {
    color: #9a3412;
}

/* Warning strip — caution, not failure: orange (red is reserved for fail) */
.mode-live-warning {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 8px 11px;
    border-radius: 6px;
    border: 1px solid rgba(234, 88, 12, 0.25);
    background: rgba(234, 88, 12, 0.05);
    color: #9a3412;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.45;
    margin-top: 0;
    animation: panel-enter 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.mode-live-warning[hidden] { display: none; }

.mode-live-warning svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* Form-level live mode accent */
.credential-form.is-live-mode {
    border-left: 3px solid rgba(234, 88, 12, 0.45);
}

.credential-form-inline .credential-form.is-live-mode {
    border-left: 3px solid rgba(234, 88, 12, 0.45);
}
