/* ============================================
   Superchat Live Chat Widget — floating button
   + expandable panel with on-device AI.
   All classes prefixed sc- to avoid collision.
   ============================================ */

.sc-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #fff;
}

/* ---- BUTTON ---- */
.sc-widget__btn {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    border: 2px solid #ffffff;
    background: linear-gradient(135deg, #FFD54F 0%, #FFC107 50%, #FFA000 100%);
    color: #3d2b00;
    cursor: pointer;
    box-shadow:
        0 10px 30px rgba(255, 193, 7, 0.35),
        0 4px 10px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: visible;
}
/* Faint pulsating yellow halo around the button */
.sc-widget__btn::before {
    content: "";
    position: absolute;
    inset: -8px;
    border-radius: 22px;
    background: radial-gradient(circle, rgba(255, 213, 79, 0.55) 0%, rgba(255, 193, 7, 0.25) 45%, rgba(255, 193, 7, 0) 75%);
    filter: blur(8px);
    opacity: 0.8;
    z-index: -1;
    animation: sc-halo 2.8s ease-in-out infinite;
    pointer-events: none;
}
@keyframes sc-halo {
    0%, 100% { transform: scale(1); opacity: 0.55; }
    50%      { transform: scale(1.18); opacity: 0.95; }
}
.sc-widget__btn:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 14px 40px rgba(255, 193, 7, 0.55),
        0 4px 10px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.sc-widget__btn:active { transform: translateY(0) scale(0.98); }

.sc-widget__progress-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.sc-widget__progress-bg {
    stroke: rgba(255, 255, 255, 0.35);
}
.sc-widget__progress-fg {
    stroke: #ffffff;
    stroke-dasharray: 176;
    stroke-dashoffset: 176;
    transition: stroke-dashoffset 0.4s ease;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.8));
}
.sc-widget__progress-fg.sc-widget__progress--done {
    stroke: #ffffff;
    opacity: 0;
    transition: opacity 0.5s ease 0.2s;
}

.sc-widget__logo {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sc-widget__logo img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
}

.sc-widget__pulse {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.9);
    animation: sc-pulse 2s infinite;
    display: none;
}
.sc-widget__btn[data-ready="true"] .sc-widget__pulse { display: block; }
@keyframes sc-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.9); }
    70%  { box-shadow: 0 0 0 12px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.sc-widget__tooltip {
    position: absolute;
    right: 76px;
    top: 50%;
    transform: translateY(-50%);
    background: #1a1f1a;
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.82rem;
    white-space: nowrap;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.sc-widget__tooltip::after {
    content: "";
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1a1f1a;
}
.sc-widget__btn:hover + .sc-widget__tooltip,
.sc-widget__tooltip--visible {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}
.sc-widget__tooltip--error {
    background: #7a1a1a;
    color: #ffdada;
}
.sc-widget__tooltip--error::after { border-left-color: #7a1a1a; }

/* Error state for the button */
.sc-widget__btn[data-error="true"] {
    background: linear-gradient(135deg, #EF5350 0%, #D32F2F 100%);
}
.sc-widget__btn[data-error="true"]::before {
    background: radial-gradient(circle, rgba(239, 83, 80, 0.6) 0%, rgba(211, 47, 47, 0) 75%);
}

/* ---- PANEL ---- */
.sc-widget__panel {
    position: absolute;
    right: 0;
    bottom: 80px;
    width: 370px;
    max-width: calc(100vw - 24px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #0f1310;
    border: 1px solid rgba(76, 175, 80, 0.2);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 8px 20px rgba(27, 94, 32, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    animation: sc-pop 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes sc-pop {
    from { opacity: 0; transform: scale(0.85) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
.sc-widget__panel[hidden] { display: none; }

.sc-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1B5E20, #2E7D32);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}
.sc-widget__title { display: flex; align-items: center; gap: 10px; }
.sc-widget__avatar {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: #FFC107;
    display: flex; align-items: center; justify-content: center;
    border: 1.5px solid #ffffff;
    overflow: hidden;
    flex-shrink: 0;
}
.sc-widget__avatar img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: none;
}
.sc-widget__title strong { display: block; font-size: 0.95rem; }
.sc-widget__title small { font-size: 0.7rem; opacity: 0.8; display: flex; align-items: center; gap: 4px; }
.sc-widget__title small::before {
    content: "";
    width: 6px; height: 6px; border-radius: 50%;
    background: #A5D6A7;
    box-shadow: 0 0 4px #A5D6A7;
}
.sc-widget__close {
    background: transparent; border: none; color: #fff;
    width: 30px; height: 30px;
    border-radius: 8px;
    cursor: pointer; font-size: 22px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.sc-widget__close:hover { background: rgba(255,255,255,0.15); }

.sc-widget__messages {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: #0f1310;
}
.sc-widget__messages::-webkit-scrollbar { width: 6px; }
.sc-widget__messages::-webkit-scrollbar-thumb { background: rgba(76,175,80,0.3); border-radius: 3px; }

.sc-widget__msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-wrap: break-word;
    animation: sc-fade-in 0.25s ease;
}
@keyframes sc-fade-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; } }
.sc-widget__msg--bot {
    align-self: flex-start;
    background: #1a2419;
    color: #e8f5e9;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(76,175,80,0.15);
}
.sc-widget__msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2E7D32, #388E3C);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.sc-widget__msg--typing {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
}
.sc-widget__msg--typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: #66BB6A;
    animation: sc-typing 1.4s infinite ease-in-out;
}
.sc-widget__msg--typing span:nth-child(2) { animation-delay: 0.2s; }
.sc-widget__msg--typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sc-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.sc-widget__progress-text {
    padding: 8px 14px;
    font-size: 0.75rem;
    color: #81C784;
    background: rgba(27,94,32,0.15);
    border-top: 1px solid rgba(76,175,80,0.1);
    text-align: center;
    display: none;
}
.sc-widget__progress-text[data-visible="true"] { display: block; }

.sc-widget__input-row {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(76,175,80,0.15);
    background: #141a14;
    flex-shrink: 0;
}
.sc-widget__input-row input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid rgba(76,175,80,0.25);
    background: #0f1310;
    color: #fff;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}
.sc-widget__input-row input::placeholder { color: #5a6a5a; }
.sc-widget__input-row input:focus { border-color: #4CAF50; }
.sc-widget__input-row input:disabled { opacity: 0.5; cursor: not-allowed; }
.sc-widget__input-row button {
    padding: 10px 16px;
    border-radius: 20px;
    border: none;
    background: linear-gradient(135deg, #2E7D32, #43A047);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.sc-widget__input-row button:hover:not(:disabled) { transform: translateY(-1px); }
.sc-widget__input-row button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- MOBILE ---- */
@media (max-width: 480px) {
    .sc-widget { right: 12px; bottom: 12px; }
    .sc-widget__btn { width: 56px; height: 56px; border-radius: 14px; }
    .sc-widget__logo { font-size: 24px; }
    .sc-widget__panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 90px);
        bottom: 72px;
    }
}
