/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@300;400;500;600&display=swap');

/* Import Google Material Symbols */
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0');

/* FONT PRINCIPALE: Inter per tutto il chatbot */
.is-chatbot-wrapper,
.is-chatbot-wrapper *,
.is-chat-container,
.is-chat-container *,
.is-message-input,
.is-send-btn,
.is-question-btn,
.is-message,
.is-bot-message,
.is-user-message {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

/* Titolo header con Playfair Display (elegante serif) */
.is-chat-header span {
  font-family: 'Playfair Display', Georgia, serif !important;
  font-weight: 700 !important;
  font-size: 1.15em !important;
  letter-spacing: 0.5px !important;
}

.is-chat-container {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 450px;
  height: calc(100vh - 120px);
  min-width: 300px;
  min-height: 400px;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  z-index: 1000;
  background-color: white;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
  resize: none;
}

.is-chat-header {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
  color: white;
  padding: 15px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  border-bottom: 2px solid #c41e3a;
}

.is-close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

.is-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
}

.is-message {
  margin-bottom: 10px;
  max-width: 80%;
  padding: 10px;
  border-radius: 10px;
  word-wrap: break-word;
  font-size: 0.95em !important;
  line-height: 1.7 !important;
  letter-spacing: 0.01em !important;
}

.is-user-message {
  background-color: #ffe6e6;
  align-self: flex-end;
  border-left: 3px solid #c41e3a;
  font-weight: 500 !important;
}

.is-bot-message {
  background-color: #f5f5f5;
  align-self: flex-start;
  border-left: 3px solid #c41e3a;
  font-weight: 400 !important;
}

.is-chat-input {
  padding: 15px;
  display: flex;
  border-top: 1px solid #e0e0e0;
  background-color: #f5f5f5;
  box-sizing: border-box;
}

#is-message-input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
  margin-right: 10px;
  min-width: 0;
  font-size: 0.95em !important;
  font-weight: 400 !important;
  letter-spacing: 0.01em !important;
}

#is-message-input::placeholder {
  font-weight: 300 !important;
  font-style: italic !important;
  opacity: 0.6 !important;
}

#is-message-input:focus {
  border-color: #c41e3a;
  box-shadow: 0 0 0 2px rgba(196, 30, 58, 0.1);
}

#is-send-btn {
  border: none;
  background-color: #c41e3a;
  color: white;
  padding: 10px 15px;
  margin-left: 0;
  margin-right: 15px;
  border-radius: 20px;
  cursor: pointer;
  min-width: 60px;
  white-space: nowrap;
  font-weight: 500 !important;
  letter-spacing: 0.03em !important;
}

.is-loading {
  align-self: center;
  margin: 10px 0;
  display: none;
}

.is-loading-dots {
  display: flex;
}

.is-loading-dot {
  width: 8px;
  height: 8px;
  background-color: #c41e3a;
  border-radius: 50%;
  margin: 0 3px;
  animation: is-pulse 1.5s infinite ease-in-out;
}

.is-loading-dot:nth-child(2) {
  animation-delay: 0.3s;
}

.is-loading-dot:nth-child(3) {
  animation-delay: 0.6s;
}

@keyframes is-pulse {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.2); opacity: 1; }
}

.is-suggested-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 15px;
}

.is-question-btn {
  background-color: #f5f5f5;
  border: 1px solid #c41e3a;
  border-radius: 20px;
  padding: 8px 15px;
  font-size: 0.9em !important;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #c41e3a;
  font-weight: 400 !important;
  letter-spacing: 0.02em !important;
}

.is-question-btn:hover {
  background-color: #c41e3a;
  color: white;
  font-weight: 500 !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(196, 30, 58, 0.3);
}

.is-open-chat-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: #c41e3a;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), 
              inset 0 0 15px 5px rgba(255, 255, 255, 0.8),
              0 0 0 4px rgba(255, 255, 255, 0.5);
  z-index: 999;
  transition: all 0.3s ease;
  border: 3px solid rgba(255, 255, 255, 0.7);
  text-shadow: 0 0 8px rgba(255, 255, 255, 1);
}

.is-open-chat-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4), 
              inset 0 0 20px 8px rgba(255, 255, 255, 0.9),
              0 0 0 6px rgba(255, 255, 255, 0.6);
}

.is-chat-prompt {
  position: fixed;
  bottom: 30px;
  right: 90px;
  background-color: white;
  padding: 10px 15px;
  border-radius: 20px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  font-size: 14px;
  z-index: 998;
  display: none;
  animation: is-fade-in 0.5s ease-in-out;
  border: 1px solid #c41e3a;
  color: #333;
  font-weight: 400 !important;
}

@keyframes is-fade-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes is-fade-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

.is-fade-out {
  animation: is-fade-out 0.5s ease-in-out;
}

.is-chat-footer {
  padding: 10px 15px;
  text-align: center;
  font-size: 12px;
  border-top: 1px solid #e0e0e0;
  background-color: #f5f5f5;
  font-weight: 300 !important;
}

.is-chat-footer a {
  color: #c41e3a;
  text-decoration: none;
  font-weight: 500 !important;
}

.is-chat-footer a:hover {
  text-decoration: underline;
}

