#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;
    min-height: var(--saf-widget-min-height, 400px);
    max-height: min(var(--saf-widget-height, 650px), calc(100vh - 120px));
    height: auto;
    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, height 0.3s ease;
}

.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;
    min-height: 120px;
}

.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-input-disabled {
    background: #f5f5f5;
    border-top: 1px solid #e0e0e0;
}

.saf-guest-login-prompt {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 20px;
    color: var(--saf-primary, #4285f4);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
}

.saf-guest-login-prompt:hover {
    background: #e3f2fd;
    color: #1565c0;
}

.saf-guest-login-prompt .saf-lock-icon {
    font-size: 16px;
}

.saf-guest-login-prompt .saf-login-arrow {
    font-size: 16px;
    transition: transform 0.2s;
}

.saf-guest-login-prompt:hover .saf-login-arrow {
    transform: translateX(3px);
}

.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);
}

/* Pop-out button */
.saf-chat-popout,
.saf-chat-info {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.saf-chat-popout:hover,
.saf-chat-info:hover {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

/* Info tooltip */
.saf-info-tooltip {
    position: absolute;
    top: 60px;
    left: 16px;
    right: 16px;
    z-index: 10;
    animation: saf-tooltip-fade 0.2s ease-out;
}

@keyframes saf-tooltip-fade {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.saf-tooltip-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 16px;
}

.saf-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.saf-tooltip-header strong {
    color: #333;
    font-size: 14px;
}

.saf-tooltip-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.saf-tooltip-close:hover {
    color: #333;
}

.saf-tooltip-text {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

.saf-tooltip-link {
    display: inline-block;
    font-size: 13px;
    color: var(--saf-primary);
    text-decoration: none;
}

.saf-tooltip-link:hover {
    text-decoration: underline;
}

/* ========================================
   REFINED MODERN DESIGN (v2.4)
   ======================================== */

/* Refined window */
.saf-chat-window.saf-refined {
    border-radius: 20px;
    overflow: hidden;
}

/* Refined header with 3 icons */
.saf-refined-header {
    background: linear-gradient(135deg, var(--saf-header-gradient-start), var(--saf-header-gradient-end));
    padding: 16px 20px;
    border-radius: 20px 20px 0 0;
}

.saf-refined-header .saf-chat-title {
    font-size: 16px;
    font-weight: 600;
}

.saf-refined-header .saf-chat-subtitle {
    font-size: 12px;
    opacity: 0.9;
}

.saf-refined-avatar {
    width: 44px;
    height: 44px;
    background: #1565c0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.saf-refined-avatar .saf-aster-logo {
    width: 44px;
    height: 44px;
}

/* Custom header logo layout */
.saf-refined-header.saf-has-custom-logo {
    flex-wrap: wrap;
    padding: 12px 16px;
}

.saf-header-logo-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
}

.saf-header-logo {
    max-width: 180px;
    max-height: 50px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: left;
}

.saf-logo-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.3;
}

.saf-has-custom-logo .saf-header-actions {
    align-self: flex-start;
    margin-top: 4px;
}

.saf-header-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.saf-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.saf-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Refined upgrade bar */
.saf-upgrade-bar.saf-refined {
    background: linear-gradient(90deg, #fff3cd, #ffeeba);
    border-bottom: 1px solid #ffc107;
    padding: 12px 20px;
}

.saf-upgrade-bar.saf-refined .saf-upgrade-icon {
    font-size: 14px;
}

.saf-upgrade-bar.saf-refined span:nth-child(2) {
    font-weight: 500;
    color: #856404;
}

.saf-upgrade-bar.saf-refined .saf-upgrade-btn {
    background: #28a745;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
}

.saf-upgrade-bar.saf-refined .saf-upgrade-btn:hover {
    background: #218838;
}

/* Login button pulse glow animation */
@keyframes saf-pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(40, 167, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 20px rgba(40, 167, 69, 0.8), 0 0 30px rgba(40, 167, 69, 0.4);
    }
}

.saf-upgrade-btn.saf-pulse-active {
    animation: saf-pulse-glow 1.5s ease-in-out 3;
}

.saf-login-btn.saf-pulse-active {
    animation: saf-pulse-glow 1.5s ease-in-out 3;
}

/* Global Announcement Banner */
.saf-global-announcement {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 13px;
    line-height: 1.4;
    border-bottom: 1px solid;
}

.saf-announcement-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.saf-announcement-text {
    flex: 1;
}

.saf-announcement-text a {
    font-weight: 600;
    text-decoration: underline;
}

.saf-announcement-info {
    background: linear-gradient(90deg, #e3f2fd, #bbdefb);
    border-color: #64b5f6;
    color: #1565c0;
}

.saf-announcement-info a {
    color: #0d47a1;
}

.saf-announcement-warning {
    background: linear-gradient(90deg, #fff8e1, #ffecb3);
    border-color: #ffc107;
    color: #856404;
}

.saf-announcement-warning a {
    color: #6d4c00;
}

.saf-announcement-maintenance {
    background: linear-gradient(90deg, #fff3e0, #ffe0b2);
    border-color: #ff9800;
    color: #e65100;
}

.saf-announcement-maintenance a {
    color: #bf360c;
}

.saf-announcement-success {
    background: linear-gradient(90deg, #e8f5e9, #c8e6c9);
    border-color: #4caf50;
    color: #2e7d32;
}

.saf-announcement-success a {
    color: #1b5e20;
}

/* Renewal Reminder Banner (v2.13.0) */
.saf-renewal-reminder-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 13px;
    line-height: 1.4;
    background: linear-gradient(90deg, #fff8e1, #ffe0b2);
    border-bottom: 1px solid #ff9800;
    color: #e65100;
}

.saf-renewal-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.saf-renewal-text {
    flex: 1;
}

.saf-renewal-link {
    flex-shrink: 0;
    padding: 4px 12px;
    background: #ff9800;
    color: white !important;
    text-decoration: none !important;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    transition: background 0.2s;
}

.saf-renewal-link:hover {
    background: #f57c00;
}

.saf-renewal-dismiss {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    padding: 0;
    background: transparent;
    border: none;
    color: #bf360c;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.saf-renewal-dismiss:hover {
    opacity: 1;
}

/* Bot avatar in messages */
.saf-bot-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
}

.saf-bot-avatar svg {
    width: 32px;
    height: 32px;
}

.saf-bot-avatar-img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 50%;
}

.saf-refined-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    margin: 0;
    border-radius: 0;
}

.saf-refined-message .saf-message-content {
    flex: 1;
    background: transparent;
    padding: 0;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}

/* Starter cards (tappable) */
.saf-starter-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 20px 20px;
}

.saf-starter-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.saf-starter-card:hover {
    border-color: var(--saf-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.saf-card-icon {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 8px;
}

.saf-card-text {
    flex: 1;
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}

/* Refined input */
.saf-refined-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #fafafa;
    border-top: 1px solid #eee;
}

.saf-refined-input .saf-chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    background: white;
    resize: none;
}

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

.saf-input-actions {
    display: flex;
    gap: 4px;
}

.saf-input-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.saf-mic-btn {
    background: #f0f0f0;
    color: #666;
}

.saf-mic-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.saf-send-btn {
    background: var(--saf-primary);
    color: white;
}

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

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

/* Refined contact footer */
.saf-contact-footer.saf-refined-footer {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 16px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.saf-contact-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: #666;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s;
}

.saf-contact-btn:hover {
    color: var(--saf-primary);
}

.saf-contact-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #e8f4fc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--saf-contact-footer-icon-color, #4285f4);
    transition: all 0.2s;
}

