/**
 * Otrax AI Chatbot Widget Styles
 * Updated to match chatbot-preview.css styling
 */

/* CSS Variables for theming */
:root {
    --widget-primary-color: #1f295d;
    --widget-border-color: #e5e7eb;
    --widget-border-color-rgb: 229, 231, 235;
    --widget-main-color: #1f295d;
    --widget-main-color-rgb: 31, 42, 93;
    --widget-body-color: #6b7280;
    --widget-heading-color: #111827;
    --widget-bg-color: #f9fafb;
    
    /* Match chatbot preview variables */
    --techwave-main-color: #1f295d;
    --techwave-main-color-rgb: 31, 42, 93;
    --techwave-border-color: #e5e7eb;
    --techwave-border-color-rgb: 229, 231, 235;
    --techwave-body-color: #6b7280;
    --techwave-heading-color: #111827;
    --techwave-bg-color: #f9fafb;
}

/* Widget Container */
.otrax-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 25px;
    line-height: 1.5;
    color: #333;
    box-sizing: border-box;
    position: fixed;
    z-index: 999999;
}

.otrax-widget * {
    box-sizing: border-box;
}

/* Widget Container Positioning */
.otrax-widget--left {
    bottom: 20px;
    left: 20px;
}

.otrax-widget--right {
    bottom: 20px;
    right: 20px;
}

/* Widget Button */
.otrax-widget__button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--widget-primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(var(--widget-primary-color-rgb), 0.3);
    transition: all 0.3s ease;
    position: absolute;
    bottom: 0;
    right: 0;
    overflow: hidden;
    z-index: 2;
}

.otrax-widget--left .otrax-widget__button {
    right: auto;
    left: 0;
}

.otrax-widget__button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(var(--widget-primary-color-rgb), 0.4);
}

.otrax-widget__button:active {
    transform: scale(0.95);
}

.otrax-widget__button-icon,
.otrax-widget__button-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 25px;
    padding: 12px;
}

/* Widget Window */
.chat__preview {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 420px;
    height: 555px;
    background: var(--widget-bg-color);
    border-radius: 25px;
    border: 1px solid var(--widget-border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.otrax-widget--left .chat__preview {
    right: auto;
    left: 0;
}

.otrax-widget--right .chat__preview {
    left: auto;
    right: 0;
}

.chat__preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--techwave-main-color) 50%, transparent 100%);
    opacity: 0.6;
}

.chat__preview--open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Keep the original animation class for JavaScript compatibility */
.otrax-widget__window--open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Position variants for chat window */
.otrax-widget--left .chat__preview {
    right: auto;
    left: 0;
}

.otrax-widget--right .chat__preview {
    left: auto;
    right: 0;
}

/* Position variants for button */
.otrax-widget--left .otrax-widget__button {
    right: auto;
    left: 0;
}

.otrax-widget--right .otrax-widget__button {
    left: auto;
    right: 0;
}

/* Header */
.chat__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 1px solid rgba(var(--techwave-border-color-rgb), 0.3);
    background: var(--preview-primary-color, var(--techwave-main-color));
    color: white;
    position: relative;
    overflow: hidden;
    transition: background-color 0.3s ease;
    height: 80px;
    min-height: 80px;
}

.chat__header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,255,255,0.05)"/><circle cx="10" cy="60" r="0.5" fill="rgba(255,255,255,0.05)"/><circle cx="90" cy="40" r="0.5" fill="rgba(255,255,255,0.05)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.chat__info {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.agent__avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.15) 100%);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    position: relative;
    overflow: hidden;
}

.agent__avatar i {
    color: white;
    transition: color 0.3s ease;
}

.agent__details h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: white;
    letter-spacing: -0.5px;
}

.agent__details p {
    font-size: 12px;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

.chat__actions {
    display: flex;
    gap: 6px;
    position: relative;
    z-index: 1;
    margin-left: auto;
}

.chat__actions .action__btn {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 12px;
}

.chat__actions .action__btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Chat Messages */
.chat__messages {
    height: 350px;
    padding: 28px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background: #f9fafb;
    position: relative;
}

.chat__messages::-webkit-scrollbar {
    width: 6px;
}

.chat__messages::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.chat__messages::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.4);
    border-radius: 3px;
    border: none;
    transition: all 0.3s ease;
}

.chat__messages::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.6);
}

.chat__messages::-webkit-scrollbar-thumb:active {
    background: rgba(156, 163, 175, 0.8);
}

/* Firefox scrollbar */
.chat__messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.4) transparent;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 88%;
    animation: messageSlideIn 0.4s ease-out;
    position: relative;
    z-index: 1;
}

.message.user__message {
    align-self: flex-end;
    flex-direction: row;
    gap: 0;
}

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

.message__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--widget-primary-color, var(--widget-main-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.message__avatar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%, rgba(0, 0, 0, 0.1) 100%);
    border-radius: 50%;
    pointer-events: none;
}

