/* ============================================================
   DE-Coder — Synthesis Chat  (admin-only)
   ============================================================ */

/* ---- Layout ---- */
.synth-shell {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #f1f5f9;
    font-family: inherit;
    min-height: 100%;
}

/* ---- Top bar ---- */
.synth-topbar {
    background: #003B5C;
    padding: .8rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.synth-topbar-icon {
    width: 36px;
    height: 36px;
    background: rgba(243,146,0,.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.synth-topbar-title {
    color: #fff;
    font-size: .92rem;
    font-weight: 700;
}
.synth-topbar-sub {
    color: rgba(255,255,255,.5);
    font-size: .72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.synth-clear-btn {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    color: rgba(255,255,255,.7);
    border-radius: 6px;
    padding: .3rem .75rem;
    font-size: .72rem;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: .03em;
    transition: background .15s;
}
.synth-clear-btn:hover { background: rgba(255,255,255,.15); }

/* ---- Theme pills ---- */
.synth-pills {
    padding: .5rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    flex-shrink: 0;
}
.synth-pill {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #003B5C;
    border-radius: 999px;
    padding: .22rem .7rem;
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, border-color .15s;
}
.synth-pill:hover {
    background: #e0eaf3;
    border-color: #003B5C;
}

.synth-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: .7rem 1.25rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-bottom: 1px solid #e2e8f0;
}
.synth-toolbar-group {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
}
.synth-toolbar-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #64748b;
}
.synth-toolbar-hint {
    font-size: .76rem;
    color: #64748b;
}
.synth-mode-pill {
    background: #fff;
    border: 1px solid #d7e1eb;
    color: #355066;
    border-radius: 999px;
    padding: .3rem .7rem;
    font-size: .74rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s ease;
}
.synth-mode-pill:hover {
    border-color: #9fb4c6;
    color: #003B5C;
}
.synth-mode-pill.active {
    background: #003B5C;
    border-color: #003B5C;
    color: #fff;
    box-shadow: 0 6px 16px rgba(0,59,92,.18);
}

/* ---- Messages scroll area ---- */
.synth-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    min-height: 0;
}
.synth-welcome {
    margin: auto;
    text-align: center;
    max-width: 380px;
    color: #64748b;
    font-size: .9rem;
    line-height: 1.6;
}
.synth-welcome-icon {
    width: 52px;
    height: 52px;
    background: #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

/* ---- Message rows ---- */
.synth-row-user {
    display: flex;
    justify-content: flex-end;
}
.synth-row-ai {
    display: flex;
    justify-content: flex-start;
}

/* ---- User bubble ---- */
.synth-bubble-user {
    background: #003B5C;
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    padding: .7rem 1.1rem;
    max-width: 70%;
    font-size: .92rem;
    line-height: 1.6;
    word-wrap: break-word;
}

/* ---- AI response card ---- */
.synth-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 4px 18px 18px 18px;
    max-width: 92%;
    overflow: hidden;
    box-shadow: 0 8px 28px rgba(15, 23, 42, .07);
}
.synth-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.3rem .85rem;
    border-bottom: 1px solid #eef2f7;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}
.synth-card-kicker {
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: .32rem;
}
.synth-card-title {
    font-size: .98rem;
    font-weight: 700;
    color: #0f172a;
}
.synth-card-evidence {
    margin-top: .35rem;
    font-size: .78rem;
    color: #64748b;
    line-height: 1.55;
}
.synth-badge-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .35rem;
}
.synth-badge {
    display: inline-flex;
    align-items: center;
    background: #eef6fb;
    color: #003B5C;
    border: 1px solid #d4e5f1;
    border-radius: 999px;
    padding: .22rem .58rem;
    font-size: .69rem;
    font-weight: 700;
    white-space: nowrap;
}
.synth-card-section {
    padding: .95rem 1.3rem 1rem;
    border-top: 1px solid #f1f5f9;
}
.synth-card-section:first-of-type {
    border-top: none;
}
.synth-section-label {
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: .55rem;
}
.synth-card-body {
    line-height: 1.85;
    font-size: .94rem;
    color: #1e293b;
}