@keyframes is-blink-attention {
  0% { 
    transform: scale(1); 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), 
                inset 0 0 15px 5px rgba(255, 255, 255, 0.8),
                0 0 0 4px rgba(255, 255, 255, 0.5);
  }
  50% { 
    transform: scale(1.15); 
    box-shadow: 0 4px 25px rgba(196, 30, 58, 0.6), 
                inset 0 0 25px 10px rgba(255, 255, 255, 1),
                0 0 0 8px rgba(255, 255, 255, 0.8),
                0 0 30px 5px rgba(255, 255, 255, 0.6);
  }
  100% { 
    transform: scale(1); 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), 
                inset 0 0 15px 5px rgba(255, 255, 255, 0.8),
                0 0 0 4px rgba(255, 255, 255, 0.5);
  }
}

.is-blink-animation {
  animation: is-blink-attention 1.2s ease-in-out;
}

.is-chat-fade-in {
  opacity: 1;
  transform: translateY(0);
}

.is-chat-fade-out {
  opacity: 0;
  transform: translateY(20px);
}

.is-resize-handle {
  position: absolute;
  width: 20px;
  height: 20px;
  top: 8px;
  left: 8px;
  cursor: nwse-resize;
  z-index: 1002;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.is-resize-handle::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid #fff;
  border-right: none;
  border-bottom: none;
  top: 2px;
  left: 2px;
}

.is-resize-handle::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border: 2px solid #fff;
  border-right: none;
  border-bottom: none;
  top: 8px;
  left: 8px;
}

.is-resizing {
  transition: none !important;
  user-select: none !important;
}

#is-message-input:disabled {
  background-color: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

#is-send-btn:disabled {
  background-color: #cccccc;
  cursor: not-allowed;
  opacity: 0.7;
}

#is-send-btn:disabled .is-send-btn-text,
#is-send-btn:disabled .is-send-btn-icon {
  opacity: 0.7;
}

/* Font smoothing per una migliore leggibilità */
.is-chatbot-wrapper,
.is-chatbot-wrapper * {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Stili specifici per dispositivi mobili */
@media screen and (max-width: 768px) {
  .is-resize-handle {
    display: none !important;
  }
  
  .is-chat-container {
    width: 90% !important;
    max-width: 350px !important;
    right: 5% !important;
    margin: 0 !important;
    left: auto !important;
    resize: none !important;
  }
  
  .is-chat-input {
    padding: 10px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  
  #is-send-btn {
    margin-right: 0 !important;
    padding: 8px 12px !important;
    min-width: 60px !important;
    white-space: nowrap !important;
    font-size: 14px !important;
    flex-shrink: 0 !important;
  }
  
  #is-message-input {
    margin-right: 8px !important;
    flex: 1 !important;
    min-width: 0 !important;
    padding: 8px !important;
  }
}

@media screen and (min-width: 769px) {
  .is-chat-container {
    max-width: none;
  }
}

.is-send-btn-text {
  display: inline-block;
}

.is-send-btn-icon {
  display: none;
  font-size: 22px;
  line-height: 1;
  vertical-align: middle;
}

#is-send-btn .is-send-btn-icon {
  margin: 0;
  padding: 0;
}

/* Stili specifici per dispositivi mobili molto piccoli */
@media screen and (max-width: 389px) {
  #is-send-btn {
    min-width: 40px !important;
    width: 40px !important;
    height: 40px !important;
    padding: 8px !important;
    border-radius: 50% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    font-size: 18px !important;
  }
  
  .is-send-btn-text {
    display: none !important;
  }
  
  .is-send-btn-icon {
    display: inline-block !important;
    font-size: 22px !important;
  }
  
  #is-send-btn .is-send-btn-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  
  .is-chat-input {
    padding: 8px !important;
  }
  
  #is-message-input {
    margin-right: 6px !important;
  }
}

/* Stili per elementi Markdown nei messaggi */
.is-bot-message h1,
.is-bot-message h2,
.is-bot-message h3,
.is-bot-message h4,
.is-bot-message h5,
.is-bot-message h6 {
  margin-top: 10px;
  margin-bottom: 5px;
  font-weight: 600 !important;
  line-height: 1.2;
}

.is-bot-message h1 { font-size: 1.5em; }
.is-bot-message h2 { font-size: 1.3em; }
.is-bot-message h3 { font-size: 1.2em; }
.is-bot-message h4 { font-size: 1.1em; }
.is-bot-message h5 { font-size: 1em; }
.is-bot-message h6 { font-size: 0.9em; }

.is-bot-message p {
  margin-top: 5px;
  margin-bottom: 5px;
}

.is-bot-message ul,
.is-bot-message ol {
  margin-top: 5px;
  margin-bottom: 5px;
  padding-left: 20px;
}

.is-bot-message li {
  margin-bottom: 3px;
}

.is-bot-message a {
  color: #c41e3a;
  text-decoration: underline;
  font-weight: 500 !important;
}

.is-bot-message a:hover {
  text-decoration: none;
}

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

.is-bot-message pre {
  background-color: #f0f0f0;
  padding: 10px;
  border-radius: 5px;
  overflow-x: auto;
  margin: 5px 0;
}

.is-bot-message pre code {
  background-color: transparent;
  padding: 0;
}

.is-bot-message blockquote {
  border-left: 3px solid #c41e3a;
  padding-left: 10px;
  margin-left: 10px;
  color: #666;
  font-style: italic;
}

.is-bot-message table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
}

.is-bot-message th,
.is-bot-message td {
  border: 1px solid #ddd;
  padding: 5px;
  text-align: left;
}

.is-bot-message th {
  background-color: #f0f0f0;
  font-weight: 600 !important;
}

.is-bot-message img {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
  margin: 5px 0;
}