/*
 * Support chat widget (resources/views/livewire/support-chat.blade.php).
 * Plain CSS, served as is: every class starts with sc- so the theme's Bootstrap
 * rules and this file never collide. z-index 1001: above page content and
 * dropdowns (1000), below the Contacts slide-over (1003), the branding panel and
 * Bootstrap modals (1050) and every toast, so a panel always covers the bubble.
 */
.sc-root {
    --sc-navy: #001871;
    --sc-navy-hover: #0a2a96;
    --sc-ink: #111827;
    --sc-text: #374151;
    --sc-muted: #6b7280;
    --sc-line: #e5e7eb;
    --sc-soft: #f3f4f6;
    --sc-wash: #f9fafb;
    --sc-online: #16a34a;
    --sc-offline: #9ca3af;
    --sc-danger: #b91c1c;
    --sc-ease: cubic-bezier(0.16, 1, 0.3, 1);

    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1001;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--sc-ink);
    -webkit-font-smoothing: antialiased;
}

.sc-root *,
.sc-root *::before,
.sc-root *::after { box-sizing: border-box; }
.sc-root [x-cloak] { display: none !important; }
.sc-root p { margin: 0; }
.sc-root ::selection { background: rgba(0, 24, 113, 0.14); }

.sc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Launcher */
.sc-launcher {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 9999px;
    background: var(--sc-navy);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 24, 113, 0.28), 0 1px 3px rgba(17, 24, 39, 0.12);
    transition: background-color 150ms ease, transform 200ms var(--sc-ease);
}
.sc-launcher:hover { background: var(--sc-navy-hover); }
.sc-launcher:active { transform: scale(0.96); }
.sc-launcher:focus-visible { outline: 2px solid var(--sc-navy); outline-offset: 3px; }
.sc-launcher svg { width: 26px; height: 26px; }

.sc-launcher-dot {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 14px;
    height: 14px;
    border: 2.5px solid #fff;
    border-radius: 9999px;
    background: var(--sc-offline);
}
.sc-launcher-dot.is-online { background: var(--sc-online); }

.sc-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border: 2px solid #fff;
    border-radius: 9999px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Panel */
.sc-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    display: flex;
    flex-direction: column;
    width: 376px;
    height: min(600px, calc(100vh - 112px));
    overflow: hidden;
    border: 1px solid var(--sc-line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(17, 24, 39, 0.16), 0 3px 8px rgba(17, 24, 39, 0.08);
    transform-origin: bottom right;
}
.sc-enter, .sc-leave { transition: opacity 180ms var(--sc-ease), transform 220ms var(--sc-ease); }
.sc-enter-start { opacity: 0; transform: translateY(8px) scale(0.98); }
.sc-enter-end { opacity: 1; transform: translateY(0) scale(1); }

.sc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 12px 14px 18px;
    border-bottom: 1px solid var(--sc-line);
}
.sc-title { font-size: 15px; font-weight: 600; color: var(--sc-ink); }
.sc-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 1px !important;
    font-size: 13px;
    color: var(--sc-muted);
}
.sc-dot {
    width: 8px;
    height: 8px;
    border-radius: 9999px;
    background: var(--sc-offline);
}
.sc-dot.is-online {
    background: var(--sc-online);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
}

.sc-icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sc-muted);
    cursor: pointer;
}
.sc-icon-button:hover { background: var(--sc-soft); color: var(--sc-ink); }
.sc-icon-button:focus-visible { outline: 2px solid var(--sc-navy); outline-offset: 1px; }
.sc-icon-button svg { width: 20px; height: 20px; }

/* Body */
.sc-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}
.sc-intro { color: var(--sc-text); }
.sc-intro p + p { margin-top: 6px; }
.sc-intro-title { font-size: 16px; font-weight: 600; color: var(--sc-ink); }
.sc-offline {
    margin-top: 12px !important;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--sc-wash);
    color: var(--sc-text);
}

.sc-thread {
    margin: 18px 0 0;
    padding: 18px 0 0;
    border-top: 1px solid var(--sc-soft);
    list-style: none;
}
.sc-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: 4px;
}
.sc-message.starts-group { margin-top: 14px; }
.sc-message:first-child { margin-top: 0; }
.sc-message.is-mine { align-items: flex-end; }

.sc-author {
    margin: 0 0 3px 2px !important;
    font-size: 12px;
    font-weight: 600;
    color: var(--sc-muted);
}
.sc-bubble {
    max-width: 84%;
    padding: 8px 12px;
    border-radius: 16px 16px 16px 4px;
    background: var(--sc-soft);
    color: var(--sc-ink);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.sc-message.is-mine .sc-bubble {
    border-radius: 16px 16px 4px 16px;
    background: var(--sc-navy);
    color: #fff;
}
.sc-bubble a {
    color: var(--sc-navy);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
.sc-bubble a:hover { text-decoration-thickness: 2px; }
.sc-message.is-mine .sc-bubble a { color: #fff; }
.sc-bubble a:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; border-radius: 2px; }
.sc-time {
    display: block;
    margin: 3px 4px 0;
    font-size: 11px;
    color: var(--sc-muted);
    font-variant-numeric: tabular-nums;
}

.sc-note {
    margin-top: 14px !important;
    font-size: 13px;
    color: var(--sc-muted);
    text-align: center;
}

/* Composer */
.sc-composer {
    margin: 0;
    padding: 12px;
    border-top: 1px solid var(--sc-line);
    background: #fff;
}
.sc-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}
.sc-field { display: block; margin: 0; }
.sc-field span {
    display: block;
    margin-bottom: 3px;
    font-size: 12px;
    font-weight: 500;
    color: var(--sc-text);
}
.sc-field input,
.sc-input-row textarea {
    display: block;
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    color: var(--sc-ink);
    font: inherit;
    caret-color: var(--sc-navy);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
.sc-field input { height: 36px; padding: 0 10px; }
.sc-field input:focus,
.sc-input-row textarea:focus {
    border-color: var(--sc-navy);
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 24, 113, 0.12);
}

.sc-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}
.sc-input-row textarea {
    min-height: 40px;
    max-height: 132px;
    padding: 9px 12px;
    overflow-y: hidden;
    resize: none;
    line-height: 1.45;
}
.sc-input-row textarea::placeholder { color: #9ca3af; }

.sc-send {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--sc-navy);
    color: #fff;
    cursor: pointer;
    transition: background-color 150ms ease, opacity 150ms ease;
}
.sc-send:hover:not(:disabled) { background: var(--sc-navy-hover); }
.sc-send:focus-visible { outline: 2px solid var(--sc-navy); outline-offset: 2px; }
.sc-send:disabled { opacity: 0.35; cursor: default; }
.sc-send svg { width: 18px; height: 18px; }

.sc-error {
    margin-top: 6px !important;
    font-size: 13px;
    color: var(--sc-danger);
}
.sc-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Phones: the panel fills the width and stops above the bubble, which stays visible. */
@media (max-width: 520px) {
    .sc-root { right: 16px; bottom: 16px; }
    .sc-panel {
        position: fixed;
        top: 12px;
        right: 12px;
        bottom: 84px;
        left: 12px;
        width: auto;
        height: auto;
    }
    .sc-fields { grid-template-columns: 1fr; }
    .sc-field input,
    .sc-input-row textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .sc-enter, .sc-leave, .sc-launcher { transition: none; }
}

@media print {
    .sc-root { display: none; }
}