/* ---- Formatted content inside card ---- */
.synth-card-body strong, .synth-formatted b {
    font-weight: 700;
    color: #003B5C;
}
.synth-formatted p {
    margin: 0 0 .9rem;
}
.synth-formatted p:last-child { margin-bottom: 0; }
.synth-formatted ul, .synth-formatted ol {
    margin: .5rem 0 .9rem 1.2rem;
    padding: 0;
}
.synth-formatted li {
    margin-bottom: .3rem;
    line-height: 1.7;
}

/* ---- Tables ---- */
.synth-table-wrap {
    overflow-x: auto;
    margin: .75rem 0;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}
.synth-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .86rem;
}
.synth-table th {
    background: #003B5C;
    color: #fff;
    padding: .55rem .85rem;
    text-align: left;
    font-weight: 700;
    font-size: .8rem;
    letter-spacing: .03em;
    white-space: nowrap;
}
.synth-table td {
    padding: .5rem .85rem;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: top;
}
.synth-table tr:last-child td { border-bottom: none; }
.synth-table tr:nth-child(even) td { background: #f8fafc; }

/* ---- Good practice box ---- */
.synth-gp {
    background: #fffbf0;
    border-left: 3px solid #F39200;
    border-radius: 0 8px 8px 0;
    padding: .8rem 1rem;
}
.synth-gp-label {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #F39200;
    margin-bottom: .25rem;
}
.synth-gp-text {
    font-size: .89rem;
    color: #1e293b;
    line-height: 1.7;
}

/* ---- Chart section ---- */
.synth-chart-section {
    background: linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
}
.synth-chart-label {
    font-size: .8rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: .5rem;
}

/* ---- Sources ---- */
.synth-sources {
    display: block;
}
.synth-sources-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.synth-sources-summary-label {
    font-size: .82rem;
    font-weight: 700;
    color: #334155;
}
.synth-sources-summary-subtle {
    margin-top: .15rem;
    font-size: .74rem;
    color: #64748b;
}
.synth-sources-view-btn {
    background: #eef6fb;
    border: 1px solid #cfe0ee;
    color: #003B5C;
    border-radius: 10px;
    padding: .45rem .8rem;
    font-size: .76rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s ease;
}
.synth-sources-view-btn:hover {
    background: #e3f0f9;
    border-color: #9bb7cc;
}

/* ---- Card footer ---- */
.synth-card-footer {
    padding: .4rem 1.3rem .65rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    gap: .4rem;
}
.synth-copy-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    border-radius: 6px;
    padding: .2rem .6rem;
    font-size: .7rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}
