/* Bubble Styles */
.chatbot-container.bubble-mode > .chat-content {
    display: none;
}

.chatbot-container.bubble-mode {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #007bff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.chatbot-container.bubble-mode:hover {
    transform: scale(1.1);
}

.chatbot-container.bubble-mode.disabled {
    background: #cccccc !important;
    cursor: not-allowed !important;
}

.chatbot-container.bubble-mode.disabled:hover {
    transform: none !important;
}

.bubble-icon {
    color: white;
    font-size: 24px;
    font-weight: bold;
}

/* Nascondi bubble-icon quando non in bubble mode */
.chatbot-container:not(.bubble-mode) .bubble-icon {
    display: none;
}

/* Container Styles */
.chatbot-container {
    width: 300px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: Arial, sans-serif;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.chatbot-container.maximized {
    width: 80%;
    height: 80vh;
    bottom: 10vh;
    right: 10%;
}

/* Header Styles */
.chatbot-header {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    background: #f8f9fa;
    border-bottom: 1px solid #ccc;
    border-radius: 8px 8px 0 0;
}

.chatbot-controls {
    display: flex;
    gap: 8px;
}

.chatbot-resize-btn,
.chatbot-restart-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-resize-btn:hover,
.chatbot-restart-btn:hover {
    color: #000;
}

.chatbot-resize-btn svg,
.chatbot-restart-btn svg {
    width: 14px;
    height: 14px;
}

/* New Close Button Styles */
.chatbot-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chatbot-close-btn:hover {
    color: #000;
}
.chatbot-close-btn svg {
    width: 14px;
    height: 14px;
}

.session-id {
    font-size: 12px;
    color: #666;
    padding: 4px 8px;
    align-self: center;
}

/* Adjust chat content structure for maximized mode */
.chat-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.3s ease;
}

.chatbot-container.maximized .chat-content {
    position: relative;
    height: 100%;
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    max-height: 400px; /* Add max-height for non-maximized mode */
    min-height: 200px;
    height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: #f9f9f9;
    transition: all 0.3s ease;
}

.chatbot-container.maximized .chatbot-messages {
    max-height: none; /* Remove max-height restriction in maximized mode */
    height: calc(80vh - 150px);
}

/* Message Styles */
.message {
    margin: 8px 0;
    padding: 8px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
    transition: all 0.3s ease;
    opacity: 1;
}

.user-message {
    background: #007bff;
    color: white;
    margin-left: auto;
    white-space: pre-line; /* Changed from pre-wrap to pre-line */
    line-height: 1.4; /* Add line height for better readability */
}

.bot-message {
    background: #e9ecef;
    color: black;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.3;
    font-size: 14px;
    position: relative;
    clear: both;
}

.bot-message .markdown-wrapper {
    display: flow-root; /* Creates new block formatting context */
}

.bot-message img {
    max-width: 30%;
    max-height: 400px;
    float: left;
    margin: 0 15px 10px 0;
    clear: left;
}

/* Showdown Generated Content Styles */
.bot-message h1 {
    font-size: 1.5em;
    margin: 0.5em 0;
}

.bot-message h2 {
    font-size: 1.3em;
    margin: 0.4em 0;
}

.bot-message h3 {
    font-size: 1.1em;
    margin: 0.3em 0;
}

.bot-message p {
    margin: 0.5em 0;
    display: flow-root; /* Creates new block formatting context for each paragraph */
    clear: both; /* Ensures paragraphs don't wrap around previous floats */
}

