/* larachat chat widget. The same on every site: a site sets its colours and the
   rounding of the corners in config/larachat.php (widget.colors, widget.radius),
   which arrive here as --lc-w-primary, --lc-w-primary-dark and --lc-w-radius. */

.lc-w {
    --lc-w-primary: #0088cc;
    --lc-w-primary-dark: #006da3;
    --lc-w-radius: 16px;
    --lc-w-z: 1080;
    --lc-w-bubble-radius: calc(var(--lc-w-radius) * 0.875);
    --lc-w-field-radius: min(24px, calc(var(--lc-w-radius) * 1.5));
    font-family: inherit;
}
.lc-w *, .lc-w *::before, .lc-w *::after { box-sizing: border-box; }
.lc-w svg { width: 1em; height: 1em; display: block; }

/* ---------- Launcher ---------- */
.lc-w-launcher {
    position: fixed; bottom: 24px; right: 24px; z-index: var(--lc-w-z);
    width: 56px; height: 56px; border-radius: 50%; border: none;
    background: var(--lc-w-primary); color: #fff; font-size: 26px;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: 0 4px 16px color-mix(in srgb, var(--lc-w-primary) 40%, transparent), 0 0 20px color-mix(in srgb, var(--lc-w-primary) 20%, transparent);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
    animation: lc-w-bounce 2.5s ease-in-out infinite;
}
.lc-w-launcher:hover { background: var(--lc-w-primary-dark); transform: scale(1.12) !important; }
.lc-w-launcher::before, .lc-w-launcher::after {
    content: ''; position: absolute; inset: -6px; border-radius: 50%; pointer-events: none;
    border: 2px solid color-mix(in srgb, var(--lc-w-primary) 50%, transparent);
    animation: lc-w-ring 2.5s ease-out infinite;
}
.lc-w-launcher::after { border-color: color-mix(in srgb, var(--lc-w-primary) 30%, transparent); animation-delay: 1.25s; }
.lc-w.lc-open .lc-w-launcher { animation: none; }
.lc-w.lc-open .lc-w-launcher::before, .lc-w.lc-open .lc-w-launcher::after { display: none; }

.lc-w-badge {
    position: absolute; top: -4px; right: -4px; z-index: 2;
    width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff;
    background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
    display: none; align-items: center; justify-content: center;
}
.lc-w-badge.is-visible { display: flex; }

.lc-w-particles { position: fixed; bottom: 10px; right: 10px; width: 84px; height: 84px; z-index: calc(var(--lc-w-z) - 1); pointer-events: none; }
.lc-w-particle {
    position: absolute; border-radius: 50%; pointer-events: none; opacity: 0;
    background: var(--lc-w-primary); box-shadow: 0 0 6px var(--lc-w-primary);
    animation: lc-w-particle 3s ease-out forwards;
}
@keyframes lc-w-particle {
    0% { opacity: 0.9; transform: translate(0, 0) scale(1); }
    50% { opacity: 0.6; }
    100% { opacity: 0; transform: translate(var(--lc-w-px), var(--lc-w-py)) scale(0); }
}

/* ---------- Nudge ---------- */
.lc-w-nudge {
    position: fixed; bottom: 96px; right: 24px; z-index: calc(var(--lc-w-z) - 1);
    max-width: 260px; padding: 10px 16px; border-radius: 12px; border-bottom-right-radius: 4px;
    background: #fff; color: #1a1a1a; font-size: 14px; font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0; visibility: hidden; transform: translateY(8px); pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s;
    animation: lc-w-bounce 2.5s ease-in-out infinite;
}
.lc-w-nudge.is-visible { opacity: 1; visibility: visible; transform: translateY(0); pointer-events: auto; cursor: pointer; }
.lc-w-nudge::after {
    content: ''; position: absolute; bottom: -6px; right: 20px; width: 12px; height: 12px;
    background: #fff; transform: rotate(45deg); box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.06);
}
.lc-w-nudge-close { display: inline-block; margin-left: 8px; opacity: 0.4; font-size: 16px; vertical-align: middle; cursor: pointer; }
.lc-w-nudge-close:hover { opacity: 0.8; }
.lc-w.lc-open .lc-w-nudge { display: none; }

@keyframes lc-w-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-8px); } 60% { transform: translateY(-4px); } }
@keyframes lc-w-ring { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(1.8); opacity: 0; } }

/* ---------- Panel ---------- */
.lc-w-panel {
    position: fixed; bottom: 92px; right: 24px; z-index: calc(var(--lc-w-z) + 1);
    width: 380px; height: 500px; max-height: calc(100vh - 112px);
    display: flex; flex-direction: column; overflow: hidden;
    border-radius: var(--lc-w-radius); background: #fff; color: #1a1a1a;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.06);
    opacity: 0; visibility: hidden; transform: translateY(20px) scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}
