/**
 * EVE RAG Chatbot Styles
 */

/* Container principale */
#eve-rag-chatbot-container {
    --eve-primary: #0073aa;
    --eve-primary-dark: #005177;
    --eve-bg: #ffffff;
    --eve-bg-light: #f6f7f7;
    --eve-text: #1e1e1e;
    --eve-text-light: #757575;
    --eve-border: #dcdcde;
    --eve-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --eve-radius: 12px;

    /*font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;*/
    font-size: 14px;
    line-height: 1.5;
    position: fixed;
    z-index: 999999;
}

/* Posizionamento */
#eve-rag-chatbot-container.position-bottom-right {
    bottom: 20px;
    right: 20px;
}

#eve-rag-chatbot-container.position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.eve-rag-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--eve-primary);
    border: 5px solid #ffffff;
    padding: 0;
    box-sizing: border-box;
    cursor: pointer;
    box-shadow: var(--eve-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    position: relative;
    z-index: 1;
}

/* Glow con colore primario */
.eve-rag-toggle::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    background: var(--eve-primary);
    z-index: -1;
    filter: blur(3px);
}

.eve-rag-toggle:hover {
    background: var(--eve-primary-dark);
    transform: scale(1.05);
}

/* Nascondi glow quando chat è aperta */
.eve-rag-toggle.open::before {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.eve-rag-toggle:active {
    transform: scale(0.95);
}

.eve-rag-toggle svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
}

.eve-rag-toggle .eve-rag-close-icon {
    display: none;
}

.eve-rag-toggle.open .eve-rag-chat-icon {
    display: none;
}

.eve-rag-toggle.open .eve-rag-close-icon {
    display: block;
}

/* Chat Window */
.eve-rag-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: var(--eve-bg);
    border-radius: var(--eve-radius);
    box-shadow: var(--eve-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.eve-rag-window.open {
    display: flex;
}

.position-bottom-right .eve-rag-window {
    right: 0;
}

.position-bottom-left .eve-rag-window {
    left: 0;
}

/* Header */
.eve-rag-header {
    background: var(--eve-primary);
    color: #ffffff;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.eve-rag-header-info {
    flex: 1;
}

.eve-rag-header-actions {
    display: flex;
    gap: 8px;
}

.eve-rag-fullscreen-btn {
    width: 32px;
    height: 32px;
    border: none;
	padding: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.eve-rag-fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.eve-rag-fullscreen-btn svg {
    width: 18px;
    height: 18px;
    fill: #ffffff;
}

.eve-rag-fullscreen-btn .eve-rag-compress-icon {
    display: none;
}

.eve-rag-fullscreen-btn.active .eve-rag-expand-icon {
    display: none;
}

.eve-rag-fullscreen-btn.active .eve-rag-compress-icon {
    display: block;
}

.eve-rag-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.eve-rag-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.eve-rag-avatar svg {
    width: 24px;
    height: 24px;
    fill: #ffffff;
}

.eve-rag-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.eve-rag-header-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

/* Messages Area */
.eve-rag-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--eve-bg-light);
}

.eve-rag-messages a {
    color: rgba(36, 151, 237, 1)
}

/* Message Bubbles */
.eve-rag-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    animation: eve-rag-fadeIn 0.3s ease-out;
}

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

/* Code blocks */
.eve-rag-message pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.eve-rag-message code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
}

.eve-rag-message pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.eve-rag-message.user {
    align-self: flex-end;
    background: var(--eve-primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.eve-rag-message.bot {
    align-self: flex-start;
    background: var(--eve-bg);
    color: var(--eve-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.eve-rag-message.error {
    background: #fef0f0;
    color: #d63638;
    border-left: 3px solid #d63638;
}

/* Typing Indicator */
.eve-rag-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    align-self: flex-start;
    background: var(--eve-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    animation: eve-rag-fadeIn 0.3s ease-out;
}

.eve-rag-typing-text {
    color: var(--eve-text-light);
    font-size: 13px;
    animation: eve-rag-pulse 1.5s ease-in-out infinite;
}

.eve-rag-typing-dots {
    display: flex;
    gap: 3px;
}

.eve-rag-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--eve-primary);
    border-radius: 50%;
    animation: eve-rag-bounce 1.4s infinite ease-in-out both;
}

.eve-rag-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.eve-rag-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

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

@keyframes eve-rag-pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* Streaming cursor */
.eve-rag-message.eve-rag-streaming::after {
    content: '\258C';
    animation: eve-rag-blink 0.7s step-end infinite;
    color: var(--eve-text-light);
}

@keyframes eve-rag-blink {
    50% { opacity: 0; }
}

/* Sources */
.eve-rag-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--eve-border);
    font-size: 12px;
}

