/* CAGEPA Chat Widget — estilos */
@import url('https://cdn.jsdelivr.net/npm/@n8n/chat/dist/style.css');

#n8n-chat {
  --chat--color-primary:               #289dcc;
  --chat--color-primary-shade-50:      #1e87b4;
  --chat--color-primary-shade-100:     #005274;
  --chat--color-secondary:             #faa51a;
  --chat--color-secondary-shade-50:    #f47a20;
  --chat--color-white:                 #ffffff;
  --chat--color-light:                 #f7f7f7;
  --chat--color-light-shade-50:        #efefef;
  --chat--color-light-shade-100:       #e4e4e4;
  --chat--color-medium:                #d3d3d3;
  --chat--color-dark:                  #1c1c1c;
  --chat--color-disabled:              #a5a5a5;
  --chat--color-typing:                #454545;

  --chat--spacing:                     1rem;
  --chat--border-radius:               0.75rem;
  --chat--transition-duration:         0.2s;

  --chat--header--padding:             1.25rem;
  --chat--header--background:          #005274;
  --chat--header--color:               #ffffff;
  --chat--header--border-top:          none;
  --chat--header--border-bottom:       none;
  --chat--heading--font-size:          1.15rem;
  --chat--subtitle--font-size:         0.85rem;
  --chat--subtitle--line-height:       1.5;

  --chat--textarea--height:            52px;
  --chat--input--font-size:            0.95rem;
  --chat--input--border-radius:        0.5rem;

  --chat--message--font-size:          0.95rem;
  --chat--message--padding:            0.85rem 1rem;
  --chat--message--border-radius:      0.75rem;
  --chat--message-line-height:         1.55;
  --chat--message--bot--background:    #ffffff;
  --chat--message--bot--color:         #1c1c1c;
  --chat--message--bot--border:        1px solid #e4e4e4;
  --chat--message--user--background:   #289dcc;
  --chat--message--user--color:        #ffffff;
  --chat--message--user--border:       none;
  --chat--message--pre--background:    rgba(0, 82, 116, 0.08);

  --chat--body--background:            #f7f7f7;

  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#n8n-chat .chat-header { display: none !important; }

#n8n-chat [class*="powered"],
#n8n-chat [class*="branding"] { display: none !important; }

#n8n-chat .chat-layout {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
  min-height: 0 !important;
  height: 100% !important;
  width: 100% !important;
  overflow: hidden !important;
}

#n8n-chat .chat-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
}
#n8n-chat .chat-messages-list {
  min-height: 0 !important;
}

#n8n-chat .chat-footer {
  flex: 0 0 auto !important;
  flex-shrink: 0 !important;
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
  background: #ffffff !important;
  border-top: 1px solid #e4e4e4 !important;
}

#n8n-chat .chat-inputs,
#n8n-chat .chat-input {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  width: 100% !important;
  height: 4.5rem !important;
  box-sizing: border-box !important;
  padding: 0.75rem 1rem !important;
}

#n8n-chat .chat-inputs textarea,
#n8n-chat .chat-input textarea,
#n8n-chat textarea {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
  resize: none !important;
  font-size: 16px !important;
}

#n8n-chat .chat-input-send-button,
#n8n-chat button[class*="send"] {
  flex: 0 0 auto !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

#chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #289dcc;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(40,157,204,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}
#chat-fab:hover { background: #005274; transform: scale(1.06); }
#chat-fab svg { display: block; }

.chat-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 24px 96px;
  pointer-events: none;
}
.chat-modal[hidden] { display: none; }
.chat-modal__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  pointer-events: all;
}
.chat-modal__window {
  position: relative;
  z-index: 1;
  width: 400px;
  height: 600px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: all;
}
.chat-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #005274;
  color: #fff;
  flex-shrink: 0;
}
.chat-modal__header span {
  font-weight: 600;
  font-size: 15px;
  font-family: Inter, system-ui, sans-serif;
}
.chat-modal__close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.8;
}
.chat-modal__close:hover { opacity: 1; }

@media (max-width: 640px) {
  #chat-fab {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }
  .chat-modal {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }
  .chat-modal__window {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .chat-modal__header {
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
  }
  #n8n-chat .chat-inputs,
  #n8n-chat .chat-input {
    padding: 0.6rem 0.75rem !important;
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom)) !important;
    height: auto !important;
    min-height: 4.5rem !important;
  }
  #n8n-chat .chat-message {
    font-size: 0.95rem !important;
  }
}