.message__avatar i {
    position: relative;
    z-index: 1;
    color: white;
    transition: color 0.3s ease;
}

.message__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    position: relative;
    z-index: 1;
}

.message__content {
    background: #ffffff;
    padding: 18px 22px;
    border-radius: 20px;
    border-top-left-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 2px 12px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(var(--widget-border-color-rgb), 0.15);
    position: relative;
    word-wrap: break-word;
    max-width: 100%;
}

.user__message .message__content {
    background: var(--widget-primary-color, var(--widget-main-color));
    color: white!important;
    border-radius: 20px;
    border-top-right-radius: 8px;
    border: none;
    box-shadow: 0 1px 3px rgba(var(--widget-primary-color-rgb, var(--widget-main-color-rgb)), 0.15), 0 2px 12px rgba(var(--widget-primary-color-rgb, var(--widget-main-color-rgb)), 0.1);
}



/* Typing Indicator */
.typing__indicator {
    opacity: 0.8;
}

.typing__content {
    background: #f0f0f0 !important;
    border: 1px solid rgba(var(--widget-border-color-rgb), 0.2) !important;
}

.typing__dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 8px 0;
}

.typing__dots span {
    width: 8px;
    height: 8px;
    background: var(--widget-body-color);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
    opacity: 0.6;
}

.typing__dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing__dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.typing__dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.6;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input */
.chat__input {
    padding: 16px 20px;
    background: #f9fafb;
    position: relative;
}

.input__container {
    position: relative;
    z-index: 1;
}

.input__wrapper {
    display: flex;
    align-items: flex-end;
    background: #ffffff;
    border: 2px solid rgba(var(--techwave-border-color-rgb), 0.4);
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
    overflow: hidden;
}

.input__wrapper:focus-within {
    border-color: var(--techwave-main-color);
    box-shadow: 0 0 0 3px rgba(var(--techwave-main-color-rgb), 0.1), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.input__container textarea {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: #575757!important;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 100px;
    transition: all 0.3s ease;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
}

.input__container textarea::placeholder {
    color: #9ca3af;
}

.input__actions {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 6px;
}

.emoji__btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--techwave-body-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.emoji__btn i{
    font-weight: 400;
    font-size: 16px;
}

.send__btn {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--techwave-main-color);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(var(--techwave-main-color-rgb), 0.2);
}

.send__btn:hover {
    background: var(--techwave-main-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--techwave-main-color-rgb), 0.3);
}

.send__btn:active {
    transform: translateY(0);
}

.send__btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send__btn i {
    font-size: 12px;
}

/* Advanced Emoji Picker */
.emoji__picker {
    position: absolute;
    bottom: 100%;
    right: 0;
    width: 100%;
    max-width: 300px;
    background: #ffffff;
    border: 2px solid rgba(var(--techwave-border-color-rgb), 0.2);
    border-radius: 20px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 6px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.emoji__picker.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}


.emoji__content {
    padding: 0;
    height: 320px;
    overflow: hidden;
    background: rgba(var(--techwave-main-color-rgb), 0.01);
    border-radius: 20px;
}

/* Custom styling for Emoji Mart */
.emoji__content .emoji-mart {
    border: none !important;
    border-radius: 20px !important;
    background: transparent !important;
    font-family: inherit !important;
}

.emoji__content .emoji-mart-search {
    padding: 12px 16px !important;
    border-bottom: 1px solid rgba(var(--techwave-border-color-rgb), 0.2) !important;
}

.emoji__content .emoji-mart-search input {
    border: 2px solid rgba(var(--techwave-border-color-rgb), 0.4) !important;
    border-radius: 12px !important;
    padding: 8px 12px !important;
    background: #ffffff !important;
    color: var(--techwave-heading-color) !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    font-family: inherit !important;
}

.emoji__content .emoji-mart-search input:focus {
    outline: none !important;
    border-color: var(--techwave-main-color) !important;
    box-shadow: 0 0 0 3px rgba(var(--techwave-main-color-rgb), 0.1) !important;
}

.emoji__content .emoji-mart-category-label {
    color: var(--techwave-heading-color) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin: 8px 0 4px 0 !important;
    padding: 0 16px !important;
}

.emoji__content .emoji-mart-scroll {
    height: 240px !important;
}

.emoji__content .emoji-mart-emoji {
    padding: 6px !important;
    font-size: 20px !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
}

.emoji__content .emoji-mart-emoji:hover {
    background: rgba(var(--techwave-main-color-rgb), 0.12) !important;
    transform: scale(1.1) !important;
}

.emoji__content .emoji-mart-emoji:active {
    transform: scale(0.9) !important;
}

.emoji__content .emoji-mart-category {
    padding: 4px !important;
}

.emoji__content .emoji-mart-category:hover {
    background: rgba(var(--techwave-main-color-rgb), 0.08) !important;
    border-radius: 6px !important;
}

