/* ── Phronesis Chat panel ────────────────────────────────────────────────────── */

/* Floating trigger button — fixed bottom-right */
.phronesis-fab {
    position: fixed;
    bottom: 88px;
    right: 28px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #015f6b 0%, #028090 50%, #02a0b4 100%);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(2,128,144,.45);
    transition: all .2s;
    font-family: inherit;
    letter-spacing: .02em;
}

.phronesis-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px rgba(2,128,144,.55);
}

.phronesis-fab-icon {
    font-size: 1rem;
    line-height: 1;
}

.phronesis-fab-badge {
    background: rgba(255,255,255,.2);
    font-size: 0.68rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* ── Slide-in panel ──────────────────────────────────────────────────────── */

.phronesis-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: calc(100vw - 16px);
    height: 100vh;
    z-index: 950;
    display: flex;
    flex-direction: column;
    background: #0f2235;
    border-left: 1px solid rgba(255,255,255,.08);
    box-shadow: -12px 0 48px rgba(0,0,0,.4);
    transition: right .3s cubic-bezier(.4,0,.2,1);
}

.phronesis-panel.open { right: 0; }

/* Backdrop */
.phronesis-backdrop {
    position: fixed;
    inset: 0;
    z-index: 940;
    background: rgba(0,0,0,.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}

.phronesis-backdrop.visible {
    opacity: 1;
    pointer-events: all;
}

/* Panel header */
.phronesis-panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.phronesis-header-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #00d4aa;
    box-shadow: 0 0 8px #00d4aa;
    flex-shrink: 0;
}

.phronesis-header-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #e8edf2;
    flex: 1;
}

.phronesis-header-ctx {
    font-size: 0.72rem;
    color: rgba(232,237,242,.45);
    font-weight: 400;
}

.phronesis-close-btn {
    background: none;
    border: none;
    color: rgba(232,237,242,.45);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all .15s;
    font-family: inherit;
}

.phronesis-close-btn:hover {
    background: rgba(255,255,255,.06);
    color: #e8edf2;
}

/* Messages area */
.phronesis-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}

.phronesis-messages::-webkit-scrollbar { width: 4px; }
.phronesis-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

/* Message bubbles */
.msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}

.msg-phronesis { align-self: flex-start; }
.msg-user   { align-self: flex-end; }

.msg-avatar {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(232,237,242,.4);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.msg-phronesis .msg-avatar { margin-left: 2px; }
.msg-user   .msg-avatar { text-align: right; margin-right: 2px; }

.msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #e8edf2;
}

.msg-phronesis .msg-bubble {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.07);
    border-bottom-left-radius: 4px;
}

.msg-user .msg-bubble {
    background: rgba(2,128,144,.18);
    border: 1px solid rgba(2,128,144,.25);
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.msg-typing .msg-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}

.typing-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: rgba(0,212,170,.5);
    animation: typing-bounce .9s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .30s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: .5; }
    40% { transform: translateY(-5px); opacity: 1; }
}

/* Suggestion chips */
.phronesis-suggestions {
    padding: 0 20px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}

.suggestion-chip {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 16px;
    padding: 5px 12px;
    font-size: 0.76rem;
    color: rgba(232,237,242,.7);
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}

.suggestion-chip:hover {
    background: rgba(2,128,144,.15);
    border-color: rgba(2,128,144,.35);
    color: #e8edf2;
}

/* Input bar */
.phronesis-input-bar {
    display: flex;
    gap: 8px;
    padding: 14px 20px 18px;
    border-top: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}

.phronesis-input {
    flex: 1;
    background: rgba(255,255,255,.05);
    border: 1.5px solid rgba(255,255,255,.1);
    border-radius: 10px;
    color: #e8edf2;
    font-size: 0.85rem;
    padding: 10px 14px;
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
    resize: none;
    height: 42px;
    max-height: 120px;
    overflow-y: auto;
}

.phronesis-input:focus { border-color: #028090; }

.phronesis-input::placeholder { color: rgba(232,237,242,.3); }

.phronesis-send-btn {
    background: linear-gradient(135deg, #028090, #02a0b4);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 0.9rem;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    flex-shrink: 0;
}

.phronesis-send-btn:hover { opacity: .85; transform: translateY(-1px); }
.phronesis-send-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

/* New conversation link */
.phronesis-new-convo {
    text-align: center;
    padding: 6px 20px 0;
    font-size: 0.72rem;
    color: rgba(232,237,242,.35);
    cursor: pointer;
    transition: color .15s;
    flex-shrink: 0;
    background: none;
    border: none;
    font-family: inherit;
    width: 100%;
}

.phronesis-new-convo:hover { color: rgba(232,237,242,.65); }

/* Error state inside bubble */
.msg-error .msg-bubble {
    background: rgba(220,38,38,.08);
    border-color: rgba(220,38,38,.2);
    color: #f87171;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .phronesis-panel { width: 100vw; max-width: 100vw; }
    .phronesis-fab   { bottom: 76px; right: 16px; }
}

/* Hide chat FAB, panel and backdrop in all printed/PDF reports */
@media print {
    .phronesis-fab,
    .phronesis-panel,
    .phronesis-backdrop { display: none !important; }
}
