/* Sisira Organics AI Chatbot — frontend styles
 * Theming is driven by CSS variables set inline from plugin settings.
 */

#sisira-chatbot-root,
#sisira-chatbot-root * {
    box-sizing: border-box;
}

.scb-launcher {
    position: fixed;
    bottom: 22px;
    z-index: 999999;
    width: 62px;
    height: 62px;
    /* Oil-drop / teardrop: rounded everywhere except top-right corner. */
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    border-top-right-radius: 4px;
    border: none;
    cursor: pointer;
    background: linear-gradient(150deg, var(--scb-accent, #e8a33d) 0%, var(--scb-brand, #5a7d2a) 100%);
    color: #fff;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.25), inset -3px -4px 10px rgba(0,0,0,0.12), inset 4px 5px 12px rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    animation: scbDropFloat 4.5s ease-in-out infinite;
}
.scb-launcher::after {
    /* Glossy highlight like a liquid droplet. */
    content: "";
    position: absolute;
    top: 12px;
    left: 16px;
    width: 14px;
    height: 18px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 50%;
    transform: rotate(-20deg);
    filter: blur(1px);
    pointer-events: none;
}
.scb-launcher:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3), inset -3px -4px 10px rgba(0,0,0,0.12), inset 4px 5px 12px rgba(255,255,255,0.25);
}
.scb-launcher svg {
    width: 26px;
    height: 26px;
    fill: #fff;
    position: relative;
    z-index: 1;
}
@keyframes scbDropFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-5px); }
}
/* Mirror the teardrop tip for left-positioned launcher. */
.scb-pos-left.scb-launcher {
    border-top-right-radius: 50%;
    border-top-left-radius: 4px;
}
.scb-pos-left.scb-launcher::after { left: auto; right: 16px; transform: rotate(20deg); }
.scb-pos-right { right: 22px; }
.scb-pos-left  { left: 22px; }

.scb-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--scb-accent, #e8a33d);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    text-align: center;
    padding: 0 4px;
}

/* Panel */
.scb-panel {
    position: fixed;
    bottom: 92px;
    z-index: 999999;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.scb-panel.scb-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.scb-pos-right.scb-panel { right: 22px; }
.scb-pos-left.scb-panel  { left: 22px; }

/* Header */
.scb-header {
    background: var(--scb-brand, #5a7d2a);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.scb-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.scb-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.scb-status { font-size: 12px; opacity: 0.9; display: flex; align-items: center; gap: 5px; }
.scb-dot { width: 8px; height: 8px; border-radius: 50%; background: #6fe06f; display: inline-block; }
.scb-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.85;
    line-height: 1;
}
.scb-close:hover { opacity: 1; }

/* Messages */
.scb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f6f7f3;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.scb-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: scbIn 0.2s ease;
}
@keyframes scbIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.scb-bot {
    align-self: flex-start;
    background: #fff;
    color: #2c2c2c;
    border-bottom-left-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.scb-user {
    align-self: flex-end;
    background: var(--scb-brand, #5a7d2a);
    color: #fff;
    border-bottom-right-radius: 5px;
}
.scb-msg a { color: var(--scb-accent, #e8a33d); font-weight: 600; }
.scb-bot a { color: var(--scb-brand, #5a7d2a); }

/* Quick replies */
.scb-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 8px;
    background: #f6f7f3;
}
.scb-chip {
    border: 1px solid var(--scb-brand, #5a7d2a);
    color: var(--scb-brand, #5a7d2a);
    background: #fff;
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.scb-chip:hover {
    background: var(--scb-brand, #5a7d2a);
    color: #fff;
}

/* Typing */
.scb-typing { display: flex; gap: 4px; padding: 12px 14px; }
.scb-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #b7c39a;
    animation: scbBlink 1.2s infinite;
}
.scb-typing span:nth-child(2) { animation-delay: 0.2s; }
.scb-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes scbBlink { 0%, 60%, 100% { opacity: 0.3; } 30% { opacity: 1; } }

/* Lead form */
.scb-lead {
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.scb-lead input,
.scb-lead textarea {
    width: 100%;
    border: 1px solid #d8ddcb;
    border-radius: 9px;
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
}
.scb-lead input:focus,
.scb-lead textarea:focus { border-color: var(--scb-brand, #5a7d2a); }
.scb-lead button {
    background: var(--scb-accent, #e8a33d);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s ease;
}
.scb-lead button:hover { filter: brightness(0.95); }
.scb-lead .scb-err { color: #c0392b; font-size: 12px; min-height: 14px; }

/* Input bar */
.scb-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e6e8df;
    background: #fff;
}
.scb-input input {
    flex: 1;
    border: 1px solid #d8ddcb;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}
.scb-input input:focus { border-color: var(--scb-brand, #5a7d2a); }
.scb-send {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: none;
    background: var(--scb-brand, #5a7d2a);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.scb-send svg { width: 20px; height: 20px; fill: #fff; }
.scb-send:disabled { opacity: 0.5; cursor: not-allowed; }

.scb-foot {
    text-align: center;
    font-size: 10.5px;
    color: #9aa088;
    padding: 4px 0 8px;
    background: #fff;
}

/* Live chat: agent message bubble (distinct from bot) */
.scb-agent {
    align-self: flex-start;
    background: #eef3e3;
    color: #2c2c2c;
    border: 1px solid #cdd9b5;
    border-bottom-left-radius: 5px;
}
.scb-msg-name {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.7;
    margin-bottom: 2px;
    display: block;
}
/* System / status line */
.scb-system {
    align-self: center;
    background: transparent;
    color: #8a8f7d;
    font-size: 12px;
    font-style: italic;
    box-shadow: none;
    max-width: 90%;
    text-align: center;
}
/* Live mode banner in header */
.scb-live-banner {
    background: var(--scb-accent, #e8a33d);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    padding: 5px;
}

/* Mobile */
@media (max-width: 480px) {
    .scb-panel {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0;
    }
    .scb-launcher { bottom: 16px; }
    .scb-pos-right { right: 16px; }
    .scb-pos-left  { left: 16px; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .scb-panel, .scb-launcher, .scb-msg { transition: none; animation: none; }
}