.synth-copy-btn:hover { background: #e2e8f0; }

/* ---- Error bubble ---- */
.synth-error {
    background: #fee2e2;
    color: #991b1b;
    border-radius: 4px 14px 14px 14px;
    padding: .65rem 1rem;
    max-width: 80%;
    font-size: .88rem;
}

/* ---- Typing indicator ---- */
.synth-typing {
    display: none;
    padding: .3rem 1.5rem .3rem;
    background: #f1f5f9;
    flex-shrink: 0;
}
.synth-typing-inner {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: .45rem .9rem;
}
.synth-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: synthDot 1.2s infinite both;
}
.synth-dot:nth-child(2) { animation-delay: .2s; }
.synth-dot:nth-child(3) { animation-delay: .4s; }
.synth-typing-text {
    font-size: .75rem;
    color: #94a3b8;
}
@keyframes synthDot {
    0%,80%,100% { transform: scale(.6); opacity: .4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ---- Input bar ---- */
.synth-inputbar {
    background: #fff;
    border-top: 1.5px solid #e2e8f0;
    padding: .75rem 1.25rem;
    display: flex;
    gap: .6rem;
    align-items: flex-end;
    flex-shrink: 0;
}
.synth-composer {
    flex: 1;
    min-width: 0;
}
.synth-composer-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
    margin-bottom: .45rem;
    padding: 0 .2rem;
}
.synth-composer-kicker {
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #94a3b8;
}
.synth-composer-value {
    font-size: .74rem;
    font-weight: 700;
    color: #003B5C;
}
.synth-composer-sep {
    color: #cbd5e1;
}
.synth-composer-subtle {
    font-size: .74rem;
    color: #64748b;
}
.synth-textarea {
    flex: 1;
    width: 100%;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: .65rem 1rem;
    font-size: .9rem;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.55;
    box-sizing: border-box;
    color: #1e293b;
    background: #f8fafc;
    transition: border-color .2s;
}
.synth-textarea:focus { border-color: #003B5C; background: #fff; }
.synth-send-btn {
    background: linear-gradient(135deg, #003B5C, #005a8e);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0 1.3rem;
    height: 44px;
    font-size: .85rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: .04em;
    flex-shrink: 0;
    transition: opacity .15s, transform .1s;
}
.synth-send-btn:hover { opacity: .88; transform: translateY(-1px); }
.synth-send-btn:active { transform: translateY(0); }
.synth-send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.synth-card-clarify {
    border-color: #d7e4f0;
}
.synth-clarify-question {
    font-size: .94rem;
    color: #0f172a;
    line-height: 1.7;
    font-weight: 600;
}
.synth-clarify-options {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    margin-top: .85rem;
}
.synth-clarify-option {
    background: #f8fbff;
    border: 1px solid #cfe0ee;
    color: #003B5C;
    border-radius: 12px;
    padding: .6rem .8rem;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s ease;
}
.synth-clarify-option:hover {
    background: #eef6fb;
    border-color: #9bb7cc;
}
.synth-clarify-note {
    margin-top: .75rem;
    font-size: .76rem;
    color: #64748b;
}

.synth-source-modal {
    max-width: 980px;
}
.synth-sources-modal {
    max-width: 760px;
}
.synth-source-modal-sub {
    margin-top: .2rem;
    font-size: .78rem;
    color: #64748b;
}
.synth-source-modal-body {
    padding: 1.25rem;
}
.synth-sources-modal-body {
    padding: 1rem 1.25rem 1.25rem;
}
.synth-sources-toolbar {
    margin-bottom: .9rem;
}
.synth-sources-search {
    width: 100%;
    border: 1.5px solid #d7e1eb;
    border-radius: 10px;
    padding: .7rem .9rem;
    font-size: .86rem;
    outline: none;
    box-sizing: border-box;
}
.synth-sources-search:focus {
    border-color: #003B5C;
}
.synth-sources-list-panel {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    max-height: 56vh;
    overflow: auto;
}
.synth-sources-list-item {
    width: 100%;
    text-align: left;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 12px;
    padding: .85rem .95rem;
    cursor: pointer;
    transition: all .15s ease;
}
.synth-sources-list-item:hover {
    border-color: #cfe0ee;
    background: #f9fbfd;
}
.synth-sources-list-name {
    display: block;
    font-size: .86rem;
    font-weight: 700;
    color: #0f172a;
}
.synth-sources-list-id {
    display: block;
    margin-top: .18rem;
    font-size: .74rem;
    color: #64748b;
}
.synth-source-loading,
.synth-source-empty {
    font-size: .88rem;
    color: #64748b;
}
.synth-source-summary {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}
.synth-source-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
}
.synth-source-meta-line {
    margin-top: .25rem;
    font-size: .78rem;
    color: #64748b;
}
.synth-source-grid {
    display: grid;
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
    gap: 1rem;
}
.synth-source-panel {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1rem;
    background: #fff;
}
.synth-source-meta-table {
    display: grid;
    gap: .55rem;
}
.synth-source-meta-row {
    display: grid;
    gap: .18rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid #f1f5f9;
}
.synth-source-meta-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}
.synth-source-meta-key {
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #94a3b8;
}
.synth-source-meta-value {
    font-size: .84rem;
    color: #1e293b;
    line-height: 1.55;
}
.synth-source-excerpt {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: .8rem;
    margin-bottom: .8rem;
}
.synth-source-excerpt:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}
.synth-source-excerpt-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    font-size: .72rem;
    color: #64748b;
    margin-bottom: .35rem;
}
.synth-source-excerpt-text {
    font-size: .86rem;
    color: #1e293b;
    line-height: 1.65;
}

@media (max-width: 900px) {
    .synth-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .synth-source-grid {
        grid-template-columns: 1fr;
    }
}
