/* ==========================
   FONT & RESETRI DE BAZĂ
   ========================== */

#ps-chatbox,
#ps-chat-launcher {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    box-sizing: border-box;
}

#ps-chatbox *,
#ps-chat-launcher * {
    box-sizing: inherit;
}

/* ==========================
   LAUNCHER PLUTITOR
   ========================== */

#ps-chat-launcher {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 999px;
    background:
        radial-gradient(circle at 0 0, rgba(255,255,255,0.28), transparent 55%),
        linear-gradient(135deg, var(--brand-blue, #080063) 0%, #24119a 45%, var(--brand-orange, #FF3B05) 100%);
    color: #ffffff;
    cursor: pointer;
    z-index: 9998;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(8, 0, 99, 0.9);
    transition:
        transform 0.18s ease-out,
        box-shadow 0.18s ease-out,
        opacity 0.18s ease-out,
        visibility 0.18s ease-out,
        filter 0.18s ease-out;
}

#ps-chat-launcher:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 22px 56px rgba(15, 23, 42, 0.65);
    filter: saturate(1.05);
}

.ps-chat-launcher-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ps-chat-launcher-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 20%, var(--brand-orange, #FF3B05), var(--brand-blue, #080063));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 0 0 2px rgba(248, 250, 252, 0.95);
    color: #f9fafb;
}

.ps-chat-launcher-text {
    font-size: 14px;
    font-weight: 500;
}

/* ==========================
   FEREASTRA DE CHAT
   ========================== */

#ps-chatbox {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 360px;
    max-width: calc(100% - 32px);
    max-height: min(520px, 80vh);
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at top, #ffffff 0, #f5f5f7 55%, #e5e7eb 100%);
    color: #0f172a;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.55);
    overflow: hidden;
    z-index: 9999;
    transform-origin: bottom right;
    border: 1px solid #e5e7eb;
    transition:
        transform 0.2s ease-out,
        opacity 0.2s ease-out,
        visibility 0.2s ease-out;
}

/* Când e închis */
#ps-chatbox.ps-chat-closed {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
    visibility: hidden;
    pointer-events: none;
}

/* Când e deschis */
#ps-chatbox.ps-chat-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    visibility: visible;
    pointer-events: auto;
}

/* ==========================
   HEADER
   ========================== */

#ps-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.18) 0, transparent 55%),
        linear-gradient(135deg, var(--brand-blue, #080063) 0%, #24119a 50%, var(--brand-orange, #FF3B05) 100%);
    border-bottom: 1px solid rgba(209, 213, 219, 0.6);
}

.ps-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ps-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 20%, var(--brand-orange, #FF3B05), var(--brand-blue, #080063));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    color: #ffffff;
    box-shadow: 0 0 0 2px rgba(248, 250, 252, 0.95);
}

.ps-chat-header-text {
    display: flex;
    flex-direction: column;
}

.ps-chat-title {
    font-size: 14px;
    font-weight: 600;
    color: #f9fafb;
}

.ps-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #e5e7eb;
    opacity: 0.9;
}

.ps-dot-online {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.35);
}

#ps-chat-close {
    border: none;
    background: transparent;
    color: #e5e7eb;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 999px;
    transition:
        background-color 0.15s ease-out,
        color 0.15s ease-out,
        transform 0.1s ease-out;
}

#ps-chat-close:hover {
    background-color: rgba(15, 23, 42, 0.25);
    transform: scale(1.05);
}

/* ==========================
   SUBTITLE
   ========================== */

#ps-chat-subtitle {
    padding: 8px 14px 6px 14px;
    font-size: 12px;
    color: #6b7280;
    background: rgba(255,255,255,0.96);
    border-bottom: 1px solid rgba(229, 231, 235, 0.95);
}

/* ==========================
   MESAJE
   ========================== */

#ps-chat-messages {
    flex: 1 1 auto;
    padding: 10px 10px 4px;
    overflow-y: auto;
    background:
        radial-gradient(circle at top, rgba(8, 0, 99, 0.04) 0, transparent 55%),
        radial-gradient(circle at bottom, rgba(255, 59, 5, 0.04) 0, transparent 55%),
        #f9fafb;
    display: flex;
    flex-direction: column;
}

