/* ============================================
   PurpleVague Widget Styling - Design System
   ============================================ */

/* Import fonts PurpleVague */
@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital@0;1&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@300;400;500;600;700&display=swap');

:host,
#kontext-chatbot-react-root,
.chatbot-widget-wrapper,
.chatbot-widget-button,
.chatbot-widget-container,
* {
    /* Spacing Scale */
    --kontext-spacing: 0.25rem;
    --kontext-spacing-xs: 0.25rem;
    --kontext-spacing-sm: 0.5rem;
    --kontext-spacing-md: 1rem;
    --kontext-spacing-lg: 1.25rem;
    --kontext-spacing-xl: 1.5rem;

    /* Typography */
    --kontext-font-family-base: "Raleway", Helvetica, Arial, Verdana, sans-serif;
    --kontext-font-family-mono: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    --kontext-default-font-size: 1rem;
    --kontext-predefined-question-btn-font-size: 0.825rem;

    /* Colors - Primary */
    --kontext-color-primary-dark: #573c81;
    --kontext-color-primary-blue: #573c81;
    --kontext-color-primary-blue-hover: #573c81;

    /* Colors - Text */
    --kontext-color-text-primary: #573c81;
    --kontext-color-text-secondary: #64748b;
    --kontext-color-text-tertiary: #94a3b8;
    --kontext-color-text-dark: #573c81;
    --kontext-color-text-white: #ffffff;

    /* Colors - Backgrounds */
    --kontext-color-bg-white: #ffffff;
    --kontext-color-bg-light: #f1f5f9;
    --kontext-color-bg-lighter: #f9fafb;
    --kontext-color-bg-app: #fdebf7;
    --kontext-color-bg-ai-message: #FEFBFD;
    --kontext-color-bg-ai-icon: #ffffff;
    --kontext-color-bg-typing: #e5e7eb;
    --kontext-color-bg-input: #f1f5f9;

    /* Colors - Borders */
    --kontext-color-border: #e5e7eb;
    --kontext-color-border-light: #e5e5e5;
    --kontext-color-border-input: #e2e8f0;
    --kontext-color-border-input-focus: #cbd5e1;

    /* Border Radius */
    --kontext-radius-xs: 0.25rem;
    --kontext-radius-sm: 0.375rem;
    --kontext-radius-md: 0.5rem;
    --kontext-radius-lg: 0.75rem;
    --kontext-radius-xl: 1rem;
    --kontext-radius-2xl: 1.125rem;
    --kontext-radius-3xl: 1.875rem;
    --kontext-radius-full: 50%;

    /* Transitions */
    --kontext-transition-fast: all 0.2s;
    --kontext-transition-base: all 0.3s ease;

    /* Shadows */
    --kontext-shadow-sm: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
    --kontext-shadow-md: 0 0.375rem 1rem rgba(0, 0, 0, 0.2);
    --kontext-shadow-xl: 0 0.625rem 2.5rem rgba(0, 0, 0, 0.2);
    --kontext-shadow-focus: 0 0 0 0.1875rem rgba(59, 130, 246, 0.1);

    /* Z-index Scale */
    --kontext-z-widget: 9999;

    pointer-events: auto;
}

/* ============================================
   Widget Positioning - Ridicat mai sus
   ============================================ */

#kontext-chatbot-widget .chatbot-widget-wrapper,
.chatbot-widget-wrapper {
    bottom: 9rem;
    right: 4.25rem !important;
}

@media (min-width: 769px) {
    .chatbot-widget-wrapper {
      right: 4.25rem !important;
    }
  
    .chatbot-widget-wrapper:has(.chatbot-widget-container.chatbot-widget-maximized) {
      right: 1.25rem !important;
    }
}

/* ============================================
   Widget Button
   ============================================ */

button.chatbot-widget-button,
.chatbot-widget-button {
    width: 4rem;
    height: 4rem;
    border-radius: var(--kontext-radius-full);
    border: 1px solid #573c81;
    background-color: #ffffff;
    background-image: none;
    background: #ffffff;
    box-shadow: var(--kontext-shadow-md);
    transition: var(--kontext-transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

button.chatbot-widget-button:hover,
.chatbot-widget-button:hover {
    background-color: #ffffff;
    background-image: none;
    background: #ffffff;
    transform: scale(1.05) translateY(-2px);
    box-shadow: var(--kontext-shadow-xl);
}

.chatbot-widget-button-logo {
    width: 50%;
    height: 50%;
    object-fit: contain;
}

/* ============================================
   Bubble Message
   ============================================ */

.chatbot-widget-button-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chatbot-widget-bubble {
    position: absolute;
    bottom: calc(100% + 1rem);
    right: 0;
    width: auto;
    min-width: 200px;
    max-width: 280px;
    background-color: #ffffff;
    border: 1px solid #573c81;
    border-radius: var(--kontext-radius-2xl);
    padding: 0.75rem 1rem;
    box-shadow: var(--kontext-shadow-md);
    cursor: pointer;
    z-index: 10;
    animation: fadeIn 0.3s ease-in-out;
}

.chatbot-widget-bubble::before {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 1.5rem;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #573c81;
}

.chatbot-widget-bubble::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 1.5rem;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid #ffffff;
    z-index: 1;
}

.chatbot-widget-bubble-text {
    font-family: "Raleway", Helvetica, Arial, Verdana, sans-serif;
    font-size: 0.9rem;
    color: #573c81;
    font-weight: 500;
    text-align: left;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .chatbot-widget-bubble {
        max-width: calc(100vw - 90px);
    }
}

/* ============================================
   Widget Container - Shadow & Rounded Corners
   ============================================ */

.chatbot-widget-container {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid var(--kontext-color-border-light);
}

/* ============================================
   Widget Header
   ============================================ */

.chatbot-widget-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--kontext-color-border-light);
}

