/* AVA Chatbot Public Styles */

:root {
    --ava-primary: #1B3A4B;
    --ava-secondary: #3D8B7A;
    --ava-accent: #C9A227;
    --ava-bot-bubble: #1B3A4B;
    --ava-user-bubble: #3D8B7A;
    --ava-bot-text: #FFFFFF;
    --ava-user-text: #FFFFFF;
    --ava-background: #FFFFFF;
    --ava-header-bg: #1B3A4B;
    --ava-header-text: #FFFFFF;
    --ava-bubble-size: 60px;
    --ava-bubble-color: #1B3A4B;
    --ava-send-color: #1B3A4B;
    --ava-window-width: 380px;
    --ava-window-height: 550px;
    --ava-bottom-distance: 0px;
    --ava-help-border-color: #309080;
    --ava-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --ava-shadow: 0 5px 40px rgba(0, 0, 0, 0.4);
    --ava-shadow-hover: 0 8px 50px rgba(0, 0, 0, 0.2);
    --ava-radius: 10px;
    --ava-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Container */
.ava-chatbot-container {
    position: fixed;
    bottom: calc(20px + var(--ava-bottom-distance));
    z-index: 999999;
    font-family: var(--ava-font-family);
    font-size: 14px;
    line-height: 1.5;
}

.ava-chatbot-container * {
    box-sizing: border-box;
}

.ava-position-right {
    right: 20px;
}

.ava-position-left {
    left: 20px;
}

/* Toggle Wrapper */
.ava-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 8px;
    animation: bounce 4s ease-in-out infinite;
}

.ava-position-right .ava-toggle-wrapper {
    flex-direction: row;
    justify-content: flex-end;
}

.ava-position-left .ava-toggle-wrapper {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

/* Help Bubble */
.ava-help-bubble {
    background: #f7f7f7;
    border: 2px solid var(--ava-help-border-color);
    border-top-left-radius: 25px;
    border-top-right-radius: 25px;
    border-bottom-right-radius: 5px;
    border-bottom-left-radius: 25px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.ava-help-bubble:hover {
    opacity: 0.85;
}

.ava-help-bubble.ava-hidden {
    display: none !important;
}

/* Toggle Button */
.ava-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: var(--ava-bubble-size);
    height: var(--ava-bubble-size);
    background: var(--ava-bubble-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--ava-shadow);
    transition: var(--ava-transition);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.ava-toggle-btn.ava-hidden {
    display: none !important;
}

.ava-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--ava-shadow-hover);
    animation-play-state: paused;
}

.ava-bubble-icon {
    width: 60%;
    height: 60%;
    object-fit: contain;
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ava-bubble-default {
    font-size: calc(var(--ava-bubble-size) * 0.4);
    color: var(--ava-header-text);
}

/* Chat Window */
.ava-chat-window,
.ava-history-panel,
.ava-conversation-view {
    position: absolute;
    bottom: calc(var(--ava-bubble-size) + 15px);
    width: var(--ava-window-width);
    max-width: calc(100vw - 40px);
    height: var(--ava-window-height);
    max-height: calc(100vh - 120px);
    background: var(--ava-background);
    border-radius: var(--ava-radius);
    box-shadow: var(--ava-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: avaSlideUp 0.3s ease-out;
}

.ava-position-right .ava-chat-window,
.ava-position-right .ava-history-panel,
.ava-position-right .ava-conversation-view {
    right: 0;
}

.ava-position-left .ava-chat-window,
.ava-position-left .ava-history-panel,
.ava-position-left .ava-conversation-view {
    left: 0;
}

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

/* Header */
.ava-chat-header,
.ava-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    background: var(--ava-header-bg);
    color: var(--ava-header-text);
    flex-shrink: 0;
}

.ava-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ava-header-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.ava-header-name {
    font-weight: 600;
    font-size: 15px;
}

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

.ava-header-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: inherit;
    cursor: pointer;
    transition: background 0.2s ease;
}

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

.ava-btn-danger:hover {
    background: #dc3232 !important;
}

/* Messages */
.ava-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

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

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

.ava-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.ava-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: avaMessageIn 0.3s ease-out;
}

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

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

.ava-message-user {
    align-self: flex-end;
}

.ava-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
}

.ava-message-bot .ava-message-content {
    background: var(--ava-bot-bubble);
    color: var(--ava-bot-text);
    border-bottom-left-radius: 4px;
    font-weight: 400;
    box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 1px 3px 1px;
}

.ava-message-user .ava-message-content {
    background: var(--ava-user-bubble);
    color: var(--ava-user-text);
    border-bottom-right-radius: 4px;
    font-weight: 400;
    box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 1px 3px 1px;
}

.ava-message-time {
    font-size: 11px;
    color: #575757;
    margin-top: 4px;
    padding: 0 4px;
}

.ava-message-user .ava-message-time {
    text-align: right;
}

/* Markdown Support */
.ava-message-content strong,
.ava-message-content b {
    font-weight: 700;
}

.ava-message-content em,
.ava-message-content i {
    font-style: italic;
}

.ava-message-content a {
    color: inherit;
    text-decoration: underline;
}

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

