/* General Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #F2F2F2;
    color: #333;
    height: 100vh;
    overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    /* For main chat, float chat uses 4px */
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Float Chat Button */
.float-chat-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    background-color: #038B8F;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(3, 139, 143, 0.3);
    transition: all 0.3s ease;
    z-index: 1000;
    border: none;
    outline: none;
}

.float-chat-button:hover {
    background-color: #027073;
    transform: scale(1.1);
}

.float-chat-button svg {
    width: 24px;
    height: 24px;
    fill: white;
}

/* Float Chat Window */
.float-chat-window {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 400px;
    height: 600px;
    background-color: #F2F2F2;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    transition: all 0.3s ease;
}

.float-chat-window.open {
    display: flex;
}

.float-chat-window.fullscreen {
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
}

/* Float Chat Header */
.float-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.float-chat-header-left {
    display: flex;
    align-items: center;
}

.float-chat-logo {
    width: 32px;
    height: 32px;
    background-color: #038B8F;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    margin-right: 10px;
}

#logo {
    /* Specific to chat.html and float-chat-header */
    max-height: 30px;
    margin-right: 10px;
}

.float-chat-brand h1 {
    font-size: 18px;
    font-weight: 600;
    color: #038B8F;
    margin: 0;
}

.float-chat-brand p {
    font-size: 12px;
    color: #666;
    margin: 0;
}

.float-chat-controls {
    display: flex;
    gap: 8px;
}

.float-chat-btn {
    width: 30px;
    height: 30px;
    border: none;
    background-color: #f0f0f0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.float-chat-btn:hover {
    background-color: #e0e0e0;
}

.float-chat-btn svg {
    width: 16px;
    height: 16px;
    fill: #666;
}

/* Float Chat Messages */
.float-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.float-chat-welcome h2 {
    font-size: 20px;
    font-weight: 300;
    margin-bottom: 8px;
    color: #038B8F;
}

.float-chat-welcome p {
    font-size: 14px;
    line-height: 1.5;
}

.float-chat-message {
    max-width: 85%;
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease-in;
}

.float-chat-message.user {
    align-self: flex-end;
    margin-left: auto;
}

.float-chat-message.bot {
    align-self: flex-start;
    margin-right: auto;
}

.float-chat-message-content {
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.4;
    word-wrap: break-word;
    border: 1px solid #e0e0e0;
}

.float-chat-message.user .float-chat-message-content {
    background-color: #038B8F;
    color: white;
    border-color: #038B8F;
}

.float-chat-message.bot .float-chat-message-content {
    background-color: white;
    color: #333;
    border-color: #e0e0e0;
}

.float-chat-message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.float-chat-message-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.float-chat-message.bot .float-chat-message-time {
    text-align: left;
}

/* Float Chat Input */
.float-chat-input {
    padding: 16px;
    background-color: transparent;
    border-top: none;
}

.float-chat-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background-color: white;
    border-radius: 24px;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.float-chat-input-wrapper {
    flex: 1;
}

.float-chat-textarea {
    width: 100%;
    min-height: 32px;
    max-height: 80px;
    padding: 6px 4px;
    border: none;
    border-radius: 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    background-color: transparent;
}

.float-chat-input-container:focus-within {
    border-color: #038B8F;
}

.float-chat-send {
    width: 36px;
    height: 36px;
    border: none;
    background-color: #038B8F;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.float-chat-send:hover {
    background-color: #027073;
}

.float-chat-send:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.float-chat-send svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Loading Spinner */
.float-chat-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background-color: white;
    border-radius: 16px;
    border: 1px solid #e0e0e0;
    max-width: 85%;
    margin-right: auto;
}

.float-chat-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #038B8F;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.float-chat-loading-text {
    color: #666;
    font-size: 12px;
}

/* Full Page Chat Specific Styles */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    margin: 0 auto;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background-color: #fff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
}


/* Stili per l'animazione GENIX */
.genix-animation-container {
    position: relative;
    /* Necessario per posizionare l'animazione dietro al testo */
    display: inline-block;
    /* Si adatta alla larghezza del testo */
}

#genix-animation {
    opacity: 0;
    position: absolute;
    top: -35px;
    left: -10px;
    width: 120px;
    /* Dimensioni iniziali */
    height: 120px;
    z-index: -1;
    /* Mette l'animazione dietro al testo h1 */
    border-radius: 55%;
    background-color: #198B90;
}

