
/* nuby Chat Widget Styles */

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;500;600;700&display=swap');

.nuby-widget-container {
    width: 100%;
    height: 100%;
    position: relative;
    font-family: 'Quicksand', sans-serif;
    overflow: hidden;
    background-color: #ffffff;
    display: flex;
    flex-direction: row; /* Main Chat | Sidebar */
}

/* --- MAIN CHAT AREA --- */
.nuby-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    position: relative;
}

.nuby-chat-header {
    padding: 16px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 10;
}

.nuby-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.nuby-subtitle {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.nuby-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --- MESSAGES --- */
.nuby-message {
    display: flex;
    margin-bottom: 4px;
}

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

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

.nuby-message-bubble {
    width: 75%;
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.nuby-message.user .nuby-message-bubble {
    border-bottom-right-radius: 2px;
}

.nuby-message.bot .nuby-message-bubble {
    background-color: #ffffff;
    color: #333;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* --- INPUT AREA --- */
.nuby-chat-input-area {
    padding: 16px;
    background-color: #ffffff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: flex-end; 
    gap: 10px;
}

.nuby-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 4px 12px;
    transition: all 0.2s;
}

.nuby-input-wrapper:focus-within {
    background-color: #fff;
    border-color: #064e96;
    box-shadow: 0 0 0 2px rgba(6, 78, 150, 0.1);
}

#nuby-input-text {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    min-height: 24px;
    max-height: 100px;
    resize: none;
}

.nuby-btn-icon {
    border: none;
    background: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    transition: all 0.2s;
}

.nuby-btn-icon:hover {
    color: #064e96;
    background-color: #e5e7eb;
}

.nuby-btn-send {
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.nuby-btn-send:hover {
    opacity: 0.9;
}

/* --- RIGHT SIDEBAR (HISTORY) --- */
.nuby-chat-sidebar {
    width: 280px;
    background-color: var(--nuby-sidebar-bg, #ffffff);
    color: var(--nuby-sidebar-text, #1f2937);
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.nuby-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--nuby-sidebar-header-bg, #ffffff);
}

.nuby-btn-new-chat {
    background-color: rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
}
.nuby-btn-new-chat:hover {
    background-color: rgba(0,0,0,0.1);
}

.nuby-sidebar-search {
    padding: 10px 16px;
    border-bottom: 1px solid #f3f4f6;
    background-color: var(--nuby-sidebar-header-bg, #ffffff);
}

#nuby-search-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.1);
    font-size: 13px;
    outline: none;
    background-color: rgba(255,255,255,0.8);
    color: inherit;
}

.nuby-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    list-style: none;
    margin: 0;
}

.nuby-history-item {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    cursor: pointer;
    transition: background 0.1s;
}

.nuby-history-item:hover {
    background-color: rgba(0,0,0,0.03);
}

.nuby-history-item.active {
    background-color: rgba(6, 78, 150, 0.05);
    border-left: 3px solid #064e96;
}

.nuby-hist-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
}

.nuby-hist-date {
    font-size: 11px;
    opacity: 0.6;
}

/* --- UTILS --- */
.hidden { display: none !important; }

/* --- TYPING INDICATOR --- */
.nuby-message-bubble.typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px 20px;
}

.nuby-message-bubble.typing span {
    width: 8px;
    height: 8px;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.nuby-message-bubble.typing span:nth-child(1) {
    animation-delay: -0.32s;
}

.nuby-message-bubble.typing span:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* --- DARK THEME --- */
.nuby-widget-container.dark { background-color: #1f2937; color: white; }
.nuby-widget-container.dark .nuby-chat-main { background-color: #1f2937; }
.nuby-widget-container.dark .nuby-chat-body { background-color: #111827; }
.nuby-widget-container.dark .nuby-chat-input-area { background-color: #1f2937; border-top-color: #374151; }
.nuby-widget-container.dark .nuby-input-wrapper { background-color: #374151; border-color: #4b5563; }
.nuby-widget-container.dark #nuby-input-text { color: white; }
.nuby-widget-container.dark .nuby-message.bot .nuby-message-bubble { background-color: #374151; color: #e5e7eb; border-color: #4b5563; }

/* --- MESSAGE LINKS --- */
.nuby-message-bubble a,
.nuby-message-bubble a.nuby-link {
    color: #064e96;
    text-decoration: none;
    word-break: break-all;
}
.nuby-message-bubble a:hover,
.nuby-message-bubble a.nuby-link:hover {
    text-decoration: underline;
}
.nuby-widget-container.dark .nuby-message-bubble a,
.nuby-widget-container.dark .nuby-message-bubble a.nuby-link {
    color: #60a5fa;
}
.nuby-message.user .nuby-message-bubble a {
    color: #fff;
    text-decoration: underline;
}

/* --- MESSAGE LISTS --- */
.nuby-message-bubble ol,
.nuby-message-bubble ul {
    margin: 8px 0;
    padding-left: 4px;
}
.nuby-message-bubble ol {
    list-style: decimal inside;
}
.nuby-message-bubble ul {
    list-style: disc inside;
}
.nuby-message-bubble li {
    margin: 4px 0;
    line-height: 1.5;
}
.nuby-message-bubble strong {
    font-weight: 600;
}
.nuby-message-bubble em {
    font-style: italic;
}

/* --- FEEDBACK BUTTONS --- */
.nuby-feedback-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.nuby-feedback-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nuby-feedback-label {
    font-size: 11px;
    color: #9ca3af;
}

.nuby-feedback-btn {
    background: none;
    border: none;
    padding: 6px;
    border-radius: 50%;
    cursor: pointer;
    color: #9ca3af;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nuby-feedback-btn:hover {
    background-color: rgba(0,0,0,0.05);
}

.nuby-feedback-btn.positive:hover {
    color: #22c55e;
    background-color: rgba(34, 197, 94, 0.1);
}

.nuby-feedback-btn.positive.active {
    color: white !important;
    background-color: #22c55e !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.nuby-feedback-btn.negative:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

.nuby-feedback-btn.negative.active {
    color: white !important;
    background-color: #ef4444 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.nuby-feedback-thanks {
    font-size: 11px;
    color: #6b7280;
    margin-left: 4px;
}

.nuby-feedback-comment-row {
    display: flex;
    gap: 6px;
    align-items: center;
    animation: fadeIn 0.2s ease-in-out;
}

.nuby-feedback-comment-input {
    flex: 1;
    font-size: 11px;
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    outline: none;
}

.nuby-feedback-comment-input:focus {
    border-color: var(--nuby-primary, #3B82F6);
}

.nuby-feedback-comment-btn {
    font-size: 11px;
    padding: 6px 12px;
    background: var(--nuby-primary, #3B82F6);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.nuby-feedback-comment-btn:hover {
    opacity: 0.9;
}

.nuby-feedback-comment-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nuby-feedback-comment-close {
    font-size: 14px;
    padding: 4px 8px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
}

.nuby-feedback-comment-close:hover {
    color: #6b7280;
}

.nuby-widget-container.dark .nuby-feedback-container {
    border-top-color: rgba(255,255,255,0.1);
}

.nuby-widget-container.dark .nuby-feedback-btn {
    color: #6b7280;
}

.nuby-widget-container.dark .nuby-feedback-btn:hover {
    background-color: rgba(255,255,255,0.05);
}

.nuby-widget-container.dark .nuby-feedback-comment-input {
    background: #374151;
    border-color: #4b5563;
    color: white;
}

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

/* --- FILE PREVIEW STYLES (OCR Support) --- */
.nuby-file-preview-bubble {
    padding: 8px !important;
    max-width: 350px !important;
}

.nuby-file-previews {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.nuby-file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 8px;
    position: relative;
}

.nuby-file-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.nuby-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nuby-file-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nuby-file-size {
    font-size: 11px;
    opacity: 0.8;
}

.nuby-file-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.3);
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.nuby-file-remove:hover {
    opacity: 1;
    background: rgba(220, 38, 38, 0.8);
}

.nuby-file-hint {
    font-size: 11px;
    opacity: 0.9;
    text-align: center;
    padding-top: 4px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

/* Dark theme adjustments for file previews */
.nuby-widget-container.dark .nuby-file-preview {
    background: rgba(0,0,0,0.2);
}

.nuby-widget-container.dark .nuby-file-hint {
    border-top-color: rgba(255,255,255,0.1);
}