.ava-message-content li {
    margin-bottom: 4px;
}

/* Typing Indicator */
.ava-typing {
    display: flex;
    gap: 4px;
    padding: 15px 16px;
}

.ava-typing span {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    animation: avaTyping 1.4s infinite;
}

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

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

@keyframes avaTyping {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Smart Action Button */
.ava-smart-action {
    display: flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    margin-top: 10px;
    padding: 10px 18px;
    background: var(--ava-accent);
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--ava-transition);
}

.ava-smart-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Quick Replies - Grid Cards */
.ava-quick-replies {
    padding: 12px 20px 8px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.ava-quick-replies-label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.ava-quick-replies-label::before,
.ava-quick-replies-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

.ava-quick-replies-label span {
    font-size: 12px;
    color: #999;
    white-space: nowrap;
}

.ava-quick-replies-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ava-quick-reply-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #ffffff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: background 0.2s ease;
    text-align: left;
    font-family: var(--ava-font-family);
}

.ava-quick-reply-card:hover {
    background: #c5c5c5;
}

.ava-qr-icon {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    flex-shrink: 0;
}

.ava-qr-text {
    font-weight: 600;
    font-size: 13px;
    color: #333;
    line-height: 1.3;
}

/* Input Container */
.ava-input-container {
    padding: 15px 20px;
    border-top: 1px solid #cbcbcb;
    flex-shrink: 0;
}

.ava-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.ava-message-input {
    flex: 1;
    padding: 12px 18px;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    font-size: 14px;
    font-family: var(--ava-font-family);
    outline: none;
    transition: border-color 0.2s ease;
    font-weight: 400;
}

.ava-message-input:focus {
    border-color: #0000006b;
    box-shadow: rgba(0, 0, 0, 0.35) 0px 0px 3px;
}

.ava-message-input::placeholder {
    color: #999;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

.ava-send-btn {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ava-send-color);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: box-shadow 0.3s ease, opacity 0.3s ease;
    flex-shrink: 0;
    font-size: 20px;
}

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

.ava-send-btn:not(:disabled):hover {
    transform: translateY(-5px);
    box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
}

.ava-disclaimer {
    margin: 10px 0 0;
    text-align: center;
    font-size: 11px;
    color: #999;
    font-style: italic;
}

/* History Panel */
.ava-history-search {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    position: relative;
}

.ava-history-search input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 25px;
    font-size: 13px;
    font-family: var(--ava-font-family);
    outline: none;
}

.ava-history-search input:focus {
    border-color: #0000006b;
    box-shadow: rgba(0, 0, 0, 0.35) 0px 0px 3px;
}

.ava-history-search i {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 14px;
}

.ava-history-list {
    flex: 1;
    overflow-y: auto;
}

.ava-history-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ava-history-item:hover {
    background: #f9f9f9;
}

.ava-history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.ava-history-item-id {
    font-weight: 600;
    color: var(--ava-primary);
    font-size: 13px;
}

.ava-history-item-date {
    font-size: 11px;
    color: #999;
}

.ava-history-item-preview {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ava-history-item-meta {
    display: flex;
    gap: 10px;
    margin-top: 6px;
    font-size: 11px;
    color: #999;
}

.ava-history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 15px;
    border-top: 1px solid #eee;
}

.ava-pagination-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ava-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.ava-pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.ava-pagination-info {
    font-size: 13px;
    color: #666;
}

/* Loading State */
.ava-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: #999;
}

.ava-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid #e0e0e0;
    border-top-color: var(--ava-primary);
    border-radius: 50%;
    animation: avaSpin 0.8s linear infinite;
}

@keyframes avaSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty State */
.ava-empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}

/* Error State */
.ava-error {
    padding: 10px 15px;
    background: #fef0f0;
    color: #dc3232;
    font-size: 13px;
    border-radius: 8px;
    margin: 10px;
}

.ava-message-content.ava-error {
    background: #fef0f0 !important;
    color: #dc3232 !important;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ava-chatbot-container {
        bottom: calc(15px + var(--ava-bottom-distance));
    }
    
    .ava-position-right {
        right: 15px;
    }
    
    .ava-position-left {
        left: 15px;
    }
    
    .ava-chat-window,
    .ava-history-panel,
    .ava-conversation-view {
        width: calc(100vw - 30px);
        height: calc(100vh - 300px);
        max-height: none;
        bottom: calc(var(--ava-bubble-size) + 10px);
    }
    
    .ava-help-bubble {
        font-size: 12px;
        padding: 8px 14px;
    }
    
    .ava-quick-replies {
        padding: 10px 15px 6px;
    }
    
    .ava-quick-replies-grid {
        gap: 8px;
    }
    
    .ava-quick-reply-card {
        padding: 10px;
    }
    
    .ava-qr-icon {
        width: 30px;
        height: 30px;
        min-width: 30px;
        font-size: 14px;
    }
    
    .ava-qr-text {
        font-size: 12px;
    }
}

/* Print Hidden */
@media print {
    .ava-chatbot-container {
        display: none !important;
    }
}
