/* Modern Chatbot Container */
.fnnrc-chatbot-container {
    position: fixed !important;
    bottom: 20px !important;
    width: 420px;
    max-width: calc(100vw - 40px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 9999 !important;
    display: none; /* Hidden by default, shown after page load */
    flex-direction: column;
    max-height: 650px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
    /* Ensure it's not affected by parent containers */
    transform: none !important;
}

.fnnrc-chatbot-container.fnnrc-loaded {
    display: flex !important;
    opacity: 1 !important;
    animation: fnnrc-fade-in 0.4s ease-in-out;
}

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

.fnnrc-chatbot-container.fnnrc-minimized {
    max-height: 70px;
    height: auto;
    overflow: hidden;
}

.fnnrc-chatbot-container.fnnrc-minimized .fnnrc-chatbot-body {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    overflow: hidden;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.fnnrc-chatbot-container:not(.fnnrc-minimized) .fnnrc-chatbot-body {
    display: flex !important;
    height: 580px !important;
}

.fnnrc-chatbot-container.fnnrc-focused {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

/* Header */
.fnnrc-chatbot-header {
    background: linear-gradient(135deg, var(--fnnrc-primary-color, #667eea) 0%, var(--fnnrc-secondary-color, #764ba2) 100%);
    color: #fff;
    padding: 18px 20px;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0;
    gap: 12px;
}

.fnnrc-chatbot-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
}

.fnnrc-chatbot-header-content {
    display: flex !important;
    align-items: center !important;
    gap: 12px;
    flex: 1;
    min-width: 0; /* Allow flex item to shrink */
    overflow: hidden; /* Prevent content overflow */
    margin: 0;
    padding: 0;
}

.fnnrc-chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.fnnrc-chatbot-avatar svg {
    width: 24px;
    height: 24px;
    color: #fff;
}

.fnnrc-chatbot-header-text {
    flex: 1;
    min-width: 0;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    align-items: flex-start;
    justify-content: center;
}

.fnnrc-chatbot-header-text h3 {
    margin: 0;
    padding: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.fnnrc-chatbot-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.fnnrc-chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    animation: fnnrc-pulse 2s ease-in-out infinite;
}

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

.fnnrc-chatbot-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    min-width: 36px;
    margin-left: 12px;
    position: relative;
}

.fnnrc-chatbot-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.fnnrc-chatbot-toggle svg {
    width: 20px;
    height: 20px;
}

.fnnrc-chatbot-container.fnnrc-minimized .fnnrc-icon-minimize {
    display: none;
}

.fnnrc-chatbot-container.fnnrc-minimized .fnnrc-icon-maximize {
    display: block !important;
}

/* Body */
.fnnrc-chatbot-body {
    display: flex;
    flex-direction: column;
    height: 580px;
    background: #f8f9fa;
    overflow: hidden;
}


.fnnrc-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.fnnrc-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.fnnrc-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Messages */
.fnnrc-message {
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    animation: fnnrc-message-enter 0.3s ease-out;
    opacity: 0;
    animation-fill-mode: forwards;
}

.fnnrc-message-enter {
    animation: fnnrc-message-enter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
}

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

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

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

.fnnrc-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--fnnrc-primary-color, #667eea) 0%, var(--fnnrc-secondary-color, #764ba2) 100%);
    color: #fff;
    margin-top: 4px;
}

.fnnrc-message-user .fnnrc-message-avatar {
    order: 2;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.fnnrc-message-avatar svg {
    width: 18px;
    height: 18px;
}

.fnnrc-message-content-wrapper {
    flex: 1;
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.fnnrc-message-user .fnnrc-message-content-wrapper {
    align-items: flex-end;
}

.fnnrc-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.fnnrc-message-user .fnnrc-message-content {
    background: linear-gradient(135deg, var(--fnnrc-primary-color, #667eea) 0%, var(--fnnrc-secondary-color, #764ba2) 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.fnnrc-message-bot .fnnrc-message-content {
    background: #ffffff;
    color: #333;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.fnnrc-message-time {
    font-size: 11px;
    color: #9ca3af;
    padding: 0 4px;
}

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

/* Loading State */
.fnnrc-message-content.fnnrc-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
}

.fnnrc-typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

.fnnrc-typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: fnnrc-typing 1.4s ease-in-out infinite;
}

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

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

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

.fnnrc-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--fnnrc-primary-color, #667eea);
    border-radius: 50%;
    animation: fnnrc-spin 0.8s linear infinite;
}

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

/* Input Area */
.fnnrc-chatbot-input-area {
    padding: 16px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.fnnrc-files-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    max-height: 100px;
    overflow-y: auto;
}

.fnnrc-file-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f3f4f6;
    border-radius: 12px;
    font-size: 12px;
    color: #374151;
}

.fnnrc-file-preview img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
}

.fnnrc-file-preview .fnnrc-file-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fnnrc-file-preview .fnnrc-file-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.fnnrc-file-preview .fnnrc-file-remove:hover {
    background: rgba(239, 68, 68, 0.1);
}

.fnnrc-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    background: #f3f4f6;
    border-radius: 24px;
    padding: 4px 4px 4px 8px;
    transition: all 0.2s ease;
}

.fnnrc-input-wrapper:focus-within {
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    border: 1px solid var(--fnnrc-primary-color, #667eea);
}

#fnnrc-chatbot-input {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    color: #333;
    font-family: inherit;
}