.eve-rag-sources-title {
    color: var(--eve-text-light);
    margin-bottom: 6px;
    font-weight: 500;
}

.eve-rag-sources a {
    display: block;
    color: var(--eve-primary);
    text-decoration: none;
    padding: 4px 0;
}

.eve-rag-sources a:hover {
    text-decoration: underline;
}

/* Input Area */
.eve-rag-input-area {
    padding: 16px;
    background: var(--eve-bg);
    border-top: 1px solid var(--eve-border);
}

.eve-rag-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.eve-rag-input {
    flex: 1;
    border: 1px solid var(--eve-border);
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    color: #232323;
}

.eve-rag-input:focus {
    border-color: var(--eve-primary);
}

.eve-rag-input::placeholder {
    color: var(--eve-text-light);
}

.eve-rag-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--eve-primary);
    border: none;
	padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.eve-rag-send:hover:not(:disabled) {
    background: var(--eve-primary-dark);
}

.eve-rag-send:active:not(:disabled) {
    transform: scale(0.95);
}

.eve-rag-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.eve-rag-send svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

/* Character Counter */
.eve-rag-char-counter {
    text-align: right;
    font-size: 12px;
    color: var(--eve-text-light);
    margin-top: 8px;
    transition: color 0.2s;
}

.eve-rag-char-counter.warning {
    color: #dba617;
}

.eve-rag-char-counter.danger {
    color: #d63638;
}

/* Welcome Message */
.eve-rag-welcome {
    text-align: center;
    padding: 30px 20px;
    color: var(--eve-text-light);
}

.eve-rag-welcome h4 {
    margin: 0 0 8px;
    color: var(--eve-text);
    font-size: 16px;
}

.eve-rag-welcome p {
    margin: 0;
    font-size: 13px;
}

/* Responsive */
@media (max-width: 480px) {
    .eve-rag-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 80px;
    }

    #eve-rag-chatbot-container.position-bottom-right,
    #eve-rag-chatbot-container.position-bottom-left {
        right: 10px;
        left: 10px;
        bottom: 10px;
    }

    .eve-rag-toggle {
        width: 56px;
        height: 56px;
    }

    .position-bottom-right .eve-rag-toggle,
    .position-bottom-left .eve-rag-toggle {
        position: fixed;
        bottom: 10px;
        right: 10px;
    }

    .position-bottom-right .eve-rag-window,
    .position-bottom-left .eve-rag-window {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 80px;
        width: auto;
    }
}

/* Scrollbar styling */
.eve-rag-messages::-webkit-scrollbar {
    width: 6px;
}

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

.eve-rag-messages::-webkit-scrollbar-thumb {
    background: var(--eve-border);
    border-radius: 3px;
}

.eve-rag-messages::-webkit-scrollbar-thumb:hover {
    background: var(--eve-text-light);
}

/* Print - Hide chatbot */
@media print {
    #eve-rag-chatbot-container {
        display: none !important;
    }
}

/* ===========================================
   FULLSCREEN MODE
   =========================================== */

/* Blocca scroll body quando in fullscreen */
body.eve-rag-fullscreen-active {
    overflow: hidden !important;
}

/* Container in fullscreen */
#eve-rag-chatbot-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 9999999;
}

/* Nascondi toggle button in fullscreen */
#eve-rag-chatbot-container.fullscreen .eve-rag-toggle {
    display: none;
}

/* Window in fullscreen */
#eve-rag-chatbot-container.fullscreen .eve-rag-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0;
    display: flex;
}

/* Header in fullscreen */
#eve-rag-chatbot-container.fullscreen .eve-rag-header {
    padding: 12px 20px;
}

/* Messages area in fullscreen */
#eve-rag-chatbot-container.fullscreen .eve-rag-messages {
    padding: 24px;
}

/* Message bubbles in fullscreen - max width for readability */
#eve-rag-chatbot-container.fullscreen .eve-rag-message {
    max-width: 700px;
}

/* Center messages in fullscreen on large screens */
@media (min-width: 900px) {
    #eve-rag-chatbot-container.fullscreen .eve-rag-messages {
        padding: 24px calc(50% - 400px);
    }
}

/* Input area in fullscreen */
#eve-rag-chatbot-container.fullscreen .eve-rag-input-area {
    padding: 16px 24px 24px;
}

@media (min-width: 900px) {
    #eve-rag-chatbot-container.fullscreen .eve-rag-input-area {
        padding: 16px calc(50% - 400px) 24px;
    }
}

/* Larger input in fullscreen */
#eve-rag-chatbot-container.fullscreen .eve-rag-input {
    padding: 14px 24px;
    font-size: 16px;
}