.emoji__content .emoji-mart-category.active {
    background: rgba(var(--techwave-main-color-rgb), 0.15) !important;
    border-radius: 6px !important;
}

.emoji__content .emoji-mart-skin-swatches {
    border-top: 1px solid rgba(var(--techwave-border-color-rgb), 0.2) !important;
    padding: 8px 16px !important;
}

.emoji__content .emoji-mart-skin-swatch {
    border: 2px solid transparent !important;
    border-radius: 50% !important;
    transition: all 0.2s ease !important;
}

.emoji__content .emoji-mart-skin-swatch:hover {
    border-color: var(--techwave-main-color) !important;
    transform: scale(1.1) !important;
}

.emoji__content .emoji-mart-skin-swatch.active {
    border-color: var(--techwave-main-color) !important;
}

/* Powered by Otrax */
.powered__by {
    text-align: center;
    padding: 12px 28px;
    border-top: 1px solid rgba(var(--techwave-border-color-rgb), 0.2);
    position: relative;
}

.powered__by::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(var(--techwave-main-color-rgb), 0.2) 50%, transparent 100%);
}

.powered__by__text {
    font-size: 12px;
    color: #575757!important;
    font-weight: 500;
    opacity: 0.8;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Responsive */
@media (max-width: 1200px) {
    .chat__preview {
        height: 520px;
        width: 380px;
    }
    
    .chat__messages {
        height: 320px;
    }
}

@media (max-width: 768px) {
    .chat__preview {
        height: 480px;
        width: 320px;
    }
    
    .chat__messages {
        height: 280px;
        padding: 20px;
    }
    
    .chat__header {
        padding: 20px 24px;
    }
    
    .input__wrapper {
        border-radius: 14px;
    }
    
    .input__actions {
        padding: 4px;
        gap: 2px;
    }
    
    .emoji__btn,
    .send__btn {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }
    
    .emoji__picker {
        width: 100%;
        right: 0;
    }
    
    .emoji__content {
        height: 250px;
    }
    
    .powered__by {
        padding: 10px 20px;
    }
    
    .powered__by__text {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .chat__preview {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
    }
    
    .otrax-widget--bottom-left .chat__preview,
    .otrax-widget--top-left .chat__preview {
        left: 0;
        right: 0;
    }
    
    .otrax-widget--top-right .chat__preview {
        top: 80px;
        bottom: auto;
    }
    
    .chat__messages {
        height: 285px;
        padding: 16px;
    }
    
    .chat__header {
        padding: 16px 20px;
    }
    
    .input__wrapper {
        border-radius: 12px;
    }
    
    .input__actions {
        padding: 6px;
        gap: 1px;
    }
    
    .emoji__btn,
    .send__btn {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }
    
    .emoji__picker {
        width: 100%;
        right: 0;
    }
    
    .emoji__content {
        height: 220px;
    }
    
    .powered__by {
        padding: 8px 16px;
    }
    
    .powered__by__text {
        font-size: 10px;
        gap: 4px;
    }
    
    .powered__by__text::before,
    .powered__by__text::after {
        width: 8px;
        height: 8px;
    }
}

/* Animation for new messages */
.message {
    animation: messageSlideIn 0.3s ease-out;
}

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

/* Loading state */
.send__btn.loading {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Focus styles */
.input__container textarea:focus {
    outline: none;
}

/* Accessibility */
.otrax-widget__button:focus,
.send__btn:focus,
.action__btn:focus {
    outline: 2px solid var(--widget-main-color);
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .message--assistant .message__content {
        border: 2px solid #333;
    }
    
    .input__wrapper {
        border: 2px solid #333;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .otrax-widget__button,
    .send__btn,
    .chat__preview,
    .message {
        transition: none;
        animation: none;
    }
}

/* Enhanced Personalization Styles */
.otrax-widget {
    --primary-color: var(--widget-primary-color);
}

.send__btn {
    background-color: var(--widget-primary-color) !important;
    transition: background-color 0.3s ease;
}

.emoji__btn {
    color: var(--widget-primary-color) !important;
    transition: color 0.3s ease;
}

/* Real-time preview updates */
.preview__update {
    animation: previewUpdate 0.3s ease;
}

@keyframes previewUpdate {
    0% { opacity: 0.8; transform: scale(0.98); }
    100% { opacity: 1; transform: scale(1); }
} 

.message__content p {
    margin: 0 0 8px;
    font-size: 15px;
    line-height: 1.6;
    font-weight: 400;
    position: relative;
    z-index: 1;
    color: #575757!important;
}

.user__message .message__content p {
    color: white!important;
}

.message__content .message__time {
    font-size: 12px;
    color: var(--techwave-body-color);
    opacity: 0.7;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.user__message .message__content .message__time {
    color: rgba(255, 255, 255, 0.7);
} 