/* Chat widgets for the AI assistant (Views/Assistant/Index.cshtml).
   Workbench-styled journal-entry cards = .ajw-* ("asiento journal widget"):
   a real, readable Debe/Haber layout (replaces the old balance-beam widget).
   Navy #1e2a4a, indigo #1f3f96, amber #d98a2b reserved for the "proposed" state. */

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

.ajw-card {
    font-family: 'Inter', system-ui, sans-serif;
    max-width: 540px;
    background: #fff;
    border: 1px solid #e6e8ec;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 22px -14px rgba(28, 35, 48, .22);
    animation: ajwIn .22s ease;
    margin-bottom: .5rem;
}

/* Header (navy bar; proposals add a 3px amber top accent) */
.ajw-head {
    background: #1e2a4a;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.ajw-head-proposed { border-top: 3px solid #d98a2b; }

.ajw-tile {
    width: 28px; height: 28px; border-radius: 7px;
    background: rgba(255, 255, 255, .12); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.ajw-tile-amber { background: rgba(217, 138, 43, .22); color: #f0b45f; }

.ajw-entry-num { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: .9rem; color: #fff; }
.ajw-head-date { font-size: .8rem; color: rgba(255, 255, 255, .6); }
.ajw-head-title { font-family: 'Spectral', serif; font-weight: 600; font-size: 1rem; color: #fff; }
.ajw-head-spacer { flex: 1; }

/* Chips (status, balance, "por confirmar") — always text, never color alone */
.ajw-chip {
    font-size: .72rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
    display: inline-flex; align-items: center; gap: 5px;
}

.ajw-chip-ok { background: #e4f3ea; color: #1f7a44; }
.ajw-chip-bad { background: #fbe6e6; color: #b23a3a; }
.ajw-chip-idle { background: rgba(255, 255, 255, .14); color: rgba(255, 255, 255, .75); }

.ajw-chip-pending {
    font-family: 'IBM Plex Mono', monospace; font-size: .64rem; font-weight: 600;
    letter-spacing: .06em; color: #f0b45f; background: rgba(217, 138, 43, .18);
    padding: 3px 8px; border-radius: 999px;
}

.ajw-badge-status {
    font-family: 'IBM Plex Mono', monospace; font-size: .66rem; font-weight: 600;
    letter-spacing: .04em; padding: 3px 9px; border-radius: 999px;
}

.ajw-status-posted { background: #e4f3ea; color: #1f7a44; }
.ajw-status-draft { background: #f1f3f7; color: #5b6373; }
.ajw-status-reversed { background: #fbe6e6; color: #b23a3a; }

/* Description / context phrase */
.ajw-desc { padding: 12px 16px; border-bottom: 1px solid #eef0f3; font-size: .9rem; line-height: 1.5; color: #1c2330; }
.ajw-context { padding: 11px 16px; border-bottom: 1px solid #eef0f3; font-size: .86rem; line-height: 1.5; color: #5b6373; }
.ajw-context strong { color: #1c2330; }

/* Read-only Debe/Haber table (grid rows) */
.ajw-lines { padding: 6px 16px 8px; }

.ajw-row {
    display: grid; grid-template-columns: 1fr auto auto; gap: 4px 18px;
    align-items: center; padding: 8px 0; border-top: 1px solid #f2f3f6;
}

.ajw-row-head {
    border-top: none; padding: 6px 0 4px;
    font-family: 'IBM Plex Mono', monospace; font-size: .62rem;
    letter-spacing: .1em; text-transform: uppercase; color: #9aa1b0;
}

.ajw-acct { min-width: 0; }
.ajw-acct-indent { padding-left: 18px; }
.ajw-acct-code { font-family: 'IBM Plex Mono', monospace; font-weight: 600; font-size: .82rem; color: #1f3f96; }
.ajw-acct-name { font-size: .78rem; color: #7a8294; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ajw-amt-cell {
    text-align: right; width: 96px;
    font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums;
    font-size: .85rem; color: #1c2330;
}

.ajw-amt-zero { color: #c4cad6; }

.ajw-truncated { padding: 7px 0 3px; border-top: 1px solid #f2f3f6; font-size: .76rem; color: #9aa1b0; }

/* Totals strip */
.ajw-totals {
    display: grid; grid-template-columns: 1fr auto auto; gap: 4px 18px;
    align-items: center; padding: 11px 16px; background: #f8f9fb; border-top: 1px solid #eef0f3;
}

.ajw-totals-label { font-family: 'Spectral', serif; font-weight: 600; color: #1e2a4a; font-size: .9rem; }

.ajw-total-amt {
    text-align: right; width: 96px; min-width: 80px;
    font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums;
    font-weight: 600; font-size: .86rem; color: #1c2330;
}

.ajw-total-pair { display: flex; gap: 16px; align-items: baseline; }

.ajw-mini-label {
    font-size: .62rem; font-family: 'IBM Plex Mono', monospace; color: #9aa1b0;
    text-transform: uppercase; letter-spacing: .08em;
}

/* Attachments (read widget, optional) */
.ajw-attachments { padding: 10px 16px 12px; border-top: 1px solid #eef0f3; }

.ajw-attachments-label {
    font-family: 'IBM Plex Mono', monospace; font-size: .62rem; letter-spacing: .1em;
    text-transform: uppercase; color: #9aa1b0; margin-bottom: 7px;
}

.ajw-attachment {
    text-decoration: none; display: flex; align-items: center; gap: 10px;
    padding: 7px 9px; border: 1px solid #e6e8ec; border-radius: 9px; margin-bottom: 6px;
}

.ajw-attachment:hover { background: #f8f9fb; }
.ajw-attachment-body { flex: 1; min-width: 0; }
.ajw-attachment-name {
    display: block; font-size: .82rem; font-weight: 500; color: #1c2330;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ajw-attachment-meta { display: block; font-size: .7rem; color: #9aa1b0; }

/* Action footer (read widget): navy link to the entry detail */
.ajw-open {
    text-decoration: none; background: #1e2a4a; padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 6px; color: #fff;
}

.ajw-open:hover { background: #172038; color: #fff; }
.ajw-open-label { font-size: .82rem; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.ajw-open .bi-chevron-right { font-size: .8rem; color: rgba(255, 255, 255, .6); }

/* Editable proposal rows: TIPO | cuenta | monto | quitar */
.ajw-editor { padding: 8px 16px 4px; }

.ajw-erow {
    display: grid; grid-template-columns: 74px 1fr 118px 30px; gap: 8px;
    align-items: center; padding: 5px 0;
}

.ajw-erow-head {
    padding: 4px 0;
    font-family: 'IBM Plex Mono', monospace; font-size: .6rem;
    letter-spacing: .1em; text-transform: uppercase; color: #9aa1b0;
}

.ajw-side {
    font-family: 'IBM Plex Mono', monospace; font-size: .62rem; font-weight: 700;
    letter-spacing: .05em; border: none; border-radius: 7px; height: 30px; cursor: pointer;
}

.ajw-side-debit { background: #eaf0fd; color: #1f3f96; }
.ajw-side-credit { background: #fbe7d6; color: #a5641a; }
.ajw-side:hover { filter: brightness(.96); }

.ajw-select {
    font-family: 'Inter', sans-serif; font-size: .82rem; color: #1c2330;
    border: 1px solid #dfe3ea; border-radius: 8px; height: 34px; padding: 0 28px 0 10px;
    background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%237a8294' stroke-width='2'><path d='M4 6l4 4 4-4'/></svg>") no-repeat right 9px center;
    -webkit-appearance: none; appearance: none; width: 100%;
}

.ajw-select:focus { outline: none; border-color: #3b5bb5; box-shadow: 0 0 0 3px rgba(59, 91, 181, .14); }

.ajw-amt-input {
    font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums;
    font-size: .85rem; text-align: right; color: #1c2330;
    border: 1px solid #dfe3ea; border-radius: 8px; height: 34px; padding: 0 10px;
    width: 100%; box-sizing: border-box;
}

.ajw-amt-input:focus { outline: none; border-color: #3b5bb5; box-shadow: 0 0 0 3px rgba(59, 91, 181, .14); }

.ajw-remove {
    width: 30px; height: 30px; border: none; background: transparent; border-radius: 7px;
    color: #c4cad6; display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
}

.ajw-remove:hover { background: #fbe6e6; color: #b23a3a; }

.ajw-add-wrap { padding: 6px 0 8px; }

.ajw-add {
    border: 1px dashed #cfd6e4; background: transparent; border-radius: 9px; color: #3b5bb5;
    font-size: .8rem; font-family: 'Inter', sans-serif; padding: 8px 0; width: 100%; cursor: pointer;
}

.ajw-add:hover { background: #eaf0fd; border-color: #3b5bb5; }

/* Confirm footer (proposal) */
.ajw-foot {
    border-top: 1px solid #eef0f3; padding: 12px 16px;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}

.ajw-confirm {
    font-family: 'Inter', sans-serif; font-size: .86rem; font-weight: 600;
    border: none; border-radius: 9px; padding: 9px 18px;
    display: inline-flex; align-items: center; gap: 7px;
    background: #1e2a4a; color: #fff; cursor: pointer;
}

.ajw-confirm:hover:not(:disabled) { background: #172038; }
.ajw-confirm:disabled { background: #eef0f3; color: #b8bec9; cursor: not-allowed; }

.ajw-foot-spacer { flex: 1; }
.ajw-note { font-size: .78rem; color: #7a8294; }
.ajw-note strong { color: #5b6373; }
.ajw-warn { font-size: .78rem; color: #b23a3a; }
.ajw-confirm-status { font-size: .8rem; }
.ajw-confirm-status.ok { color: #1f7a44; }
.ajw-confirm-status.error { color: #b23a3a; }

/* Compact mode inside the 336px chat rail: tighter paddings/gaps and narrower amount
   columns so a 7-digit CLP amount plus the account column still fit. */
.chat-rail .ajw-card { max-width: none; }
.chat-rail .ajw-head, .chat-rail .ajw-desc, .chat-rail .ajw-context,
.chat-rail .ajw-lines, .chat-rail .ajw-totals, .chat-rail .ajw-attachments,
.chat-rail .ajw-open { padding-left: 12px; padding-right: 12px; }
.chat-rail .ajw-row, .chat-rail .ajw-totals { gap: 4px 10px; }
.chat-rail .ajw-amt-cell { width: 80px; font-size: .8rem; }
.chat-rail .ajw-total-amt { width: 80px; min-width: 70px; font-size: .8rem; }
.chat-rail .ajw-total-pair { gap: 10px; }
.chat-rail .ajw-head-title { font-size: .92rem; }
