/*
 * Copyright (c) 2026 LP. Siagian <lamhot.info@gmail.com>. All rights reserved.
 * Restricted license: use requires prior written permission from the author.
 *
 * Selectors use the doubled class ".eps-wc.eps-wc" so host themes
 * (e.g. WordPress button/textarea styles) cannot override the widget, and
 * every property themes commonly set is reset explicitly.
 * Colours: Elbrus Power logo blue / red.
 */
.eps-wc.eps-wc {
    --eps-wc-primary: #123b63;
    --eps-wc-toggle: #d90f1e;
    --eps-wc-toggle-hover: #b80c19;
    --eps-wc-bg: #ffffff;
    --eps-wc-text: #1f2933;
    --eps-wc-muted: #6b7280;
    --eps-wc-bot: #f1f5f9;
    --eps-wc-agent: #e6f4ea;
    --eps-wc-border: #d1d5db;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: var(--eps-wc-text);
    text-align: left;
    letter-spacing: normal;
    text-transform: none;
}
.eps-wc.eps-wc *,
.eps-wc.eps-wc *::before,
.eps-wc.eps-wc *::after {
    box-sizing: border-box;
}

/* -- buttons: full reset against theme styles ---------------------------- */
.eps-wc.eps-wc button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    border: 0;
    box-shadow: none;
    outline-offset: 2px;
    font: inherit;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    text-decoration: none;
    min-width: 0;
    min-height: 0;
    cursor: pointer;
}
.eps-wc.eps-wc button:focus-visible,
.eps-wc.eps-wc textarea:focus-visible {
    outline: 2px solid var(--eps-wc-primary);
}

.eps-wc.eps-wc .eps-wc-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 999px;
    background: var(--eps-wc-toggle);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.eps-wc.eps-wc .eps-wc-toggle:hover { background: var(--eps-wc-toggle-hover); }
.eps-wc.eps-wc .eps-wc-toggle-wide { width: auto; padding: 0 20px 0 16px; }
.eps-wc.eps-wc .eps-wc-toggle-icon { font-size: 22px; line-height: 1; }
.eps-wc.eps-wc .eps-wc-toggle-label { font-size: 15px; font-weight: 600; white-space: nowrap; }

/* -- panel ---------------------------------------------------------------- */
.eps-wc.eps-wc .eps-wc-panel {
    display: flex;
    flex-direction: column;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 110px);
    margin: 0 0 12px;
    padding: 0;
    background: var(--eps-wc-bg);
    border: 0;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, .2);
    overflow: hidden;
}
.eps-wc.eps-wc .eps-wc-panel[hidden] { display: none; }
.eps-wc.eps-wc .eps-wc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 10px 12px 10px 14px;
    background: var(--eps-wc-primary);
    color: #fff;
}
.eps-wc.eps-wc .eps-wc-avatar {
    flex: none;
    width: 40px;
    height: 40px;
    margin: 0;
    border: 2px solid rgba(255, 255, 255, .9);
    border-radius: 50%;
    background: #fff;
    object-fit: cover;
}
.eps-wc.eps-wc .eps-wc-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; }
.eps-wc.eps-wc .eps-wc-status { font-size: 12px; opacity: .9; text-align: right; }
.eps-wc.eps-wc .eps-wc-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    font-size: 22px;
}
.eps-wc.eps-wc .eps-wc-close:hover { background: rgba(255, 255, 255, .15); }

/* -- messages ------------------------------------------------------------- */
.eps-wc.eps-wc .eps-wc-log {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 12px;
    overflow-y: auto;
    background: var(--eps-wc-bg);
}
.eps-wc.eps-wc .eps-wc-msg {
    max-width: 85%;
    margin: 0;
    padding: 8px 11px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.eps-wc.eps-wc .eps-wc-visitor { align-self: flex-end; background: var(--eps-wc-primary); color: #fff; }
.eps-wc.eps-wc .eps-wc-visitor a { color: #fff; }
.eps-wc.eps-wc .eps-wc-bot { align-self: flex-start; background: var(--eps-wc-bot); }
.eps-wc.eps-wc .eps-wc-agent { align-self: flex-start; background: var(--eps-wc-agent); }
.eps-wc.eps-wc .eps-wc-system {
    align-self: center;
    max-width: 95%;
    background: transparent;
    color: var(--eps-wc-muted);
    font-size: 12px;
    font-style: italic;
    text-align: center;
}
.eps-wc.eps-wc .eps-wc-name { margin: 0 0 2px; font-size: 11px; font-weight: 600; color: var(--eps-wc-muted); }
.eps-wc.eps-wc .eps-wc-body a { text-decoration: underline; overflow-wrap: anywhere; }

/* -- input form ----------------------------------------------------------- */
.eps-wc.eps-wc .eps-wc-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
    padding: 10px;
    border-top: 1px solid #e5e7eb;
    background: var(--eps-wc-bg);
}
.eps-wc.eps-wc .eps-wc-input {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    width: auto;
    height: 40px;
    min-height: 40px;
    max-height: 120px;
    margin: 0;
    padding: 9px 10px;
    border: 1px solid var(--eps-wc-border);
    border-radius: 8px;
    background: #fff;
    color: var(--eps-wc-text);
    box-shadow: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
}
.eps-wc.eps-wc .eps-wc-input:focus { border-color: var(--eps-wc-primary); box-shadow: none; }
.eps-wc.eps-wc .eps-wc-send {
    flex: none;
    width: auto;
    height: 40px;
    padding: 0 16px;
    border-radius: 8px;
    background: var(--eps-wc-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}
.eps-wc.eps-wc .eps-wc-send:hover { filter: brightness(1.1); }
.eps-wc.eps-wc .eps-wc-send:disabled { opacity: .5; cursor: wait; }

@media (max-width: 480px) {
    .eps-wc.eps-wc { right: 12px; bottom: 12px; left: 12px; }
    .eps-wc.eps-wc .eps-wc-panel { width: 100%; height: calc(100vh - 100px); }
}
