/* Super Speedy Chat - Front-end Chat Bubble */

:root {
    --ssc-primary: #0073aa;
    --ssc-primary-dark: #005a87;
    --ssc-bg: #ffffff;
    --ssc-text: #333333;
    --ssc-text-light: #666666;
    --ssc-border: #e0e0e0;
    --ssc-header-bg: var(--ssc-primary);
    --ssc-visitor-bg: var(--ssc-primary);
    --ssc-visitor-text: #ffffff;
    --ssc-admin-bg: #f0f0f0;
    --ssc-admin-text: #333333;
    --ssc-system-bg: #fff3cd;
    --ssc-system-text: #856404;
    --ssc-bubble-size: 60px;
    --ssc-widget-width: 370px;
    --ssc-widget-height: 500px;
}

/* Wrapper - anchors the entire chat to the viewport corner */
#ssc-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99998;
}

/* Trigger Button */
#ssc-trigger {
    width: var(--ssc-bubble-size);
    height: var(--ssc-bubble-size);
    border-radius: 50%;
    background: var(--ssc-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
    padding: 0;
    font-size: 0;
    line-height: 1;
}

#ssc-trigger:hover {
    transform: scale(1.1);
    background: var(--ssc-primary-dark);
}

#ssc-trigger svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

#ssc-trigger .ssc-trigger-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 0;
}

#ssc-trigger .ssc-close-icon {
    display: none;
}

#ssc-trigger.ssc-open .ssc-chat-icon {
    display: none;
}

#ssc-trigger.ssc-open .ssc-close-icon {
    display: block;
}

/* Position: bottom-left */
.ssc-position-bottom-left {
    right: auto;
    left: 20px;
}

.ssc-position-bottom-left #ssc-widget {
    right: auto;
    left: 0;
}

/* Unread Badge */
#ssc-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    font-weight: bold;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 22px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#ssc-unread-badge.ssc-has-unread {
    display: flex;
}

/* Chat Widget */
#ssc-widget {
    position: absolute;
    bottom: calc(var(--ssc-bubble-size) + 10px);
    right: 0;
    width: var(--ssc-widget-width);
    height: var(--ssc-widget-height);
    max-height: calc(100vh - 120px);
    background: var(--ssc-bg);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

#ssc-widget.ssc-visible {
    display: flex;
    animation: sscBounceIn 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

/* Bounce-in animation (easeOutElastic equivalent in CSS) */
@keyframes sscBounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(40px);
    }
    50% {
        opacity: 1;
        transform: scale(1.05) translateY(-5px);
    }
    70% {
        transform: scale(0.97) translateY(2px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

@keyframes sscBounceOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.3) translateY(40px);
    }
}

#ssc-widget.ssc-hiding {
    animation: sscBounceOut 0.3s ease-in forwards;
}

/* Widget Header */
.ssc-header {
    background: var(--ssc-header-bg);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.ssc-header-image {
    height: 28px;
    width: auto;
    flex-shrink: 0;
}

.ssc-header-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    margin: 0;
}

.ssc-header-status {
    font-size: 12px;
    opacity: 0.85;
}

/* Messages Area */
.ssc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ssc-messages::-webkit-scrollbar {
    width: 6px;
}

.ssc-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ssc-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* Individual Message */
.ssc-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

.ssc-msg-visitor {
    background: var(--ssc-visitor-bg);
    color: var(--ssc-visitor-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ssc-msg-admin,
.ssc-msg-bot {
    background: var(--ssc-admin-bg);
    color: var(--ssc-admin-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ssc-msg-system {
    background: var(--ssc-system-bg);
    color: var(--ssc-system-text);
    align-self: center;
    text-align: center;
    font-size: 13px;
    border-radius: 8px;
    max-width: 90%;
}

.ssc-msg-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    opacity: 0.8;
}

.ssc-msg-text {
    margin: 0;
}

.ssc-msg-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    display: block;
}

/* Welcome message */
.ssc-welcome {
    background: var(--ssc-admin-bg);
    color: var(--ssc-admin-text);
    padding: 8px 12px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 80%;
}

/* Input Area */
.ssc-input-area {
    border-top: 1px solid var(--ssc-border);
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: var(--ssc-bg);
}

.ssc-input-area textarea {
    flex: 1;
    border: 1px solid var(--ssc-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 80px !important;
    min-height: 20px !important;
    height: 40px !important;
    padding:5px!important;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s;
}

.ssc-input-area textarea:focus {
    border-color: var(--ssc-primary);
}

.ssc-send-btn {
    background: var(--ssc-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    flex-shrink: 0;
    min-height: 36px;
}

.ssc-send-btn:hover {
    background: var(--ssc-primary-dark);
}

.ssc-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Email Prompt */
.ssc-email-prompt {
    padding: 12px 16px;
    background: #f8f9fa;
    border-top: 1px solid var(--ssc-border);
    flex-shrink: 0;
    display: none;
}

.ssc-email-prompt.ssc-visible {
    display: block;
}

.ssc-email-prompt p {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--ssc-text-light);
}

.ssc-email-prompt-form {
    display: flex;
    gap: 6px;
}

.ssc-email-prompt-form input[type="email"] {
    flex: 1;
    border: 1px solid var(--ssc-border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    outline: none;
}

.ssc-email-prompt-form button {
    background: var(--ssc-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

/* Login prompt */
.ssc-login-prompt {
    padding: 8px 16px;
    background: #eef7ff;
    border-top: 1px solid var(--ssc-border);
    font-size: 13px;
    text-align: center;
    flex-shrink: 0;
    display: none;
}

.ssc-login-prompt.ssc-visible {
    display: block;
}

.ssc-login-prompt a {
    color: var(--ssc-primary);
    font-weight: 600;
    text-decoration: none;
}

.ssc-login-prompt a:hover {
    text-decoration: underline;
}

/* Powered by / branding */
.ssc-powered {
    text-align: center;
    padding: 4px;
    font-size: 10px;
    color: #aaa;
    flex-shrink: 0;
}

/* New message highlight animation */
@keyframes sscNewMsg {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ssc-msg-new {
    animation: sscNewMsg 0.3s ease-out;
}

/* Loading dots */
.ssc-loading-dots {
    display: inline-flex;
    gap: 4px;
    padding: 8px 12px;
    align-self: flex-start;
}

.ssc-loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ccc;
    animation: sscDotPulse 1.4s infinite;
}

.ssc-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.ssc-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sscDotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Mobile responsive */
@media (max-width: 480px) {
    #ssc-wrapper {
        right: 10px;
        bottom: 10px;
    }

    .ssc-position-bottom-left {
        left: 10px;
    }

    #ssc-widget {
        position: fixed;
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: 10px;
        left: 10px;
        bottom: 80px;
        max-height: none;
        border-radius: 12px;
    }
}
