/* =========================================================
   Console · Chat with Pi
   Brand-navy console shell, ready to bind to CRM/SaaS later
   ========================================================= */

:root {
    --pi-navy: #fcf8f5;
    --pi-navy-2: #f2eeeb;
    --pi-navy-3: #d8cbbf;
    --pi-line: rgba(70, 50, 32, 0.14);
    --pi-text: #38200c;
    --pi-dim: #7d5a3c;
    --pi-gold: #ff9800;
    --pi-gold-2: #e07000;
    --pi-cyan: #1d6fd6;
    --pi-ok: #1f9d5c;
    --pi-warn: #c77700;
    --pi-err: #c94b4b;
    --pi-mono: "SFMono-Regular", ui-monospace, Menlo, Consolas,
        "Liberation Mono", monospace;
}

/* ---------- Launcher ---------- */

.pi-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 8px 8px;
    border: 1px solid var(--pi-navy-3);
    border-radius: 999px;
    background: var(--pi-navy);
    color: var(--pi-text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 550;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(37, 17, 2, 0.32);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.pi-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 38px rgba(37, 17, 2, 0.4);
}

.pi-launcher img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex: none;
}

.pi-launcher .pi-ping {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--pi-ok);
    box-shadow: 0 0 0 0 rgba(70, 192, 122, 0.6);
    animation: pi-ping 2.4s ease-out infinite;
    flex: none;
}

@keyframes pi-ping {
    0% {
        box-shadow: 0 0 0 0 rgba(70, 192, 122, 0.55);
    }
    70% {
        box-shadow: 0 0 0 9px rgba(70, 192, 122, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(70, 192, 122, 0);
    }
}

.pi-open .pi-launcher {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

/* ---------- Panel ---------- */

.pi-panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 901;
    width: 392px;
    max-width: calc(100vw - 32px);
    height: 574px;
    max-height: calc(100vh - 44px);
    display: flex;
    flex-direction: column;
    background: var(--pi-navy);
    border: 1px solid var(--pi-navy-3);
    border-radius: 16px;
    box-shadow: 0 30px 70px rgba(10, 18, 34, 0.45);
    overflow: hidden;
    color: var(--pi-text);
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(0.985);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.pi-open .pi-panel {
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* Header */
.pi-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    background: linear-gradient(180deg, var(--pi-navy-2), var(--pi-navy));
    border-bottom: 1px solid var(--pi-line);
    flex: none;
}

.pi-head img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex: none;
}

.pi-head .pi-titles {
    flex: 1;
    min-width: 0;
}

.pi-head .pi-t {
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pi-head .pi-s {
    font-size: 11.5px;
    color: var(--pi-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 1px;
}

.pi-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--pi-warn);
    flex: none;
}

.pi-dot[data-state="online"] {
    background: var(--pi-ok);
}
.pi-dot[data-state="error"] {
    background: var(--pi-err);
}

.pi-iconbtn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--pi-dim);
    border-radius: 7px;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.pi-iconbtn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--pi-text);
}

/* Log */
.pi-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(90, 50, 15, 0.3) transparent;
}

.pi-log::-webkit-scrollbar {
    width: 8px;
}

.pi-log::-webkit-scrollbar-thumb {
    background: rgba(90, 50, 15, 0.28);
    border-radius: 4px;
}

.pi-msg {
    font-size: 13.5px;
    line-height: 1.55;
    animation: pi-in 0.22s ease both;
}

@keyframes pi-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

.pi-role {
    font-family: var(--pi-mono);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pi-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.pi-msg[data-role="user"] .pi-role {
    color: var(--pi-cyan);
}
.pi-msg[data-role="pi"] .pi-role {
    color: var(--pi-gold);
}

.pi-bubble {
    background: var(--pi-navy-2);
    border: 1px solid var(--pi-line);
    border-radius: 10px;
    padding: 9px 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.pi-msg[data-role="user"] .pi-bubble {
    background: var(--pi-navy-3);
    border-color: rgba(29, 111, 214, 0.3);
}

.pi-msg[data-role="system"] .pi-bubble {
    background: transparent;
    border: 1px dashed var(--pi-line);
    color: var(--pi-dim);
    font-family: var(--pi-mono);
    font-size: 12px;
}

/* Typing indicator */
.pi-typing .pi-bubble {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.pi-typing i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--pi-dim);
    animation: pi-blink 1.2s infinite ease-in-out;
}

.pi-typing i:nth-child(2) {
    animation-delay: 0.16s;
}
.pi-typing i:nth-child(3) {
    animation-delay: 0.32s;
}

@keyframes pi-blink {
    0%,
    80%,
    100% {
        opacity: 0.25;
    }
    40% {
        opacity: 1;
    }
}

/* Quick chips */
.pi-quick {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 0 14px 10px;
    flex: none;
}

.pi-quick button {
    font-family: inherit;
    font-size: 12px;
    color: var(--pi-dim);
    background: transparent;
    border: 1px solid var(--pi-line);
    border-radius: 999px;
    padding: 5px 11px;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.pi-quick button:hover {
    color: var(--pi-text);
    border-color: rgba(255, 152, 0, 0.55);
    background: rgba(255, 152, 0, 0.1);
}

/* Composer */
.pi-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--pi-line);
    background: var(--pi-navy-2);
    flex: none;
}

.pi-form textarea {
    flex: 1;
    resize: none;
    min-height: 38px;
    max-height: 120px;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--pi-text);
    background: var(--pi-navy);
    border: 1px solid var(--pi-navy-3);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.15s ease;
}

.pi-form textarea::placeholder {
    color: rgba(125, 90, 60, 0.7);
}

.pi-form textarea:focus {
    border-color: rgba(255, 152, 0, 0.6);
}

.pi-send {
    width: 38px;
    height: 38px;
    flex: none;
    border: none;
    border-radius: 10px;
    background: linear-gradient(150deg, var(--pi-gold), var(--pi-gold-2));
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: filter 0.15s ease, transform 0.15s ease;
}

.pi-send:hover {
    filter: brightness(1.07);
}

.pi-send:active {
    transform: scale(0.95);
}

.pi-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pi-hint {
    padding: 0 14px 10px;
    font-family: var(--pi-mono);
    font-size: 10.5px;
    color: rgba(125, 90, 60, 0.8);
    background: var(--pi-navy-2);
    flex: none;
}

@media (max-width: 520px) {
    .pi-panel {
        right: 10px;
        left: 10px;
        bottom: 10px;
        width: auto;
        height: min(80vh, 560px);
    }
    .pi-launcher {
        right: 14px;
        bottom: 14px;
        padding: 8px;
    }
    .pi-launcher .pi-label {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pi-launcher .pi-ping,
    .pi-typing i {
        animation: none;
    }
}
