/* PatioSlings.com AI Assistant - floating chat widget
   Scoped under #psChatRoot so it never collides with site styles.
   Uses Driftwood palette: navy #2C3E4E, cream #F5F1EA, drift #B8A38A,
   teal #4A6B7C, line #E4DCCB. */

#psChatRoot, #psChatRoot * { box-sizing: border-box; }
/* The site-wide stylesheet sets a { font: normal 14px 'Droid Sans'...;
   vertical-align: middle } which overrides inherited font-size and
   baseline. Reset both so links inside the widget sit on the same
   line and match the surrounding text. */
#psChatRoot a { font: inherit; vertical-align: baseline; }

#psChatRoot {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2147483000;
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    color: #1a1a1a;
}

/* --- Launcher button --- */
#psChatLauncher {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: #2C3E4E;
    color: #F5F1EA;
    border: none;
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
#psChatLauncher:hover {
    background: #365464;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}
#psChatLauncher svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}
#psChatRoot.open #psChatLauncher { display: none; }

/* --- Chat panel --- */
#psChatPanel {
    display: none;
    flex-direction: column;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 40px);
    background: #F5F1EA;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(34, 49, 63, 0.3);
    overflow: hidden;
    border: 1px solid #E4DCCB;
}
#psChatRoot.open #psChatPanel { display: flex; }

/* --- Header --- */
#psChatHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #2C3E4E;
    color: #F5F1EA;
}
#psChatHeader .psHeaderLeft {
    display: flex;
    align-items: center;
    gap: 10px;
}
#psChatHeader .psBotIcon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#psChatHeader .psBotIcon svg {
    width: 34px;
    height: 34px;
}
#psChatHeader .title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}
#psChatHeader .subtitle {
    font-size: 12px;
    opacity: 0.8;
    font-weight: 400;
}
#psChatHeader .actions { display: flex; gap: 4px; }
#psChatHeader button {
    background: transparent;
    border: none;
    color: #F5F1EA;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#psChatHeader button:hover { background: rgba(255, 255, 255, 0.15); }
#psChatHeader svg { width: 16px; height: 16px; fill: currentColor; }

/* --- Message list --- */
#psChatLog {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #F5F1EA;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
#psChatLog::-webkit-scrollbar { width: 8px; }
#psChatLog::-webkit-scrollbar-track { background: transparent; }
#psChatLog::-webkit-scrollbar-thumb { background: #D9D1C1; border-radius: 4px; }

.psMsg {
    max-width: 85%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}
.psMsg.user {
    align-self: flex-end;
    background: #2C3E4E;
    color: #F5F1EA;
    border-bottom-right-radius: 4px;
}
.psMsg.assistant {
    align-self: flex-start;
    background: #ffffff;
    color: #2C3E4E;
    border: 1px solid #E4DCCB;
    border-bottom-left-radius: 4px;
}
.psMsg.error {
    align-self: center;
    background: #EBE4D6;
    color: #7E5B3A;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #7E5B3A;
}
.psMsg p { margin: 0 0 8px 0; }
.psMsg p:last-child { margin-bottom: 0; }
.psMsg ul, .psMsg ol { margin: 4px 0 8px 20px; padding: 0; }
.psMsg li { margin: 2px 0; }
.psMsg a {
    color: #4A6B7C;
    text-decoration: underline;
}
.psMsg.user a { color: #D9D1C1; }
.psMsg code {
    background: #EBE4D6;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 13px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
.psMsg.user code { background: rgba(245, 241, 234, 0.18); color: #F5F1EA; }
.psMsg strong { font-weight: 600; }
.psMsg img {
    display: block;
    max-width: 100%;
    max-height: 260px;
    margin: 8px 0;
    border-radius: 6px;
    border: 1px solid #E4DCCB;
    background: #ffffff;
}
.psMsg table {
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0;
    font-size: 13px;
}
.psMsg th, .psMsg td {
    border: 1px solid #E4DCCB;
    padding: 4px 7px;
    text-align: left;
}
.psMsg.user table th, .psMsg.user table td { border-color: rgba(245, 241, 234, 0.3); }

/* Typing indicator */
.psTyping {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid #E4DCCB;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.psTyping span {
    width: 7px;
    height: 7px;
    background: #B8A38A;
    border-radius: 50%;
    animation: psBlink 1.2s infinite ease-in-out;
}
.psTyping span:nth-child(2) { animation-delay: 0.15s; }
.psTyping span:nth-child(3) { animation-delay: 0.3s; }
@keyframes psBlink {
    0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-2px); }
}

/* --- Composer --- */
#psChatForm {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #E4DCCB;
    background: #ffffff;
}
#psChatInput {
    flex: 1;
    resize: none;
    max-height: 100px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid #E4DCCB;
    border-radius: 10px;
    outline: none;
    color: #2C3E4E;
    background: #fff;
}
#psChatInput:focus { border-color: #4A6B7C; box-shadow: 0 0 0 3px rgba(74, 107, 124, 0.15); }
#psChatSend {
    background: #2C3E4E;
    color: #F5F1EA;
    border: none;
    border-radius: 10px;
    padding: 0 16px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    min-width: 60px;
}
#psChatSend:disabled { opacity: 0.5; cursor: not-allowed; }
#psChatSend:hover:not(:disabled) { background: #365464; }

#psChatFooter {
    font-size: 11px;
    color: #6E7A85;
    text-align: center;
    padding: 6px 12px 10px;
    background: #ffffff;
}
#psChatFooter a { color: #4A6B7C; text-decoration: none; }
#psChatFooter a:hover { text-decoration: underline; }

/* Greeting / suggestions */
.psSuggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 4px;
}
.psSuggestions button {
    background: #fff;
    border: 1px solid #2C3E4E;
    color: #2C3E4E;
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-family: inherit;
    min-height: 0;
    line-height: 1.3;
}
.psSuggestions button:hover { background: #2C3E4E; color: #F5F1EA; }

/* --- Standalone full-page view --- */
#psChatRoot.fullpage {
    position: static;
    right: auto;
    bottom: auto;
    display: flex;
    justify-content: center;
    padding: 20px;
}
#psChatRoot.fullpage #psChatLauncher { display: none; }
#psChatRoot.fullpage #psChatPanel {
    display: flex;
    width: 100%;
    max-width: 860px;
    height: min(80vh, 760px);
}

@media (max-width: 1024px) {
    #psChatLauncher span { display: none; }
    #psChatLauncher { padding: 14px; }
}

/* --- Mobile --- */
@media (max-width: 480px) {
    #psChatRoot { right: 10px; bottom: 10px; left: 10px; }
    #psChatLauncher { margin-left: auto; }
    #psChatPanel {
        width: auto;
        height: calc(100vh - 20px);
        max-height: calc(100vh - 20px);
        border-radius: 12px;
    }
}