.lc-w-panel.is-open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.lc-w-head {
    display: flex; align-items: center; gap: 12px; flex-shrink: 0; padding: 14px 16px;
    background: linear-gradient(135deg, var(--lc-w-primary), var(--lc-w-primary-dark)); color: #fff;
}
.lc-w-head-avatar { width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, 0.2); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.lc-w-head-info { flex: 1; min-width: 0; }
.lc-w-head-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.lc-w-head-name span { font-weight: 400; font-size: 12px; opacity: 0.7; }
.lc-w-head-status { font-size: 12px; opacity: 0.85; line-height: 1.3; }
.lc-w-close {
    flex-shrink: 0; padding: 4px; border: none; border-radius: 6px; background: none; color: #fff; font-size: 22px;
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s;
}
.lc-w-close:hover { background: rgba(255, 255, 255, 0.15); }

/* ---------- Messages ---------- */
.lc-w-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.lc-w-messages::-webkit-scrollbar { width: 5px; }
.lc-w-messages::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 10px; }

.lc-w-welcome { text-align: center; padding: 20px 16px 8px; font-size: 13px; color: #888; line-height: 1.5; }

.lc-w-row { display: flex; align-items: flex-start; gap: 8px; align-self: flex-start; max-width: 88%; animation: lc-w-in 0.25s ease; }
.lc-w-avatar {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; margin-top: 18px;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.lc-w-avatar--bot { background: linear-gradient(135deg, var(--lc-w-primary), var(--lc-w-primary-dark)); color: #fff; font-size: 16px; }
.lc-w-avatar--owner { background: var(--lc-w-primary-dark); color: #fff; font-size: 13px; font-weight: 700; }
.lc-w-avatar--owner img { width: 100%; height: 100%; object-fit: cover; }
.lc-w-sender { margin-bottom: 2px; padding-left: 2px; font-size: 11px; font-weight: 600; color: #888; }

.lc-w-bubble { padding: 10px 14px; border-radius: var(--lc-w-bubble-radius); font-size: 14px; line-height: 1.45; word-wrap: break-word; animation: lc-w-in 0.25s ease; }
.lc-w-bubble--bot { background: #f0f0f0; color: #1a1a1a; border-bottom-left-radius: 4px; }
.lc-w-bubble--bot a { color: var(--lc-w-primary); text-decoration: underline; text-underline-offset: 2px; }
.lc-w-bubble--bot a:hover { color: var(--lc-w-primary-dark); }
.lc-w-bubble--visitor { align-self: flex-end; max-width: 80%; background: var(--lc-w-primary); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.lc-w-time { margin-top: 4px; font-size: 11px; opacity: 0.55; }
.lc-w-bubble--visitor .lc-w-time { text-align: right; }

@keyframes lc-w-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.lc-w-typing { display: flex; gap: 4px; padding: 10px 16px; background: #f0f0f0; border-radius: var(--lc-w-bubble-radius); border-bottom-left-radius: 4px; }
.lc-w-typing span { width: 7px; height: 7px; border-radius: 50%; background: #999; animation: lc-w-dot 1.2s ease-in-out infinite; }
.lc-w-typing span:nth-child(2) { animation-delay: 0.2s; }
.lc-w-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes lc-w-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ---------- Contact form (a message of the conversation) ---------- */
.lc-w-form {
    display: flex; flex-direction: column; gap: 10px; width: 100%; padding: 14px;
    border: 1px solid color-mix(in srgb, var(--lc-w-primary) 25%, transparent);
    border-radius: var(--lc-w-bubble-radius); background: color-mix(in srgb, var(--lc-w-primary) 5%, #fff);
    animation: lc-w-in 0.25s ease;
}
.lc-w-form-title { font-size: 14px; font-weight: 700; line-height: 1.35; }
.lc-w-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.lc-w-form-wide { grid-column: 1 / -1; }
.lc-w-form label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: #777; }
.lc-w-form input {
    width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: calc(var(--lc-w-bubble-radius) * 0.6);
    background: #fff; color: #1a1a1a; font: inherit; font-size: 14px; text-transform: none; letter-spacing: 0; outline: none;
}
.lc-w-form input:focus { border-color: var(--lc-w-primary); }
.lc-w-form-error { font-size: 12px; color: #dc2626; }
.lc-w-form-error:empty { display: none; }
.lc-w-form-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lc-w-form-foot button {
    padding: 9px 14px; border: none; border-radius: calc(var(--lc-w-bubble-radius) * 0.6);
    background: var(--lc-w-primary); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer;
}
.lc-w-form-foot button:hover { background: var(--lc-w-primary-dark); }
.lc-w-form-foot button:disabled { opacity: 0.6; cursor: wait; }
.lc-w-form-privacy { font-size: 11px; color: #888; }
.lc-w-form-privacy a { color: inherit; text-decoration: underline; }

/* ---------- Mode bar and input ---------- */
.lc-w-mode {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px;
    background: color-mix(in srgb, var(--lc-w-primary) 6%, #fff); border-top: 1px solid color-mix(in srgb, var(--lc-w-primary) 15%, transparent);
}
.lc-w-mode[hidden] { display: none; }
.lc-w-mode-text { font-size: 12px; color: #666; font-weight: 500; white-space: nowrap; }
.lc-w-mode-btn {
    display: flex; align-items: center; gap: 4px; padding: 5px 12px; white-space: nowrap; cursor: pointer;
    border: 1px solid var(--lc-w-primary); border-radius: 8px; background: color-mix(in srgb, var(--lc-w-primary) 8%, #fff);
    color: var(--lc-w-primary); font-size: 12px; font-weight: 600;
}
.lc-w-mode-btn svg { font-size: 14px; }
.lc-w-mode-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Several lines: the box grows with the text up to its max-height, then scrolls. */
.lc-w-input { display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0; padding: 12px 14px; border-top: 1px solid #e5e5e5; background: #fff; }
.lc-w-input textarea {
    flex: 1; min-height: 40px; max-height: 140px; padding: 9px 16px; resize: none; overflow-y: hidden;
    border: 1px solid #ddd; border-radius: var(--lc-w-field-radius); outline: none;
    background: #fafafa; color: #1a1a1a; font: inherit; font-size: 14px; line-height: 1.45; transition: border-color 0.2s;
}
.lc-w-input textarea:focus { border-color: var(--lc-w-primary); }
.lc-w-input textarea::placeholder { color: #999; }
.lc-w-input button {
    width: 40px; height: 40px; flex-shrink: 0; border: none; border-radius: 50%; cursor: pointer;
    background: var(--lc-w-primary); color: #fff; font-size: 20px;
    display: flex; align-items: center; justify-content: center; transition: background 0.2s, transform 0.15s;
}
.lc-w-input button:hover { background: var(--lc-w-primary-dark); }
.lc-w-input button:active { transform: scale(0.92); }

/* ---------- Dark mode: follows the page's Bootstrap colour mode (<html data-bs-theme="dark">) ---------- */
:root[data-bs-theme="dark"] .lc-w-launcher { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5); }
:root[data-bs-theme="dark"] .lc-w-badge { border-color: #1a1a2e; }
:root[data-bs-theme="dark"] .lc-w-panel { background: #1e1e2e; color: #e0e0e0; box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06); }
:root[data-bs-theme="dark"] .lc-w-messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); }
:root[data-bs-theme="dark"] .lc-w-welcome { color: #777; }
:root[data-bs-theme="dark"] .lc-w-sender { color: #999; }
:root[data-bs-theme="dark"] .lc-w-bubble--bot, :root[data-bs-theme="dark"] .lc-w-typing { background: #2a2a3e; color: #e0e0e0; }
:root[data-bs-theme="dark"] .lc-w-typing span { background: #666; }
:root[data-bs-theme="dark"] .lc-w-form { background: color-mix(in srgb, var(--lc-w-primary) 10%, #1e1e2e); }
:root[data-bs-theme="dark"] .lc-w-form label, :root[data-bs-theme="dark"] .lc-w-form-privacy { color: #999; }
:root[data-bs-theme="dark"] .lc-w-form input { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
:root[data-bs-theme="dark"] .lc-w-form input:focus { border-color: var(--lc-w-primary); }
:root[data-bs-theme="dark"] .lc-w-form-error { color: #f87171; }
:root[data-bs-theme="dark"] .lc-w-mode { background: color-mix(in srgb, var(--lc-w-primary) 12%, #1e1e2e); }
:root[data-bs-theme="dark"] .lc-w-mode-text { color: #aaa; }
:root[data-bs-theme="dark"] .lc-w-mode-btn { background: color-mix(in srgb, var(--lc-w-primary) 15%, #1e1e2e); }
:root[data-bs-theme="dark"] .lc-w-input { border-top-color: #333; background: #1e1e2e; }
:root[data-bs-theme="dark"] .lc-w-input textarea { background: #2a2a3e; border-color: #444; color: #e0e0e0; }
:root[data-bs-theme="dark"] .lc-w-input textarea:focus { border-color: var(--lc-w-primary); }
:root[data-bs-theme="dark"] .lc-w-input textarea::placeholder { color: #777; }
:root[data-bs-theme="dark"] .lc-w-nudge { background: #2a2a3e; color: #e0e0e0; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); }
:root[data-bs-theme="dark"] .lc-w-nudge::after { background: #2a2a3e; box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2); }

/* ---------- Phones: the panel takes the screen, above anything the page keeps fixed or sticky ---------- */
@media (max-width: 480px) {
    .lc-w-panel { bottom: 0; right: 0; width: 100%; height: 100dvh; max-height: none; border-radius: 0; z-index: 2147483000; }
    .lc-w-form-grid { grid-template-columns: 1fr; }
    .lc-w.lc-open .lc-w-launcher, .lc-w.lc-open .lc-w-launcher-own { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .lc-w-launcher, .lc-w-nudge, .lc-w-launcher::before, .lc-w-launcher::after { animation: none; }
}