.saf-contact-btn:hover .saf-contact-icon {
    background: var(--saf-contact-footer-icon-color, #4285f4);
    color: white;
}

.saf-contact-label {
    font-size: 12px;
    font-weight: 500;
}

/* Messages area for refined layout */
.saf-refined .saf-chat-messages {
    background: #f5f5f5;
    padding: 0;
}

/* ========================================
   OPTIONS MENU (v2.5.4)
   ======================================== */

.saf-options-menu {
    position: absolute;
    top: 60px;
    right: 16px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 180px;
    animation: saf-menu-fade 0.15s ease-out;
}

@keyframes saf-menu-fade {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.saf-menu-section {
    padding: 12px 16px;
}

.saf-menu-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.saf-size-options {
    display: flex;
    gap: 6px;
}

.saf-size-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 12px;
    border: 1px solid #ddd;
    background: #f8f8f8;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    color: #555;
}

.saf-size-btn:hover {
    border-color: #1976d2;
    background: #e3f2fd;
}

.saf-size-btn.active {
    border-color: #1976d2;
    background: #1976d2;
    color: white;
}

.saf-menu-divider {
    height: 1px;
    background: #eee;
    margin: 0;
}

.saf-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    text-align: left;
    transition: background 0.15s;
}

.saf-menu-item:hover {
    background: #f5f5f5;
}

.saf-menu-item:last-child {
    border-radius: 0 0 12px 12px;
}

.saf-menu-item svg {
    color: #666;
}

/* Widget width classes */
.saf-chat-window.saf-width-compact {
    width: 320px !important;
}

