/* Spain Tax Experts — Asistente Fiscal Panel
   Slide-in chat panel injected by the FAB or rendered full-page on
   /asistente/ and /en/assistant/. Dark mode coherent with the rest
   of the site. */

/* Backdrop overlay (mobile only) */
.asistente-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.asistente-panel-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
@media (min-width: 601px) {
  .asistente-panel-overlay {
    display: none;
  }
}

/* Main panel container */
.asistente-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 400px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: #0b1220;
  border: 1px solid #1f2a45;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #e7edf5;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.asistente-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Mobile: full screen */
@media (max-width: 600px) {
  .asistente-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    bottom: 0;
    right: 0;
  }
}

/* Header */
.asistente-panel-header {
  padding: 14px 18px;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  border-bottom: 1px solid #1f2a45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.asistente-panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}
.asistente-panel-title .icon {
  font-size: 20px;
}
.asistente-panel-close {
  background: transparent;
  border: 0;
  color: #ffffff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.asistente-panel-close:hover,
.asistente-panel-close:focus-visible {
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

/* Messages area */
.asistente-panel-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.asistente-panel-messages::-webkit-scrollbar {
  width: 6px;
}
.asistente-panel-messages::-webkit-scrollbar-track {
  background: transparent;
}
.asistente-panel-messages::-webkit-scrollbar-thumb {
  background: #1f2a45;
  border-radius: 3px;
}

/* Message bubbles */
.asistente-msg {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.asistente-msg-bot {
  align-self: flex-start;
  background: #101828;
  border: 1px solid #1f2a45;
  color: #e7edf5;
  border-bottom-left-radius: 4px;
}
.asistente-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.asistente-msg-error {
  align-self: center;
  background: #2a1a1a;
  border: 1px solid #ef4444;
  color: #fecaca;
  font-size: 13px;
  text-align: center;
  max-width: 95%;
}

/* Typing indicator */
.asistente-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 14px 16px;
  background: #101828;
  border: 1px solid #1f2a45;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.asistente-typing span {
  width: 7px;
  height: 7px;
  background: #7dd3fc;
  border-radius: 50%;
  animation: asistente-bounce 1.2s infinite ease-in-out;
}
.asistente-typing span:nth-child(2) { animation-delay: 0.15s; }
.asistente-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes asistente-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input area */
.asistente-panel-input {
  padding: 12px;
  border-top: 1px solid #1f2a45;
  background: #0b1220;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.asistente-panel-textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: 11px 14px;
  background: #1b2437;
  border: 1px solid #1f2a45;
  border-radius: 10px;
  color: #e7edf5;
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.4;
  resize: none;
  outline: none;
  transition: border-color 0.15s ease;
}
.asistente-panel-textarea:focus {
  border-color: #7dd3fc;
}
.asistente-panel-textarea::placeholder {
  color: #6b7280;
}
.asistente-panel-send {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  border: 1px solid #60a5fa;
  border-radius: 10px;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.asistente-panel-send:hover:not(:disabled) {
  transform: scale(1.05);
}
.asistente-panel-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Footer */
.asistente-panel-footer {
  padding: 8px 12px;
  background: #0b1220;
  border-top: 1px solid #1f2a45;
  text-align: center;
  font-size: 11px;
  color: #6b7280;
  flex-shrink: 0;
}
.asistente-panel-footer a {
  color: #7dd3fc;
  text-decoration: none;
}
.asistente-panel-footer a:hover {
  text-decoration: underline;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .asistente-panel,
  .asistente-panel-overlay {
    transition: opacity 0.1s ease;
    transform: none !important;
  }
  .asistente-typing span {
    animation: none;
  }
}

/* Full-page mode (used in /asistente/ and /en/assistant/) */
.asistente-panel--fullpage {
  position: relative;
  inset: auto;
  width: 100%;
  max-width: 800px;
  margin: 32px auto;
  height: calc(100vh - 240px);
  max-height: 800px;
  bottom: auto;
  right: auto;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  border-radius: 16px;
}
@media (max-width: 600px) {
  .asistente-panel--fullpage {
    margin: 0;
    height: calc(100vh - 64px);
    max-height: none;
    border-radius: 0;
    border: none;
  }
}
