/* Help / Chat widget (partials/support-widget.blade.php, frontend/js/support-widget.js). PM-332.
   Sits under Metronic modals (1065+) and, below 992px, under the mobile header (9999). */
.psw {
    --psw-primary: #3699FF;
    --psw-primary-dark: #187DE4;
    --psw-text: #3F4254;
    --psw-muted: #7E8299;
    --psw-border: #EBEDF3;
    --psw-bg: #FFFFFF;
    --psw-soft: #F3F6F9;
    --psw-mine: #E1F0FF;
    --psw-online: #1BC5BD;
    --psw-danger: #F64E60;
    font-family: Poppins, Helvetica, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.45;
    color: var(--psw-text);
}

.psw *, .psw *::before, .psw *::after { box-sizing: border-box; }
.psw [hidden] { display: none !important; }
.psw-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.psw-launcher {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1050;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px 0 14px;
    border: 0;
    border-radius: 22px;
    background: var(--psw-primary);
    color: #FFFFFF;
    font: inherit;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(54, 153, 255, .35);
    cursor: pointer;
}
.psw-launcher:hover, .psw-launcher:focus-visible { background: var(--psw-primary-dark); outline: none; }
.psw-launcher:focus-visible { box-shadow: 0 0 0 3px rgba(54, 153, 255, .4); }
.psw-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 10px;
    height: 10px;
    border: 2px solid #FFFFFF;
    border-radius: 50%;
    background: var(--psw-danger);
}
/* Metronic's scroll-to-top button sits in the same corner. */
body .scrolltop { bottom: 76px; }

.psw-panel {
    position: fixed;
    right: 20px;
    bottom: 76px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    width: 370px;
    max-height: min(620px, calc(100vh - 110px));
    border: 1px solid var(--psw-border);
    border-radius: 12px;
    background: var(--psw-bg);
    box-shadow: 0 14px 40px rgba(24, 28, 50, .18);
    overflow: hidden;
}

.psw-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 14px 14px 12px 18px;
    background: var(--psw-primary);
    color: #FFFFFF;
}
.psw-header-text { flex: 1; min-width: 0; }
.psw-title { margin: 0; font-size: 15px; font-weight: 600; color: #FFFFFF; line-height: 1.3; }
.psw-status { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; font-size: 12px; opacity: .92; }
.psw-dot { width: 8px; height: 8px; border-radius: 50%; background: #B5B5C3; flex-shrink: 0; }
.psw-status-online .psw-dot { background: #7CFFC4; }
.psw-close, .psw-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #FFFFFF;
    cursor: pointer;
}
.psw-close:hover, .psw-back:hover, .psw-close:focus-visible, .psw-back:focus-visible { background: rgba(255, 255, 255, .18); outline: none; }

.psw-view { padding: 14px 16px 16px; overflow-y: auto; }

.psw-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #E4E6EF;
    border-radius: 6px;
    background: #FFFFFF;
    color: var(--psw-text);
    font: inherit;
}
.psw-input:focus { border-color: var(--psw-primary); outline: none; box-shadow: 0 0 0 2px rgba(54, 153, 255, .15); }
textarea.psw-input { resize: none; }

.psw-results { list-style: none; margin: 8px 0 0; padding: 0; }
.psw-results li a { display: block; padding: 7px 4px; border-bottom: 1px solid var(--psw-border); color: var(--psw-text); text-decoration: none; }
.psw-results li a:hover, .psw-results li a:focus-visible { color: var(--psw-primary); outline: none; }
.psw-results .psw-results-all a { border-bottom: 0; color: var(--psw-primary); font-weight: 600; }
.psw-results .psw-results-none { padding: 7px 4px; color: var(--psw-muted); }

.psw-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.psw-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--psw-border);
    border-radius: 8px;
    background: var(--psw-bg);
    color: var(--psw-text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.psw-action:hover, .psw-action:focus-visible { border-color: var(--psw-primary); color: var(--psw-text); text-decoration: none; outline: none; background: #F8FBFF; }
.psw-action strong { display: block; font-weight: 600; }
.psw-action small { display: block; color: var(--psw-muted); font-size: 12px; }
.psw-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--psw-mine);
    color: var(--psw-primary);
}