.saf-chat-window.saf-width-normal {
    width: 380px !important;
}

.saf-chat-window.saf-width-wide {
    width: 450px !important;
}

.saf-chat-window.saf-width-extra-wide {
    width: 1100px !important;
}

/* Microphone active state */
.saf-mic-btn.saf-mic-active {
    background: #ff4444 !important;
    animation: saf-mic-pulse 1s infinite;
}

.saf-mic-btn.saf-mic-active svg {
    fill: white;
}

@keyframes saf-mic-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Mobile responsiveness for width */
@media (max-width: 480px) {
    .saf-chat-window.saf-width-compact,
    .saf-chat-window.saf-width-normal,
    .saf-chat-window.saf-width-wide,
    .saf-chat-window.saf-width-extra-wide {
        width: calc(100vw - 20px) !important;
        max-width: none !important;
    }
}

/* Tablet responsiveness for extra wide */
@media (max-width: 1200px) {
    .saf-chat-window.saf-width-extra-wide {
        width: calc(100vw - 40px) !important;
        max-width: 1100px !important;
    }
}

/* Privacy controls */
.saf-toggle-btn {
    position: relative;
}

.saf-toggle-btn.active {
    color: #1976D2;
}

.saf-toggle-btn.active svg {
    color: #1976D2;
}

.saf-danger-btn {
    color: #d32f2f;
}

.saf-danger-btn:hover {
    background: #ffebee !important;
}

.saf-danger-btn svg {
    color: #d32f2f;
}

/* Retention period row */
.saf-retention-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: default;
}

.saf-retention-row span {
    flex-shrink: 0;
}

.saf-retention-row.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.saf-retention-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    min-width: 100px;
}

.saf-retention-select:hover:not(:disabled) {
    border-color: #1976D2;
}

.saf-retention-select:focus {
    outline: none;
    border-color: #1976D2;
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
}

.saf-retention-select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

/* Personalized greeting */
.saf-personalized-greeting {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
}

/* Privacy Consent Modal */
.saf-privacy-modal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    border-radius: 16px;
}

.saf-privacy-modal-content {
    background: white;
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: saf-modal-appear 0.3s ease-out;
}

@keyframes saf-modal-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.saf-privacy-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 18px;
    color: #1976D2;
}

.saf-privacy-modal-header svg {
    color: #1976D2;
}

.saf-privacy-modal-body {
    margin-bottom: 20px;
}

.saf-privacy-modal-body p {
    margin: 0 0 12px 0;
    line-height: 1.5;
    color: #333;
    font-size: 14px;
}

.saf-privacy-modal-body .saf-privacy-note {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.saf-privacy-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.saf-privacy-btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.saf-privacy-btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.saf-privacy-btn-secondary:hover {
    background: #e0e0e0;
}

.saf-privacy-btn-primary {
    background: #1976D2;
    color: white;
}

.saf-privacy-btn-primary:hover {
    background: #1565C0;
}

.saf-personalized-greeting .saf-message-content {
    font-style: italic;
}

/* Chat message typography - scaled down headings for chat context */
.saf-message h1,
.saf-message-content h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 12px 0 8px 0;
    line-height: 1.3;
    color: #1a1a1a;
}

.saf-message h2,
.saf-message-content h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 10px 0 6px 0;
    line-height: 1.3;
    color: #2a2a2a;
}

.saf-message h3,
.saf-message-content h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 8px 0 4px 0;
    line-height: 1.3;
    color: #333;
}

.saf-message h4,
.saf-message h5,
.saf-message h6,
.saf-message-content h4,
.saf-message-content h5,
.saf-message-content h6 {
    font-size: 14px;
    font-weight: 600;
    margin: 6px 0 4px 0;
    line-height: 1.4;
    color: #444;
}

.saf-message p,
.saf-message-content p {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.saf-message p:last-child,
.saf-message-content p:last-child {
    margin-bottom: 0;
}

.saf-message ul,
.saf-message ol,
.saf-message-content ul,
.saf-message-content ol {
    margin: 6px 0;
    padding-left: 20px;
}

.saf-message li,
.saf-message-content li {
    margin: 4px 0;
    line-height: 1.5;
}

.saf-message blockquote,
.saf-message-content blockquote {
    margin: 8px 0;
    padding: 8px 12px;
    border-left: 3px solid #1976D2;
    background: #f5f5f5;
    border-radius: 0 8px 8px 0;
}

/* KaTeX math formula styles */
.saf-katex-block {
    display: block;
    margin: 12px 0;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    overflow-x: auto;
    text-align: center;
}

.saf-katex-inline {
    display: inline;
    padding: 0 2px;
}

.saf-message .katex,
.saf-message-content .katex {
    font-size: 1.1em;
}

.saf-katex-block .katex {
    font-size: 1.2em;
}

.saf-katex-block .katex-display {
    margin: 0;
}

.saf-message code,
.saf-message-content code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 13px;
}