/* Assicuriamoci che il testo sia sempre sopra l'animazione */
.brand-info h1 {
    position: relative;
    z-index: 1;
    margin-bottom: 2px;
    /* Manteniamo lo stile originale */
}



.logo {
    width: 40px;
    height: 40px;
    background-color: #038B8F;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
    margin-right: 12px;
}

#logo {
    /* Specific to chat.html and float-chat-header */
    max-height: 50px;
    margin-right: 10px;
}

.brand-info h1 {
    font-size: 24px;
    font-weight: 600;
    color: #038B8F;
    margin-bottom: 2px;
}

.brand-info p {
    font-size: 14px;
    color: #666;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 90px;
    width: 100%;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
}

.dark-mode .welcome-message h1 {
    color: #1A1A1A;
}

.welcome-message h1 {
    color: #F2F2F2;
}

.welcome-message p {
    font-size: 18px;
    line-height: 1.6;
    margin-top: 60px;
}

.message {
    max-width: 75%;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-in;
}

.message.user {
    align-self: flex-end;
    margin-left: auto;
}

.message.bot {
    align-self: flex-start;
    margin-right: auto;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    border: 1px solid #e0e0e0;
}

.message.user .message-content {
    background-color: #038B8F;
    color: white;
    border-color: #038B8F;
}

.message.bot .message-content {
    background-color: white;
    color: #333;
    border-color: #e0e0e0;
}

.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.message-time {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.message.bot .message-time {
    text-align: left;
}

.input-area {
    padding: 20px 24px;
    background-color: transparent;
    border-top: none;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    max-width: 100%;
    background-color: white;
    border-radius: 30px;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#messageInput {
    width: 100%;
    min-height: 40px;
    max-height: 120px;
    padding: 8px 4px;
    border: none;
    border-radius: 20px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    background-color: transparent;
}

.input-container:focus-within {
    border-color: #038B8F;
}

#sendButton {
    width: 44px;
    height: 44px;
    border: none;
    background-color: #038B8F;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

#sendButton:hover {
    background-color: #027073;
}

#sendButton:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.loading-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background-color: white;
    border-radius: 18px;
    border: 1px solid #e0e0e0;
    max-width: 75%;
    margin-right: auto;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #038B8F;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #666;
    font-size: 14px;
}

/* HTML content styling in bot messages (common for both) */
.float-chat-message.bot .float-chat-message-content h1,
.float-chat-message.bot .float-chat-message-content h2,
.float-chat-message.bot .float-chat-message-content h3,
.float-chat-message.bot .float-chat-message-content h4,
.float-chat-message.bot .float-chat-message-content h5,
.float-chat-message.bot .float-chat-message-content h6,
.message.bot .message-content h1,
.message.bot .message-content h2,
.message.bot .message-content h3,
.message.bot .message-content h4,
.message.bot .message-content h5,
.message.bot .message-content h6 {
    color: #038B8F;
    margin: 6px 0 3px 0;
    /* Adjusted for float chat, larger for main chat */
    font-weight: 600;
}

.message.bot .message-content h1,
.message.bot .message-content h2,
.message.bot .message-content h3,
.message.bot .message-content h4,
.message.bot .message-content h5,
.message.bot .message-content h6 {
    margin: 8px 0 4px 0;
    /* Larger margins for main chat */
}

.float-chat-message.bot .float-chat-message-content p,
.message.bot .message-content p {
    margin: 6px 0;
    /* Adjusted for float chat */
    line-height: 1.5;
}

.message.bot .message-content p {
    margin: 8px 0;
    /* Larger margins for main chat */
    line-height: 1.6;
}

.float-chat-message.bot .float-chat-message-content ul,
.float-chat-message.bot .float-chat-message-content ol,
.message.bot .message-content ul,
.message.bot .message-content ol {
    margin: 6px 0;
    /* Adjusted for float chat */
    padding-left: 16px;
    /* Adjusted for float chat */
}

.message.bot .message-content ul,
.message.bot .message-content ol {
    margin: 8px 0;
    /* Larger margins for main chat */
    padding-left: 20px;
    /* Larger padding for main chat */
}

.float-chat-message.bot .float-chat-message-content li,
.message.bot .message-content li {
    margin: 3px 0;
    /* Adjusted for float chat */
}