/* Scrollbar discret */
#ps-chat-messages::-webkit-scrollbar {
    width: 6px;
}
#ps-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#ps-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.6);
    border-radius: 999px;
}

.ps-msg {
    max-width: 78%;
    margin: 6px 0;
    padding: 8px 11px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.4;
    display: inline-flex;
    flex-direction: column;
}

/* eticheta de sus (Dvs. / Simona) */
.ps-msg-label {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.9;
    color: #6b7280;
}

.ps-msg-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Mesaj AI – card stânga, aliniat cu cardurile din landing */
.ps-msg-ai {
    align-self: flex-start;
    background: #ffffff;
    color: #111827;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(209, 213, 219, 0.9);
    box-shadow: 0 10px 26px rgba(148, 163, 184, 0.28);
}

/* Mesaj utilizator – card dreapta, gradient brand */
.ps-msg-user {
    align-self: flex-end;
    background:
        radial-gradient(circle at 0 0, rgba(255,255,255,0.25), transparent 55%),
        linear-gradient(135deg, var(--brand-blue, #080063), var(--brand-orange, #FF3B05));
    color: #f9fafb;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(8, 0, 99, 0.85);
    box-shadow: 0 12px 32px rgba(8, 0, 99, 0.55);
}

/* Simona scrie... */
.ps-msg-typing .ps-msg-text {
    font-style: italic;
    opacity: 0.85;
}

/* Eroare */
.ps-msg-error {
    max-width: 100%;
    margin: 8px auto;
    background: rgba(248, 113, 113, 0.08);
    color: #b91c1c;
    border: 1px solid rgba(248, 113, 113, 0.7);
    border-radius: 10px;
    font-size: 12px;
}

/* ==========================
   FOOTER & INPUT
   ========================== */

#ps-chat-footer {
    border-top: 1px solid rgba(229, 231, 235, 0.95);
    padding: 6px 10px 8px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#ps-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 6px 6px 6px 10px;
    background: #f9fafb;
    border-radius: 999px;
    border: 1px solid rgba(209, 213, 219, 0.9);
}

/* IMPORTANT: font-size >= 16px ca să nu facă zoom pe mobil */
#ps-chat-input {
    flex: 1 1 auto;
    border: none;
    outline: none;
    background: transparent;
    color: #0f172a;
    resize: none;
    font-size: 16px;
    line-height: 1.4;
    max-height: 120px;
    padding: 4px 0;
}

#ps-chat-input::placeholder {
    color: #9ca3af;
}

#ps-chat-send {
    border: none;
    outline: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 500;
    cursor: pointer;
    background:
        radial-gradient(circle at 0 0, rgba(255,255,255,0.25), transparent 55%),
        linear-gradient(135deg, var(--brand-orange, #FF3B05), #ff7a3b);
    color: #f9fafb;
    white-space: nowrap;
    transition:
        transform 0.12s ease-out,
        box-shadow 0.12s ease-out,
        opacity 0.12s ease-out,
        background-position 0.12s ease-out,
        filter 0.12s ease-out;
    background-size: 200% 200%;
    background-position: 0% 50%;
    box-shadow: 0 18px 45px rgba(8, 0, 99, 0.45);
    border: 1px solid rgba(8, 0, 99, 0.9);
}

#ps-chat-send:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 22px 60px rgba(8, 0, 99, 0.65);
    background-position: 100% 50%;
    filter: saturate(1.05);
}

#ps-chat-send:active {
    transform: translateY(0);
    box-shadow: none;
}

.ps-chat-send-disabled {
    opacity: 0.65;
    cursor: default;
    box-shadow: none !important;
    transform: none !important;
}

/* Disclaimer */
.ps-chat-disclaimer {
    font-size: 11px;
    color: #9ca3af;
    padding: 0 4px;
}

/* ==========================
   RESPONSIVE
   ========================== */

@media (max-width: 600px) {
    #ps-chatbox {
        right: 8px;
        left: 8px;
        width: auto;
        max-width: none;
        bottom: 10px;
        max-height: 80vh;
        border-radius: 18px;
    }

    #ps-chat-launcher {
        right: 12px;
        bottom: 12px;
        padding: 9px 12px;
    }

    .ps-chat-launcher-text {
        font-size: 13px;
    }
}