.psw-chat { display: flex; flex-direction: column; gap: 10px; }
.psw-chat-intro { margin: 0; color: var(--psw-muted); }
.psw-signed-in { display: block; margin-top: 4px; color: var(--psw-text); }
.psw-messages { display: flex; flex-direction: column; gap: 10px; }
.psw-msg { max-width: 88%; }
.psw-msg-customer { align-self: flex-end; text-align: right; }
.psw-msg-meta { margin-bottom: 3px; color: var(--psw-muted); font-size: 11px; }
.psw-msg-body {
    display: inline-block;
    padding: 8px 11px;
    border-radius: 10px;
    background: var(--psw-soft);
    text-align: left;
    overflow-wrap: anywhere;
}
.psw-msg-customer .psw-msg-body { background: var(--psw-mine); }
.psw-msg-body p { margin: 0 0 6px; }
.psw-msg-body p:last-child { margin-bottom: 0; }
.psw-msg-body img { max-width: 100%; height: auto; }
.psw-chat-note { margin: 0; padding: 8px 10px; border-radius: 6px; background: #E8FFF3; color: #0BB783; }
.psw-visitor { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.psw-compose { display: flex; gap: 6px; align-items: flex-end; }
.psw-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: 0;
    border-radius: 8px;
    background: var(--psw-primary);
    color: #FFFFFF;
    cursor: pointer;
}
.psw-send:disabled { opacity: .55; cursor: default; }
.psw-send:hover:not(:disabled), .psw-send:focus-visible { background: var(--psw-primary-dark); outline: none; }
.psw-error { margin-bottom: 6px; padding: 7px 10px; border-radius: 6px; background: #FFE2E5; color: var(--psw-danger); }
.psw-hp { position: absolute; left: -9999px; }
.psw-fine { margin: 6px 0 0; color: var(--psw-muted); font-size: 11px; }
.psw-fine a { color: var(--psw-muted); text-decoration: underline; }
.psw-chat-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 12px; }
.psw-chat-footer a { color: var(--psw-primary); }
.psw-link { padding: 0; border: 0; background: none; color: var(--psw-muted); font: inherit; text-decoration: underline; cursor: pointer; }
.psw-skip-ai { display: block; margin-top: 6px; font-size: 12px; }

/* AI assistant (answers from the Knowledge Base) */
.psw-msg-assistant .psw-msg-body { background: #F8F5FF; border: 1px solid #EEE5FF; }
.psw-msg-sources { margin-top: 8px; color: var(--psw-muted); font-size: 12px; }
.psw-msg-body ul { margin: 2px 0 0; padding-left: 18px; }
.psw-msg-body a { color: var(--psw-primary); }
.psw-ai-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.psw-chip {
    padding: 6px 12px;
    border: 1px solid var(--psw-border);
    border-radius: 16px;
    background: var(--psw-bg);
    color: var(--psw-text);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.psw-chip:hover, .psw-chip:focus-visible { border-color: var(--psw-primary); outline: none; }
.psw-chip-primary { border-color: var(--psw-primary); background: var(--psw-primary); color: #FFFFFF; }
.psw-chip-primary:hover, .psw-chip-primary:focus-visible { background: var(--psw-primary-dark); }

@media (max-width: 575.98px) {
    .psw-launcher { right: 12px; bottom: 12px; }
    .psw-launcher-text { display: none; }
    .psw-launcher { width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 50%; }
    .psw-panel { right: 12px; left: 12px; bottom: 70px; width: auto; max-height: calc(100vh - 140px); }
    body .scrolltop { bottom: 70px; }
}

@media print {
    .psw { display: none !important; }
}