.message.bot .message-content li {
    margin: 4px 0;
    /* Larger margins for main chat */
}

.float-chat-message.bot .float-chat-message-content a,
.message.bot .message-content a {
    color: #038B8F;
    text-decoration: none;
}

.float-chat-message.bot .float-chat-message-content a:hover,
.message.bot .message-content a:hover {
    text-decoration: underline;
}

.float-chat-message.bot .float-chat-message-content code,
.message.bot .message-content code {
    background-color: #f5f5f5;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.float-chat-message.bot .float-chat-message-content pre,
.message.bot .message-content pre {
    background-color: #f5f5f5;
    padding: 8px;
    /* Adjusted for float chat */
    border-radius: 4px;
    /* Adjusted for float chat */
    overflow-x: auto;
    margin: 6px 0;
    /* Adjusted for float chat */
}

.message.bot .message-content pre {
    padding: 12px;
    /* Larger padding for main chat */
    border-radius: 6px;
    /* Larger border radius for main chat */
    margin: 8px 0;
    /* Larger margins for main chat */
}

.float-chat-message.bot .float-chat-message-content pre code,
.message.bot .message-content pre code {
    background-color: transparent;
    padding: 0;
}

.float-chat-message.bot .float-chat-message-content blockquote,
.message.bot .message-content blockquote {
    border-left: 3px solid #038B8F;
    /* Adjusted for float chat */
    margin: 6px 0;
    /* Adjusted for float chat */
    padding-left: 12px;
    /* Adjusted for float chat */
    font-style: italic;
    color: #666;
}

.message.bot .message-content blockquote {
    border-left: 4px solid #038B8F;
    /* Larger border for main chat */
    margin: 8px 0;
    /* Larger margins for main chat */
    padding-left: 16px;
    /* Larger padding for main chat */
}

.message.bot .message-content strong {
    font-weight: 600;
}

.message.bot .message-content em {
    font-style: italic;
}

/* Dark Mode Toggle (full page chat) */
.theme-toggle {
    width: 44px;
    height: 24px;
    background-color: #e0e0e0;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: none;
    outline: none;
}

.theme-toggle.dark {
    background-color: #038B8F;
}

.theme-toggle-slider {
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle.dark .theme-toggle-slider {
    transform: translateX(20px);
}

.theme-toggle-icon {
    width: 12px;
    height: 12px;
    fill: #666;
}

.theme-toggle.dark .theme-toggle-icon {
    fill: #038B8F;
}


/* Dark Mode Styles (common for both) */
body.dark-mode,
.float-chat-window.dark-mode {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

.dark-mode .header,
.float-chat-window.dark-mode .float-chat-header {
    background-color: #2d2d2d;
    border-bottom-color: #404040;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dark-mode .brand-info h1,
.float-chat-window.dark-mode .float-chat-brand h1 {
    color: #038B8F;
}

.dark-mode .brand-info p,
.float-chat-window.dark-mode .float-chat-brand p {
    color: #b0b0b0;
}

.dark-mode .welcome-message,
.float-chat-window.dark-mode .float-chat-welcome {
    color: #b0b0b0;
}

.dark-mode .welcome-message h2,
.float-chat-window.dark-mode .float-chat-welcome h2 {
    color: #038B8F;
}

.dark-mode .message.bot .message-content,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content {
    background-color: #2d2d2d;
    color: #e0e0e0;
    border-color: #404040;
}

.dark-mode .message.bot .message-content h1,
.dark-mode .message.bot .message-content h2,
.dark-mode .message.bot .message-content h3,
.dark-mode .message.bot .message-content h4,
.dark-mode .message.bot .message-content h5,
.dark-mode .message.bot .message-content h6,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content h1,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content h2,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content h3,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content h4,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content h5,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content h6 {
    color: #198B90;
}

.dark-mode .message.bot .message-content a,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content a {
    color: #198B90;
}

.dark-mode .message.bot .message-content code,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content code {
    background-color: #404040;
    color: #e0e0e0;
}

.dark-mode .message.bot .message-content pre,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content pre {
    background-color: #404040;
}

.dark-mode .message.bot .message-content blockquote,
.float-chat-window.dark-mode .float-chat-message.bot .float-chat-message-content blockquote {
    border-left-color: #198B90;
    color: #b0b0b0;
}

.dark-mode .input-area,
.float-chat-window.dark-mode .float-chat-input {
    background-color: transparent;
}

.dark-mode .input-container,
.float-chat-window.dark-mode .float-chat-input-container {
    background-color: #404040;
    border-color: #555;
}

.dark-mode .input-container:focus-within,
.float-chat-window.dark-mode .float-chat-input-container:focus-within {
    border-color: #038B8F;
}

.dark-mode #messageInput,
.float-chat-window.dark-mode .float-chat-textarea {
    color: #e0e0e0;
}

.dark-mode #messageInput::placeholder,
.float-chat-window.dark-mode .float-chat-textarea::placeholder {
    color: #888;
}

.dark-mode .loading-message,
.float-chat-window.dark-mode .float-chat-loading {
    background-color: #2d2d2d;
    border-color: #404040;
}

.dark-mode .loading-text,
.float-chat-window.dark-mode .float-chat-loading-text {
    color: #b0b0b0;
}

.dark-mode .message-time,
.float-chat-window.dark-mode .float-chat-message-time {
    color: #888;
}

.float-chat-window.dark-mode .float-chat-btn {
    background-color: #404040;
}

.float-chat-window.dark-mode .float-chat-btn:hover {
    background-color: #555;
}

.float-chat-window.dark-mode .float-chat-btn svg {
    fill: #b0b0b0;
}

.float-chat-window.dark-mode .float-chat-messages::-webkit-scrollbar-track,
.dark-mode .messages-container::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.float-chat-window.dark-mode .float-chat-messages::-webkit-scrollbar-thumb,
.dark-mode .messages-container::-webkit-scrollbar-thumb {
    background: #555;
}

.float-chat-window.dark-mode .float-chat-messages::-webkit-scrollbar-thumb:hover,
.dark-mode .messages-container::-webkit-scrollbar-thumb:hover {
    background: #666;
}


/* Animations */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive (Float Chat) */
@media (max-width: 768px) {
    .float-chat-window:not(.fullscreen) {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        top: 20px;
        left: 20px;
        right: 20px;
        bottom: 20px;
        border-radius: 12px;
    }

    .float-chat-window.fullscreen {
        width: 100vw;
        height: 100vh;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
    }

    .float-chat-button {
        bottom: 80px;
    }

    .float-chat-messages {
        padding-bottom: 20px;
    }

    .float-chat-input {
        /* Apply sticky behavior to float chat input */
        position: sticky;
        bottom: 5px;
        /* Adjusted to be slightly above the bottom */
        background-color: #F2F2F2;
        border-top: 1px solid #e0e0e0;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    .float-chat-window.dark-mode .float-chat-input {
        background-color: #1e1e1e;
        border-top: 1px solid #444;
    }

    .float-chat-input-container {
        /* Ensure input container remains within the input area */
        font-size: 14px;
        /* Adjusted for float chat */
    }
}

/* Desktop larger size when not fullscreen (Float Chat) */
@media (min-width: 769px) {
    .float-chat-window:not(.fullscreen) {
        width: 400px;
        height: 600px;
    }
}

/* Responsive (Full Page Chat) */
@media (max-width: 768px) {
    .container {
        border-left: none;
        border-right: none;
    }

    .theme-toggle.dark .theme-toggle-slider {
        transform: translateX(0);
        top: 2px;
        left: 2px;
    }

    .theme-toggle {
        width: 30px;
        height: 24px;
        background-color: #e0e0e0;
        border-radius: 12px;
        position: relative;
        cursor: pointer;
        transition: background-color 0.3s ease;
        border: none;
        outline: none;
    }

    .header {
        padding: 12px 16px;
    }

    .brand-info h1 {
        font-size: 20px;
    }

    .messages-container {
        /* Adjusted padding for mobile to ensure last message is visible */
        padding: 16px 16px 160px 16px;
        /* top, right, bottom, left */
    }

    .message {
        max-width: 85%;
    }

    .welcome-message {
        padding: 40px 16px;
    }

    .welcome-message h2 {
        font-size: 24px;
    }

    .welcome-message p {
        font-size: 16px;
    }

    .input-area {
        padding: 16px;
        background-color: #F2F2F2;
        border-top: 1px solid #e0e0e0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        /* Ensure it spans full width */
    }

    .dark-mode .input-area {
        background-color: #1e1e1e;
        border-top: 1px solid #444;
    }
}