.bot-message code {
    background-color: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.bot-message pre {
    background-color: #f0f0f0;
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.bot-message pre code {
    background-color: transparent;
    padding: 0;
}

.bot-message a {
    color: #007bff;
    text-decoration: none;
}

.bot-message a:hover {
    text-decoration: underline;
}

/* Info badge styles */
.info-badge, .photo-badge {
    display: inline-block;
    background: #007bff;
    color: white;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
    cursor: pointer;
    vertical-align: middle;
}

.info-badge:hover, .photo-badge:hover {
    background: #0056b3;
}

/* Styles for chatbot query links */
.chatbot-query-link {
    color: #fff; /* White text */
    padding: 2px 6px;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: inline-block; /* To allow padding and margin */
    margin: 0 2px; /* Small margin to separate from surrounding text */
}

.chatbot-query-link:hover {
    text-decoration: none; /* Ensure no underline on hover */
}

.bot-message ul,
.bot-message ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.bot-message ul ul,
.bot-message ul ol,
.bot-message ol ul,
.bot-message ol ol {
    margin: 0.25em 0;
}

.bot-message li {
    margin: 0.25em 0;
}

.bot-message table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5em 0;
    background-color: white;
}

.bot-message th,
.bot-message td {
    padding: 8px;
    border: 1px solid #ddd;
}

.bot-message th {
    background-color: #f5f5f5;
    font-weight: bold;
}

.bot-message tr:nth-child(even) {
    background-color: #f9f9f9;
}

.bot-message tr:hover {
    background-color: #f5f5f5;
}

/* Input Area */
.chatbot-input {
    display: flex;
    padding: 10px;
    background: white;
    border: 1px solid #ccc;
}

.chatbot-input input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-right: 8px;
    font-size: 14px;
}

.chatbot-input textarea {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-right: 8px;
    font-size: 14px;
    min-height: 38px;
    max-height: 120px; /* Reduced to prevent going off screen */
    height: 38px; /* Start with single line height */
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    overflow-y: hidden; /* Hide scrollbar by default */
    transition: height 0.2s ease; /* Smooth height transitions */
}

/* Adjust input area when maximized to prevent overflow */
.chatbot-container.maximized .chatbot-input {
    border-radius: 0 0 8px 8px;
}

/* Adjust input positioning */
.chatbot-input {
    padding: 10px;
    background: white;
    border-top: 1px solid #eee;
}

/* Remove old positioning rules */
.chatbot-container.maximized .chatbot-input {
    position: static;
}

.chatbot-input button {
    padding: 8px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chatbot-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chatbot-input button:hover:not(:disabled) {
    background: #0056b3;
}

/* Bottom section containing disclaimer, speak-to-human, and input */
.chatbot-bottom {
    background: white;
    border-top: 1px solid #ccc;
    z-index: 2;
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-container.maximized .chatbot-bottom {
    position: relative; /* Cambiato da fixed a relative */
    bottom: auto;
    left: auto;
    right: auto;
    width: 100%;
    border-radius: 0 0 8px 8px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    margin: 8px 0;
    padding: 8px;
    border-radius: 8px;
    background: #e9ecef;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background: #999;
    border-radius: 50%;
    animation: typing 1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Arabic support */
.chatbot-container[dir="rtl"] {
    left: 20px;
    right: auto;
}

.chatbot-container[dir="rtl"].maximized {
    left: 10%;
    right: auto;
}

.chatbot-container[dir="rtl"] .chatbot-input input {
    margin-right: 0;
    margin-left: 8px;
}

.chatbot-container[dir="rtl"] .user-message {
    margin-right: auto;
    margin-left: 0;
}

.chatbot-container[dir="rtl"] .bot-message ul,
.chatbot-container[dir="rtl"] .bot-message ol {
    padding-right: 1.5em;
    padding-left: 0;
}

.chatbot-container[dir="rtl"] .chatbot-controls {
    flex-direction: row-reverse;
}


.chatbot-disclaimer {
    padding: 8px;
    font-size: 12px;
    color: #666;
    border-top: 1px solid #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
	font-style: italic;
}

.chatbot-disclaimer.expanded {
    background: #f8f9fa;
}

.chatbot-disclaimer .full-disclaimer {
    display: none;
    margin-top: 8px;
    line-height: 1.4;
}

.chatbot-disclaimer.expanded .full-disclaimer {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

.shake-animation {
    animation: shake 0.3s ease-in-out 3;
}

.speak-to-human {
    display: block;
    color: #007bff;
    text-decoration: none;
    margin: 0 8px;
    font-size: 12px;
    font-style: normal;
}

.speak-to-human:hover {
    text-decoration: underline;
}

/* Image Expansion Styles */
.image-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000; /* Above chatbot container */
    cursor: zoom-out;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.image-overlay img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    cursor: zoom-out;
    transition: transform 0.3s ease;
}

.bot-message img {
    cursor: zoom-in;
}