.chatbot-widget-title {
    color: #573c81;
    font-family: "Raleway", Helvetica, Arial, Verdana, sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
}

.chatbot-widget-header-left {
    align-items: center;
    gap: 0.5rem;
}

.chatbot-widget-logo {
    border-radius: var(--kontext-radius-full);
    overflow: hidden;
}

.chatbot-widget-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   Messages Area
   ============================================ */

.chatbot-messages {
    background: #ffffff;
}

/* User message */
.bubble-user {
    background-color: #573c81;
    color: #ffffff;
    border-radius: var(--kontext-radius-2xl);
}

/* AI message - transparent, fÄrÄ fundal */
.message-ai .message-content {
    background-color: transparent;
    color: #000000;
    border: none;
    border-radius: var(--kontext-radius-2xl);
}

.ai-icon {
    background-color: #ffffff;
    border-radius: var(--kontext-radius-full);
    width: 2.5rem;
    height: 2.5rem;
}

.ai-icon-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--kontext-radius-full);
}

.message-actions {
    gap: 0.2rem !important;
    margin-bottom: 0.5rem !important;
}

.message-action-btn {
    border: none !important;
    background: transparent !important;
    color: #573c81 !important;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.message-action-btn:hover {
    opacity: 1;
}

/* Typing Indicator - Matching Theme */
.typing-indicator {
    background-color: transparent !important;
    padding: 0.5rem 0 !important;
}

.typing-indicator .the7-spinner div {
    background-color: #987dc3 !important; 
}

/* ============================================
   Follow-up / Predefined Questions
   Font-size: 16px, Border: mov #573c81, FÄRÄ background la hover
   ============================================ */


.predefined-question-btn,
button.predefined-question-btn {
    background-color: #ffffff;
    border: 1px solid #573c81;
    border-radius: 1.125rem;
    color: #573c81;
    font-size: 16px;
    font-family: "Raleway", Helvetica, Arial, Verdana, sans-serif;
    font-weight: 500;
    line-height: 1.5;
    padding: 0.75rem 1.25rem;
    transition: all 0.2s;
    text-align: left;
}

.predefined-question-btn:hover:not(:disabled),
button.predefined-question-btn:hover:not(:disabled) {
    background-color: transparent;
    border-color: #573c81;
    color: #573c81;
}

/* ============================================
   Input Area
   ============================================ */

.chatbot-input-wrapper {
    border-color: var(--kontext-color-border-input);
    background-color: var(--kontext-color-bg-input);
}

.chatbot-input-wrapper:focus-within {
    border-color: #573c81;
    box-shadow: var(--kontext-shadow-focus);
}

/* ============================================
   Links
   ============================================ */

.bubble-ai a,
.chatbot-disclaimer-link,
.chatbot-footer-link {
    color: #573c81;
}

.bubble-ai a:hover,
.chatbot-disclaimer-link:hover,
.chatbot-footer-link:hover {
    color: #573c81;
}

/* ============================================
   Scrollbar
   ============================================ */

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ============================================
   Footer - Pe o singurÄ linie, gap-uri mici
   ============================================ */

.chatbot-disclaimer,
.chatbot-disclaimer-text {
    font-size: 0.7rem;
    font-family: "Raleway", Helvetica, Arial, Verdana, sans-serif;
    line-height: 1.2;
}

.chatbot-footer-link,
.chatbot-footer {
    font-size: 0.7rem;
    font-family: "Raleway", Helvetica, Arial, Verdana, sans-serif;
}

.chatbot-footer {
    gap: 0;
    flex-wrap: nowrap;
    align-items: center;
    display: flex;
    padding: 0.25rem 0;
}

.chatbot-footer-separator {
    margin: 0 0.25rem;
    display: inline;
}

.chatbot-footer-links {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    align-items: center;
}

.kontext-powered-by {
    gap: 0.25rem;
}

.kontext-powered-by-text,
.kontext-logo-powered-by {
    font-family: "Raleway", Helvetica, Arial, Verdana, sans-serif;
    font-size: 0.7rem;
    height: 0.74rem !important;
}

/* ============================================
   Maximized State
   ============================================ */

.chatbot-widget-container.chatbot-widget-maximized .chatbot-widget-title {
    font-size: 1.5rem;

}

/* ============================================
   Animations
   ============================================ */

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