#fnnrc-chatbot-input::placeholder {
    color: #9ca3af;
}

#fnnrc-chatbot-send,
#fnnrc-chatbot-live-agent {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--fnnrc-primary-color, #667eea) 0%, var(--fnnrc-secondary-color, #764ba2) 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

#fnnrc-chatbot-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#fnnrc-chatbot-send:active:not(:disabled) {
    transform: scale(0.95);
}

#fnnrc-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#fnnrc-chatbot-send svg {
    width: 18px;
    height: 18px;
}

#fnnrc-chatbot-attach {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    color: #6b7280;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#fnnrc-chatbot-attach:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--fnnrc-primary-color, #667eea);
}

#fnnrc-chatbot-attach svg {
    width: 20px;
    height: 20px;
}

#fnnrc-chatbot-live-agent {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    color: #d63638;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#fnnrc-chatbot-live-agent:hover {
    background: rgba(214, 54, 56, 0.1);
    color: #b32d2e;
    transform: scale(1.1);
}

#fnnrc-chatbot-live-agent svg {
    width: 20px;
    height: 20px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .fnnrc-chatbot-container {
        width: calc(100vw - 20px);
        max-width: 420px;
        bottom: 10px;
        border-radius: 16px;
        max-height: calc(100vh - 20px);
    }
    
    .fnnrc-chatbot-container:not(.fnnrc-minimized) .fnnrc-chatbot-body {
        height: calc(100vh - 140px) !important;
        max-height: calc(100vh - 140px) !important;
    }
    
    .fnnrc-chatbot-header {
        padding: 14px 16px;
    }
    
    .fnnrc-chatbot-header-text h3 {
        font-size: 14px;
    }
    
    .fnnrc-chatbot-status {
        font-size: 11px;
    }
    
    .fnnrc-message-content {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .fnnrc-input-wrapper {
        padding: 8px;
    }
    
    #fnnrc-chatbot-input {
        font-size: 14px;
        padding: 8px 12px;
    }
    
    #fnnrc-chatbot-send,
    #fnnrc-chatbot-attach,
    #fnnrc-chatbot-live-agent {
        width: 32px;
        height: 32px;
    }
    
    .fnnrc-message-avatar {
        width: 28px;
        height: 28px;
    }
}

@media (max-width: 480px) {
    .fnnrc-chatbot-container {
        width: calc(100vw - 16px);
        bottom: 8px;
        border-radius: 12px;
    }
    
    .fnnrc-chatbot-container:not(.fnnrc-minimized) .fnnrc-chatbot-body {
        height: calc(100vh - 120px) !important;
        max-height: calc(100vh - 120px) !important;
    }
    
    .fnnrc-chatbot-header {
        padding: 12px 14px;
    }
    
    .fnnrc-chatbot-header-text h3 {
        font-size: 13px;
    }
    
    .fnnrc-chatbot-messages {
        padding: 12px;
    }
    
    .fnnrc-message {
        margin-bottom: 12px;
    }
    
    .fnnrc-message-content {
        font-size: 13px;
        padding: 8px 10px;
        max-width: 85%;
    }
    
    .fnnrc-input-wrapper {
        padding: 6px;
    }
    
    #fnnrc-chatbot-input {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    #fnnrc-chatbot-send,
    #fnnrc-chatbot-attach,
    #fnnrc-chatbot-live-agent {
        width: 28px;
        height: 28px;
        padding: 6px;
    }
    
    .fnnrc-message-avatar {
        width: 24px;
        height: 24px;
    }
    
    .fnnrc-files-preview {
        padding: 8px;
    }
    
    .fnnrc-file-preview {
        padding: 6px;
        font-size: 12px;
    }
    
    .fnnrc-chatbot-header {
        padding: 14px 16px;
    }
    
    .fnnrc-chatbot-messages {
        padding: 16px;
    }
    
    .fnnrc-message-content-wrapper {
        max-width: 85%;
    }
    
    .fnnrc-files-preview {
        padding: 8px;
    }
    
    .fnnrc-file-preview {
        padding: 6px;
        font-size: 12px;
    }
    
    .fnnrc-file-preview img {
        max-width: 60px;
        max-height: 60px;
    }
}

/* Tablet Responsive */
@media (min-width: 481px) and (max-width: 768px) {
    .fnnrc-chatbot-container {
        width: 380px;
        bottom: 15px;
    }
    
    .fnnrc-chatbot-container:not(.fnnrc-minimized) .fnnrc-chatbot-body {
        height: 550px !important;
        max-height: 550px !important;
    }
}

/* Smooth animations */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Text selection */
.fnnrc-message-content {
    user-select: text;
    -webkit-user-select: text;
}

/* Touch-friendly improvements for mobile */
@media (max-width: 768px) {
    .fnnrc-chatbot-toggle,
    #fnnrc-chatbot-send,
    #fnnrc-chatbot-attach,
    #fnnrc-chatbot-live-agent {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .fnnrc-message-content {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .fnnrc-chatbot-messages {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent text size adjustment on iOS */
    #fnnrc-chatbot-input {
        -webkit-appearance: none;
        appearance: none;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .fnnrc-chatbot-container:not(.fnnrc-minimized) .fnnrc-chatbot-body {
        height: calc(100vh - 100px) !important;
        max-height: calc(100vh - 100px) !important;
    }
}

