#sab-bot-container {
    max-width: 480px;
    margin: 30px auto;
    border: none;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 10px 40px rgba(15, 37, 87, 0.12);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    position: relative;
    overflow: hidden;
}

/* Accessibility improvements */
#sab-bot-container:focus-within {
    outline: 2px solid #0f2557;
    outline-offset: 2px;
}

.sab-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

#sab-bot-header {
    background: linear-gradient(135deg, #0f2557 0%, #1a3a6b 100%);
    color: white;
    padding: 28px 24px;
    text-align: center;
    border-bottom: none;
}

#sab-bot-header h3 {
    margin: 0 0 8px 0;
    font-size: 1.6em;
    font-weight: 700;
    letter-spacing: -0.03em;
}

#sab-bot-header p {
    margin: 0;
    opacity: 0.95;
    font-size: 0.98em;
    font-weight: 400;
    line-height: 1.5;
}

#sab-chat-messages {
    height: 480px;
    overflow-y: auto;
    padding: 28px 24px;
    background: #fafbfc;
    scroll-behavior: smooth;
}

/* Improve focus visibility for keyboard navigation */
#sab-chat-messages:focus {
    outline: 2px solid #0f2557;
    outline-offset: -2px;
}

/* Custom scrollbar */
#sab-chat-messages::-webkit-scrollbar {
    width: 8px;
}

#sab-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#sab-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#sab-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.sab-message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-start;
    animation: fadeInMessage 0.3s ease-in;
}

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

.sab-message.user {
    justify-content: flex-end;
}

.sab-message.bot {
    justify-content: flex-start;
}

.sab-message-content {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
}

.sab-message.user .sab-message-content {
    background: linear-gradient(135deg, #0f2557 0%, #1a3a6b 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(15, 37, 87, 0.2);
}

.sab-message.bot .sab-message-content {
    background: white;
    color: #2c3e50;
    border: 1px solid #e8eaed;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.sab-message.bot::before {
    display: none;
}

#sab-chat-input {
    display: flex;
    padding: 20px 24px;
    border-top: 1px solid #e8eaed;
    background: white;
    gap: 12px;
}

#sab-message-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e8eaed;
    border-radius: 12px;
    outline: none;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: #fafbfc;
}

#sab-message-input:focus {
    border-color: #0f2557;
    background: white;
    box-shadow: 0 0 0 4px rgba(15, 37, 87, 0.08);
}

#sab-send-btn {
    background: linear-gradient(135deg, #0f2557 0%, #1a3a6b 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(15, 37, 87, 0.25);
}

#sab-send-btn:hover {
    background: linear-gradient(135deg, #1a3a6b 0%, #0f2557 100%);
    box-shadow: 0 6px 16px rgba(15, 37, 87, 0.35);
    transform: translateY(-2px);
}

#sab-send-btn:active {
    transform: translateY(0);
}

#sab-send-btn:disabled {
    background: #e8eaed;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

#sab-quick-replies {
    padding: 0 24px 24px;
    background: #fafbfc;
}

.sab-quick-reply {
    display: inline-block;
    background: white;
    border: 2px solid #0f2557;
    color: #0f2557;
    padding: 11px 22px;
    margin: 6px 6px 0 0;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: 0 2px 6px rgba(15, 37, 87, 0.1);
}

.sab-quick-reply:hover,
.sab-quick-reply:focus {
    background: linear-gradient(135deg, #0f2557 0%, #1a3a6b 100%);
    color: white;
    border-color: #0f2557;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 37, 87, 0.25);
}

.sab-quick-reply:focus {
    outline: 2px solid #1a3a6b;
    outline-offset: 2px;
}

.sab-quick-reply:active {
    transform: translateY(0);
}

.sab-typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 80px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.sab-typing-dots {
    display: flex;
    gap: 4px;
}

.sab-typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: sab-typing 1.4s infinite ease-in-out;
}

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

@keyframes sab-typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.sab-welcome-message {
    text-align: center;
    padding: 30px 20px;
    color: #666;
}

.sab-welcome-message h4 {
    margin: 0 0 10px 0;
    color: #333;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    #sab-bot-container {
        margin: 10px;
        border-radius: 0;
        max-width: 100%;
    }
    
    #sab-bot-header {
        border-radius: 0;
    }
    
    #sab-chat-messages {
        height: 350px;
        padding: 15px;
    }
    
    .sab-message-content {
        max-width: 85%;
        font-size: 13px;
    }
    
    #sab-chat-input {
        padding: 12px;
    }
    
    #sab-message-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .sab-quick-reply {
        font-size: 14px;
        padding: 10px 16px;
        margin: 5px 3px;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    #sab-chat-messages {
        scroll-behavior: auto;
    }
}

/* Error state styling */
.sab-error-message {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.sab-error-message::before {
    content: '!';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #ffc107;
    color: white;
    border-radius: 50%;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.sab-retry-button {
    background: #ffc107;
    color: #000;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: auto;
}

.sab-retry-button:hover {
    background: #e0a800;
}

/* Loading skeleton for better perceived performance */
.sab-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    height: 16px;
    margin: 4px 0;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Connection status indicator */
.sab-connection-status {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #46b450;
}

.sab-connection-status.disconnected {
    background: #dc3232;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
#sab-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#sab-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#sab-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#sab-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}