.saf-message pre,
.saf-message-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.saf-message pre code,
.saf-message-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.saf-message hr,
.saf-message-content hr {
    margin: 12px 0;
    border: none;
    border-top: 1px solid #e0e0e0;
}

/* Citations Section */
.saf-citations-section {
    margin-top: 12px;
    border-top: 1px solid #e0e0e0;
    padding-top: 10px;
}

.saf-citations-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f5f7fa;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #555;
    transition: background 0.2s, border-color 0.2s;
    width: 100%;
    text-align: left;
}

.saf-citations-toggle:hover {
    background: #e8ecf0;
    border-color: #d0d4da;
}

.saf-citations-icon {
    font-size: 14px;
}

.saf-citations-label {
    flex: 1;
    font-weight: 500;
}

.saf-citations-arrow {
    font-size: 10px;
    color: #888;
    transition: transform 0.2s;
}

.saf-citations-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.saf-citation-item {
    padding: 10px 12px;
    background: #fafbfc;
    border: 1px solid #e8ebef;
    border-radius: 8px;
    transition: background 0.2s, border-color 0.2s;
}

.saf-citation-item:hover {
    background: #f0f4f8;
    border-color: #1976D2;
}

.saf-citation-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #1976D2;
    font-weight: 500;
    font-size: 13px;
}

.saf-citation-link:hover {
    text-decoration: underline;
}

.saf-citation-icon {
    font-size: 14px;
}

.saf-citation-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saf-citation-url {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #888;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saf-citation-no-link {
    color: #555;
    cursor: default;
}

.saf-citation-no-link:hover {
    text-decoration: none;
}

/* Inline Citations */
.saf-inline-citation {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin: 0 2px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: var(--saf-primary, #1976D2);
    border-radius: 50%;
    cursor: pointer;
    vertical-align: super;
    line-height: 1;
    transition: background 0.2s, transform 0.2s;
}

.saf-inline-citation:hover {
    background: var(--saf-primary-dark, #1565C0);
    transform: scale(1.1);
}

.saf-citation-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: normal;
    white-space: normal;
    min-width: 200px;
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100010;
    pointer-events: none;
    text-align: left;
}

.saf-citation-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

.saf-citation-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.saf-citation-tooltip-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: #fff;
    line-height: 1.3;
}

.saf-citation-tooltip-url {
    font-size: 11px;
    color: #aaa;
    word-break: break-all;
    line-height: 1.3;
}

/* Mobile adjustments for inline citations */
@media (max-width: 480px) {
    .saf-inline-citation {
        width: 16px;
        height: 16px;
        font-size: 10px;
    }
    
    .saf-citation-tooltip {
        min-width: 160px;
        max-width: 260px;
        font-size: 11px;
        padding: 8px 12px;
    }
}

/* Verify Button (v2.10.21) */
.saf-verify-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    margin-right: 8px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #d0d0d0;
    border-radius: 16px;
    color: #666;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.saf-verify-btn:hover {
    background: #f5f5f5;
    border-color: #bbb;
    color: #333;
}

.saf-verify-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.saf-verify-btn svg {
    flex-shrink: 0;
}

.saf-verify-loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ddd;
    border-top-color: #666;
    border-radius: 50%;
    animation: saf-spin 0.8s linear infinite;
}

@keyframes saf-spin {
    to { transform: rotate(360deg); }
}

/* Claims Panel */
.saf-claims-panel {
    margin-top: 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.saf-claims-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #f0f0f0;
    border-bottom: 1px solid #e0e0e0;
}

.saf-claims-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.saf-claims-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.saf-claims-close:hover {
    color: #333;
}

.saf-claims-empty {
    padding: 16px;
    text-align: center;
    color: #888;
    font-size: 13px;
}

.saf-claims-list {
    padding: 8px;
}

.saf-claim-item {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: #fff;
    border-radius: 8px;
    border-left: 3px solid #ddd;
}

.saf-claim-item:last-child {
    margin-bottom: 0;
}

.saf-claim-verified-item {
    border-left-color: #4caf50;
}

.saf-claim-unverified-item {
    border-left-color: #ff9800;
}

.saf-claim-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.saf-claim-icon {
    flex-shrink: 0;
}

.saf-claim-icon.saf-claim-verified {
    color: #4caf50;
}

