/* ═══════════════════════════════════════════════════════════════════════════
   Frande One — Sales AI Widget
   Floating chat widget for the landing page.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --sw-primary:       #3B9EFF;
    --sw-primary-dark:  #2181e2;
    --sw-primary-rgb:   59, 158, 255;
    --sw-primary-light: rgba(59, 158, 255, 0.10);
    --sw-bg: #ffffff;
    --sw-bg-secondary:  #f7f8fc;
    --sw-text:          #1e2a3a;
    --sw-text-secondary:#6b7a8d;
    --sw-border:        #e8ecf1;
    --sw-bot-bubble:    #eef4ff;
    --sw-user-bubble: var(--sw-primary);
    --sw-shadow:        0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
    --sw-radius: 16px;
    --sw-fab-size:      56px;
    --sw-panel-w: 380px;
    --sw-panel-h: 520px;
    --sw-z: 11020;
}

/* ── FAB Button ──────────────────────────────────────────────────────────── */
.sw-fab {
    position: fixed;
    bottom: 24px;
    right: 90px; /* offset from WhatsApp link area */
    z-index: var(--sw-z);
    width: var(--sw-fab-size);
    height: var(--sw-fab-size);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sw-primary), var(--sw-primary-dark));
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(59,158,255,.40), 0 2px 6px rgba(0,0,0,.10);
    transition: transform .2s, box-shadow .2s;
    animation: swFabPulse 3s ease-in-out infinite;
}
.sw-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(59,158,255,.52), 0 3px 8px rgba(0,0,0,.12);
}
.sw-fab svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}
.sw-fab-hidden { display: none !important; }

/* Notification dot */
.sw-fab-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: swDotPulse 2s ease-in-out infinite;
}

@keyframes swFabPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(59,158,255,.40), 0 2px 6px rgba(0,0,0,.10); }
    50%      { box-shadow: 0 4px 28px rgba(59,158,255,.56), 0 2px 10px rgba(0,0,0,.13); }
}
@keyframes swDotPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* ── Panel ───────────────────────────────────────────────────────────────── */
.sw-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: calc(var(--sw-z) + 1);
    width: var(--sw-panel-w);
    height: var(--sw-panel-h);
    background: var(--sw-bg);
    border-radius: var(--sw-radius);
    box-shadow: var(--sw-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.06);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    opacity: 0;
    transform: translateY(20px) scale(.95);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}
.sw-panel.sw-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.sw-header {
    background: linear-gradient(135deg, #3B9EFF 0%, #2181e2 100%);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.sw-header-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.20);
    border: 1.5px solid rgba(255,255,255,0.35);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sw-header-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}
.sw-header-info {
    flex: 1;
    min-width: 0;
}
.sw-header-info h4 {
    margin: 0;
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.2;
}
.sw-header-info small {
    font-size: .72rem;
    opacity: .7;
}
.sw-close {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sw-close:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
}
.sw-close svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ── Messages ────────────────────────────────────────────────────────────── */
.sw-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--sw-bg-secondary);
}
.sw-messages::-webkit-scrollbar { width: 4px; }
.sw-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.sw-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: .85rem;
    line-height: 1.5;
    word-wrap: break-word;
    animation: swMsgIn .2s ease-out;
}
.sw-msg a,
.sw-msg a.sw-link {
    color: var(--sw-primary);
    text-decoration: underline;
    font-weight: 500;
    word-break: break-word;
}
.sw-msg a:hover,
.sw-msg a.sw-link:hover {
    color: var(--sw-primary-dark);
    text-decoration: none;
}
.sw-msg-user a,
.sw-msg-user a.sw-link {
    color: #fff;
    text-decoration: underline;
}
.sw-msg-user a:hover {
    opacity: .85;
}
.sw-msg-bot {
    background: var(--sw-bot-bubble);
    color: var(--sw-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.sw-msg-user {
    background: var(--sw-user-bubble);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

@keyframes swMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Typing indicator */
.sw-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--sw-bot-bubble);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 60px;
}
.sw-typing span {
    width: 7px;
    height: 7px;
    background: #aab;
    border-radius: 50%;
    animation: swBounce .6s infinite alternate;
}
.sw-typing span:nth-child(2) { animation-delay: .15s; }
.sw-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes swBounce {
    to { transform: translateY(-5px); opacity: .5; }
}

/* ── Input Area ──────────────────────────────────────────────────────────── */
.sw-input-area {
    padding: 10px 12px;
    border-top: 1px solid var(--sw-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--sw-bg);
    flex-shrink: 0;
}
.sw-input {
    flex: 1;
    border: 1px solid var(--sw-border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: .85rem;
    resize: none;
    outline: none;
    max-height: 80px;
    min-height: 38px;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color .15s;
    background: var(--sw-bg);
    color: var(--sw-text);
}
.sw-input:focus {
    border-color: var(--sw-primary);
    box-shadow: 0 0 0 3px rgba(59,158,255,0.12);
}
.sw-input::placeholder {
    color: var(--sw-text-secondary);
}
.sw-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--sw-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
}
.sw-send:hover {
    background: var(--sw-primary-dark);
}
.sw-send:active {
    transform: scale(.92);
}
.sw-send:disabled {
    opacity: .5;
    cursor: not-allowed;
}
.sw-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ── Powered by ──────────────────────────────────────────────────────────── */
.sw-footer {
    text-align: center;
    padding: 4px 0 6px;
    font-size: .65rem;
    color: var(--sw-text-secondary);
    background: var(--sw-bg);
    border-top: 1px solid var(--sw-border);
    flex-shrink: 0;
}

/* ── Quick actions ───────────────────────────────────────────────────────── */
.sw-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}
.sw-quick-btn {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 8px;
    font-size: .78rem;
    border: 1px solid var(--sw-primary);
    color: var(--sw-primary);
    background: #fff;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.sw-quick-btn:hover {
    background: var(--sw-primary);
    color: #fff;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .sw-panel {
        top: max(8px, env(safe-area-inset-top));
        right: max(8px, env(safe-area-inset-right));
        bottom: max(8px, env(safe-area-inset-bottom));
        left: max(8px, env(safe-area-inset-left));
        width: auto;
        height: auto;
        max-height: none;
        border-radius: 14px;
    }
    .sw-fab {
        bottom: max(16px, calc(env(safe-area-inset-bottom) + 16px));
        right: max(16px, calc(env(safe-area-inset-right) + 16px));
        width: 52px;
        height: 52px;
    }
    .sw-fab svg { width: 24px; height: 24px; }
}

/* ── Dark mode support ───────────────────────────────────────────────────── */
[data-theme="dark"] .sw-panel {
    --sw-bg:            #1a2332;
    --sw-bg-secondary:  #111b28;
    --sw-text:          #e8edf3;
    --sw-text-secondary:#8a94a7;
    --sw-border:        #2a3b55;
    --sw-bot-bubble:    #1e2e44;
    --sw-shadow:        0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
}
[data-theme="dark"] .sw-input {
    background: #2a2a3e;
    color: #e4e4e7;
    border-color: #444;
}
[data-theme="dark"] .sw-quick-btn {
    background: #2a2a3e;
    border-color: var(--sw-primary);
    color: var(--sw-primary);
}
[data-theme="dark"] .sw-quick-btn:hover {
    background: var(--sw-primary);
    color: #fff;
}
