#saf-chat-widget-container {
    --saf-primary: #4285f4;
    --saf-primary-dark: #3367d6;
    --saf-bg: #ffffff;
    --saf-text: #333333;
    --saf-text-light: #666666;
    --saf-border: #e0e0e0;
    --saf-user-bg: #4285f4;
    --saf-bot-bg: #f1f3f4;
    --saf-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --saf-header-gradient-start: #4285f4;
    --saf-header-gradient-end: #5a9bf4;
    --saf-user-bubble-color: #4285f4;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.saf-chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--saf-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: var(--saf-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    z-index: 99998;
}

.saf-chat-button:hover {
    transform: scale(1.05);
    background: var(--saf-primary-dark);
}

.saf-chat-button svg {
    width: 28px;
    height: 28px;
}

.saf-chat-button.left {
    right: auto;
    left: 20px;
}

.saf-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: var(--saf-widget-height, 650px);
    max-height: calc(100vh - 120px);
    background: var(--saf-bg);
    border-radius: 16px;
    box-shadow: var(--saf-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.saf-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.saf-chat-window.left {
    right: auto;
    left: 20px;
}

@media (max-width: 480px) {
    .saf-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 10px;
        left: 10px;
        border-radius: 12px;
    }
}

.saf-chat-header {
    background: linear-gradient(135deg, var(--saf-header-gradient-start), var(--saf-header-gradient-end));
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.saf-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
}

.saf-chat-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.saf-chat-header-info {
    flex: 1;
}

.saf-chat-title {
    font-weight: 600;
    font-size: 16px;
    margin: 0;
}

.saf-chat-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.saf-chat-reset,
.saf-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.saf-chat-reset:hover,
.saf-chat-close:hover {
    opacity: 1;
}

.saf-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.saf-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
}

.saf-message-user {
    background: var(--saf-user-bubble-color, var(--saf-user-bg));
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

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

.saf-message-system {
    background: #fff3cd;
    color: #856404;
    align-self: center;
    text-align: center;
    font-size: 13px;
    border-radius: 8px;
}

.saf-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--saf-bot-bg);
    border-radius: 16px;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.saf-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: saf-bounce 1.4s infinite ease-in-out;
}

.saf-typing span:nth-child(1) { animation-delay: -0.32s; }
.saf-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes saf-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.saf-message-streaming {
    position: relative;
}

.saf-streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background-color: var(--saf-text);
    margin-left: 2px;
    animation: saf-blink 1s infinite;
    vertical-align: text-bottom;
}

@keyframes saf-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.saf-chat-input-container {
    padding: 12px 16px;
    border-top: 1px solid var(--saf-border);
    display: flex;
    gap: 8px;
    background: var(--saf-bg);
    align-items: flex-end;
}

.saf-chat-input {
    flex: 1;
    border: 1px solid var(--saf-border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.4;
    overflow-y: hidden;
}

.saf-chat-input:focus {
    border-color: var(--saf-primary);
}

.saf-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--saf-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.saf-chat-send:hover {
    background: var(--saf-primary-dark);
}

.saf-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.saf-chat-send svg {
    width: 20px;
    height: 20px;
}

.saf-login-prompt {
    padding: 16px;
    background: #e3f2fd;
    text-align: center;
}

.saf-login-prompt p {
    margin: 0 0 12px;
    color: var(--saf-text);
}

.saf-login-btn {
    display: inline-block;
    padding: 10px 24px;
    background: var(--saf-primary);
    color: white;
    text-decoration: none;
    border-radius: 24px;
    font-weight: 500;
    transition: background 0.2s;
}

.saf-login-btn:hover {
    background: var(--saf-primary-dark);
    color: white;
}

.saf-livechat-notice {
    padding: 16px;
    background: #e8f5e9;
    text-align: center;
}

.saf-livechat-notice p {
    margin: 0 0 12px;
    color: var(--saf-text);
}

.saf-livechat-btn {
    display: inline-block;
    padding: 10px 24px;
    background: #4caf50;
    color: white;
    text-decoration: none;
    border-radius: 24px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-size: 14px;
}

.saf-livechat-btn:hover {
    background: #43a047;
}

.saf-member-badge {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 11px;
    margin-left: 8px;
}

/* Expand button */
.saf-chat-expand {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.saf-chat-expand:hover {
    opacity: 1;
}

/* Expanded mode */
.saf-chat-window.saf-expanded {
    width: 600px;
    height: 80vh;
    max-height: 800px;
}

@media (max-width: 680px) {
    .saf-chat-window.saf-expanded {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
    }
}

/* Copy button */
.saf-message-bot {
    position: relative;
}

.saf-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    border-radius: 4px;
    color: #666;
}

.saf-message-bot:hover .saf-copy-btn {
    opacity: 0.6;
}

.saf-copy-btn:hover {
    opacity: 1 !important;
    background: rgba(0, 0, 0, 0.1);
}

.saf-copy-btn.saf-copied {
    color: #4caf50;
    opacity: 1 !important;
}

/* Modern Layout Styles */
.saf-chat-window.saf-modern {
    display: flex;
    flex-direction: column;
}

.saf-modern-header {
    padding: 12px 16px;
}

.saf-modern-header .saf-chat-title {
    font-size: 15px;
}

.saf-modern-header .saf-chat-subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
}

.saf-status-dot {
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
    display: inline-block;
}

.saf-modern-avatar {
    width: 36px;
    height: 36px;
}

/* Upgrade bar */
.saf-upgrade-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff8e1;
    border-bottom: 1px solid #ffe082;
    font-size: 13px;
}

.saf-upgrade-icon {
    font-size: 16px;
}

.saf-upgrade-bar span:nth-child(2) {
    flex: 1;
    color: #5d4037;
}

.saf-upgrade-btn {
    padding: 6px 16px;
    background: #ff9800;
    color: white;
    text-decoration: none;
    border-radius: 16px;
    font-weight: 500;
    font-size: 12px;
    transition: background 0.2s;
}

.saf-upgrade-btn:hover {
    background: #f57c00;
    color: white;
}

/* Starter question chips */
.saf-starter-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.saf-starter-chip {
    background: white;
    border: 1px solid var(--saf-border);
    border-radius: 16px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--saf-text);
}

.saf-starter-chip:hover {
    background: var(--saf-primary);
    color: white;
    border-color: var(--saf-primary);
}

/* Contact footer */
.saf-contact-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
    border-top: 1px solid var(--saf-border);
    background: #fafafa;
}

.saf-contact-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--saf-text-light);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}

.saf-contact-item:hover {
    background: #e8e8e8;
    color: var(--saf-text);
}

.saf-contact-item svg {
    opacity: 0.7;
}

/* Modern input styling */
.saf-modern-input {
    border-top: none;
    background: #fafafa;
    padding: 16px;
}

.saf-modern-input .saf-chat-input {
    background: white;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
