:root {
  --pcb-primary: #a32b24; /* saci Blue */
  --pcb-primary-hover: #9c1a13; /* Darker variant for hover */
  --pcb-bg: rgb(27 27 27 / 85%); /* Slate 900 Glass */
  --pcb-border: rgba(255, 255, 255, 0.1);
  --pcb-text: #f8fafc;
  --pcb-text-muted: #adadad;
  --pcb-bot-msg: rgb(255 16 3 / 7%);
  --pcb-user-msg: var(--pcb-primary);
}

#saci-chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Chat Button */
.pcb-toggle-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pcb-primary), #e53935);
  color: white;
  border: none;
  box-shadow: 0 10px 25px rgba(196, 33, 24, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.pcb-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 15px 30px rgba(196, 33, 24, 0.5);
}

.pcb-toggle-btn.pcb-active {
  transform: rotate(90deg) scale(0.9);
}

/* Chat Window */
.pcb-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 120px);
  max-width: calc(100vw - 48px);
  background: var(--pcb-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--pcb-border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.pcb-window.pcb-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.pcb-header {
  padding: 20px;
  border-bottom: 1px solid var(--pcb-border);
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
}

.pcb-avatar {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 15px;
}

.pcb-title {
  flex: 1;
}

.pcb-title h3 {
  margin: 0;
  color: var(--pcb-text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.pcb-title p {
  margin: 2px 0 0;
  color: var(--pcb-text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.pcb-online-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px #10b981;
}

/* Messages Area */
.pcb-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--pcb-primary) transparent;
}

.pcb-messages::-webkit-scrollbar {
  width: 6px;
}

.pcb-messages::-webkit-scrollbar-thumb {
  background-color: var(--pcb-border);
  border-radius: 10px;
}

.pcb-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--pcb-text);
  animation: pcbFadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  word-wrap: break-word;
}

@keyframes pcbFadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.pcb-msg-bot {
  align-self: flex-start;
  background: var(--pcb-bot-msg);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--pcb-border);
}

.pcb-msg-user {
  align-self: flex-end;
  background: #292929;
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgb(53 53 53 / 30%);
}

/* Typing Indicator */
.pcb-typing {
  display: flex;
  gap: 4px;
  padding: 15px 20px;
  background: var(--pcb-bot-msg);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  border: 1px solid var(--pcb-border);
}

.pcb-typing span {
  width: 6px;
  height: 6px;
  background-color: var(--pcb-text-muted);
  border-radius: 50%;
  animation: pcbBounce 1.4s infinite ease-in-out both;
}

.pcb-typing span:nth-child(1) { animation-delay: -0.32s; }
.pcb-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes pcbBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Input Area */
.pcb-input-area {
  padding: 15px;
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid var(--pcb-border);
  display: flex;
  gap: 10px;
  align-items: center;
}

.pcb-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--pcb-border);
  color: var(--pcb-text);
  padding: 10px 14px;
  border-radius: 20px;
  height: 46px;
  font-size: 13.5px;
  outline: none;
  transition: all 0.3s ease;
  font-family: inherit;
  text-transform: none !important;
}

.pcb-input:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--pcb-primary);
  box-shadow: 0 0 0 2px rgba(196, 33, 24, 0.2);
}

.pcb-input::placeholder {
  color: var(--pcb-text-muted);
  text-transform: none !important;
  font-size: inherit;
}

.pcb-send-btn {
  background: var(--pcb-primary);
  color: white;
  border: none;
  width: 44px;
  padding: 5px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.pcb-send-btn:hover {
  background: var(--pcb-primary-hover);
  transform: scale(1.05);
}

.pcb-send-btn:active {
  transform: scale(0.95);
}

/* Button Link Styling */
.pcb-button-link {
    margin-top: 10px;
    padding: 8px 16px;
    background-color: var(--pcb-primary);
    color: #fff !important;
    text-decoration: none;
    border-radius: 10px;
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 10px rgba(196, 33, 24, .3);
    transition: all .3s ease;
    text-align: center;
}

.pcb-button-link:hover {
  background-color: var(--pcb-primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(196, 33, 24, 0.4);
}

/* Fix per als enllaços genèrics de la IA (Projectes/Imatges) perquè siguin blancs i no heretin el negre del tema */
.pcb-msg a {
  color: #ffffff !important;
}


/* Responsive */
@media (max-width: 480px) {
  .pcb-window {
    width: calc(100vw - 32px);
    right: -8px;
    bottom: 70px;
    height: 500px;
  }
}
