* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6B5CE7;
    --primary-dark: #5648c7;
    --primary-light: #8B7EF0;
    --secondary-color: #00D4AA;
    --background: #f5f7fb;
    --surface: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --border-color: #e5e7eb;
    --message-user: #6B5CE7;
    --message-bot: #f3f4f6;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.hidden {
    display: none !important;
}

/* Widget Toggle Button */
.widget-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-xl);
    transition: transform 0.3s, box-shadow 0.3s;
    z-index: 9999;
}

.widget-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 25px 30px -5px rgba(107, 92, 231, 0.4);
}

.widget-toggle .chat-icon,
.widget-toggle .close-icon {
    transition: transform 0.3s, opacity 0.3s;
}

.widget-toggle.active .chat-icon {
    transform: rotate(90deg);
    opacity: 0;
}

.widget-toggle.active .close-icon {
    transform: rotate(0deg);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ef4444;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Widget Container */
.widget-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 140px);
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Widget Header */
.widget-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.widget-header .header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.widget-header .logo {
    width: 40px;
    height: auto;
    border-radius: var(--radius-sm);
    background: white;
    padding: 3px;
}

.widget-header .header-text h1 {
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.widget-header .status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem;
}

.widget-header .status-dot {
    width: 6px;
    height: 6px;
    background: var(--secondary-color);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: white;
    transition: background 0.2s;
}

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

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

.widget-messages::-webkit-scrollbar {
    width: 4px;
}

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

.widget-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    gap: 10px;
    animation: fadeIn 0.3s ease;
}

.welcome-message .bot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--background);
    padding: 4px;
    flex-shrink: 0;
}

.welcome-message .bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.welcome-content {
    background: var(--message-bot);
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.welcome-content p {
    margin-bottom: 8px;
}

.welcome-content p:last-child {
    margin-bottom: 0;
}

.welcome-content ul {
    margin: 8px 0;
    padding-left: 18px;
}

.welcome-content li {
    margin: 4px 0;
    color: var(--text-secondary);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 10px;
    max-width: 90%;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.bot {
    align-self: flex-start;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
}

.message.bot .message-avatar {
    background: var(--background);
    padding: 3px;
}

.message.bot .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.message-content {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    line-height: 1.5;
    font-size: 0.875rem;
}

.message.user .message-content {
    background: var(--message-user);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.bot .message-content {
    background: var(--message-bot);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message.bot .message-content strong {
    color: var(--primary-color);
}

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

.message.bot .message-content li {
    margin: 3px 0;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--message-bot);
    border-radius: var(--radius-md);
    border-bottom-left-radius: 4px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-light);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Quick Actions */
.quick-actions {
    padding: 0 16px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.quick-btn {
    background: var(--background);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-lg);
    font-size: 0.75rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.quick-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Input Area */
.widget-input-container {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--surface);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--background);
    border-radius: var(--radius-md);
    padding: 6px 6px 6px 12px;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    max-height: 80px;
    padding: 6px 0;
    color: var(--text-primary);
}

.input-wrapper textarea:focus {
    outline: none;
}

.input-wrapper textarea::placeholder {
    color: var(--text-light);
}

.send-btn {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

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

.send-btn:active {
    transform: scale(0.95);
}

.send-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 420px) {
    .widget-container {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 90px;
        height: calc(100vh - 110px);
        max-height: none;
        border-radius: var(--radius-lg);
    }
    
    .widget-toggle {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}