.saf-claim-icon.saf-claim-unverified {
    color: #ff9800;
}

.saf-claim-status-text {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.saf-claim-verified-item .saf-claim-status-text {
    color: #4caf50;
}

.saf-claim-unverified-item .saf-claim-status-text {
    color: #ff9800;
}

.saf-claim-text {
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    margin-bottom: 6px;
}

.saf-claim-explanation {
    font-size: 12px;
    color: #666;
    font-style: italic;
    line-height: 1.4;
    margin-bottom: 6px;
}

.saf-claim-sources {
    margin-top: 6px;
}

.saf-claim-source-link {
    display: block;
    font-size: 11px;
    color: var(--saf-primary, #1976D2);
    text-decoration: none;
    margin-bottom: 4px;
    word-break: break-word;
}

.saf-claim-source-link:hover {
    text-decoration: underline;
}

/* Mobile adjustments for verify feature */
@media (max-width: 480px) {
    .saf-verify-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .saf-claims-panel {
        margin-top: 10px;
    }
    
    .saf-claim-text {
        font-size: 12px;
    }
    
    .saf-claim-explanation {
        font-size: 11px;
    }
}

/* Document Analyst - File Upload Styles */
.saf-attach-btn {
    color: var(--saf-text-light, #666);
    transition: color 0.2s ease, transform 0.2s ease;
}

.saf-attach-btn:hover {
    color: var(--saf-primary, #4285f4);
    transform: scale(1.1);
}

.saf-attach-btn.has-file {
    color: var(--saf-primary, #4285f4);
}

.saf-file-input {
    display: none !important;
}

.saf-file-preview {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f0f7ff 0%, #e8f4fd 100%);
    border: 1px solid #d0e3f5;
    border-radius: 8px;
    margin: 8px 12px 0 12px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.saf-file-preview-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.saf-file-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.saf-file-name {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.saf-file-remove {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.saf-file-remove:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #d32f2f;
}

/* User message with file attachment */
.saf-message.user .saf-message-content {
    white-space: pre-wrap;
}

/* User Feedback Buttons (v2.11.0) */
.saf-feedback-buttons {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    margin-left: 8px;
}

.saf-feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s ease;
}

.saf-feedback-btn:hover {
    background: #f5f5f5;
    border-color: #bbb;
    color: #555;
}

.saf-feedback-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.saf-feedback-btn svg {
    flex-shrink: 0;
}

.saf-feedback-btn img {
    max-width: 16px;
    max-height: 16px;
    object-fit: contain;
}

/* Selected feedback state */
.saf-feedback-btn.saf-feedback-selected {
    border-color: #4285f4;
    color: #4285f4;
    background: rgba(66, 133, 244, 0.1);
}

.saf-feedback-positive.saf-feedback-selected {
    border-color: #4caf50;
    color: #4caf50;
    background: rgba(76, 175, 80, 0.1);
}

.saf-feedback-negative.saf-feedback-selected {
    border-color: #f44336;
    color: #f44336;
    background: rgba(244, 67, 54, 0.1);
}

/* Submitted state - more subtle */
.saf-feedback-btn.saf-feedback-submitted {
    opacity: 0.8;
}

/* Mobile adjustments for feedback buttons */
@media (max-width: 480px) {
    .saf-feedback-buttons {
        margin-top: 8px;
        margin-left: 4px;
    }
    
    .saf-feedback-btn {
        width: 26px;
        height: 26px;
    }
    
    .saf-feedback-btn svg {
        width: 14px;
        height: 14px;
    }
}

/* Clickable Follow-up Question Chips (v2.11.1) */
.saf-followup-container {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.saf-followup-label {
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 500;
}

.saf-followup-chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.saf-followup-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f4ff 100%);
    border: 1px solid rgba(66, 133, 244, 0.2);
    border-radius: 20px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    line-height: 1.4;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.saf-followup-chip:hover {
    background: linear-gradient(135deg, #e8f0fe 0%, #d2e3fc 100%);
    border-color: rgba(66, 133, 244, 0.4);
    box-shadow: 0 2px 6px rgba(66, 133, 244, 0.15);
    transform: translateY(-1px);
}

.saf-followup-chip:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.saf-followup-chip::before {
    content: '→';
    color: #4285f4;
    font-weight: bold;
    flex-shrink: 0;
}

/* Mobile adjustments for follow-up chips */
@media (max-width: 480px) {
    .saf-followup-container {
        margin-top: 12px;
        padding-top: 10px;
    }
    
    .saf-followup-label {
        font-size: 12px;
    }
    
    .saf-followup-chip {
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 16px;
    }
}
