/**
 * Chat Widget Styles - Figma Design v2
 * Minimal monochrome design
 */

/* FAB Button */
.chat-fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ffffff;
  color: #171717;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.2s ease,
    background 0.2s ease,
    opacity 0.3s ease;
  z-index: 9998;
}

.chat-fab:hover {
  transform: scale(1.05);
  background: #e5e5e5;
}

.chat-fab.hidden {
  opacity: 0;
  pointer-events: none;
}

.chat-fab.open {
  opacity: 0;
  pointer-events: none;
}

.chat-fab svg {
  width: 24px;
  height: 24px;
}

/* Chat Overlay */
.chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 16px;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.chat-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Chat Container */
.chat-container {
  width: 100%;
  max-width: 400px;
  height: 70vh;
  max-height: 600px;
  background: #ffffff;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  border: 1px solid #e5e5e5;
}

.chat-overlay.open .chat-container {
  transform: translateY(0);
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e5e5e5;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #737373;
}

.chat-header-icon svg {
  width: 20px;
  height: 20px;
}

.chat-header-title {
  font-weight: 400;
  font-size: 15px;
  color: #171717;
  letter-spacing: -0.01em;
}

.chat-close {
  background: transparent;
  border: none;
  color: #737373;
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition:
    background 0.2s ease,
    color 0.2s ease;
  /* Touch optimization */
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-close:hover {
  background: #f5f5f5;
  color: #171717;
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
}

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

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #e5e5e5;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #d4d4d4;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: chatFadeIn 0.3s ease-out;
}

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

.chat-message.user {
  align-self: flex-end;
}

.chat-message.assistant {
  align-self: flex-start;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  letter-spacing: -0.01em;
}

.chat-message.user .chat-bubble {
  background: #171717;
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-bubble {
  background: #f5f5f5;
  color: #171717;
  border-bottom-left-radius: 4px;
}

/* Formatted markdown inside bubbles */
.chat-bubble strong {
  font-weight: 600;
}
.chat-bubble em {
  font-style: italic;
}
.chat-bubble ul {
  margin: 6px 0;
  padding-left: 18px;
  list-style: disc;
}
.chat-bubble ul li {
  margin-bottom: 2px;
}

/* Loading dots animation */
.loading-dots {
  display: inline-flex;
  gap: 3px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background: #737373;
  border-radius: 50%;
  animation: loadingDot 1.4s infinite;
  opacity: 0.3;
}

.loading-dots span:nth-child(1) {
  animation-delay: 0s;
}
.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loadingDot {
  0%,
  60%,
  100% {
    opacity: 0.3;
  }
  30% {
    opacity: 1;
  }
}

/* Theater Cards */
.chat-theaters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
  width: 100%;
}

.chat-container .theater-card {
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  padding: 14px;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.chat-container .theater-card:hover {
  border-color: #171717;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.chat-container .theater-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
  gap: 8px;
}

.chat-container .theater-header .theater-name {
  font-weight: 500;
  font-size: 14px;
  color: #171717;
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
  line-height: 1.3;
}

.chat-container .chat-share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border: none;
  background: #f5f5f5;
  color: #525252;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition:
    color 0.15s,
    background 0.15s;
}

.chat-container .chat-share-btn:hover {
  color: #171717;
  background: #e5e5e5;
}

.chat-container .chat-share-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.chat-container .theater-city {
  font-size: 13px;
  color: #737373;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-container .theater-distance {
  color: #171717;
  font-weight: 500;
}

.chat-container .theater-showtimes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.showtime-chip {
  display: inline-block;
  padding: 6px 12px;
  background: #171717;
  color: white;
  font-size: 13px;
  font-weight: 500;
  border-radius: 20px;
  text-decoration: none;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
}

.showtime-chip:hover {
  background: #404040;
  transform: scale(1.02);
}

.showtime-chip.is-vo {
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.vo-badge {
  margin-left: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

/* Grouped showtimes by date (nearby-all flow) */
.theater-showtimes-grouped {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.theater-date-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.theater-date-label {
  font-weight: 500;
  min-width: 48px;
  color: #737373;
}

.theater-date-times {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* Abandon chat button (mobile only) */
.chat-abandon {
  display: none;
}

/* Chat Input (film info mode only) */
.chat-input-container {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  background: #ffffff;
  border-top: 1px solid #e5e5e5;
}

.chat-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #e5e5e5;
  border-radius: 24px;
  font-size: 15px;
  outline: none;
  background: #fafafa;
  color: #171717;
  transition:
    border-color 0.2s ease,
    background 0.2s ease;
  letter-spacing: -0.01em;
}

.chat-input::placeholder {
  color: #a3a3a3;
}

.chat-input:focus {
  border-color: #171717;
  background: #ffffff;
}

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #171717;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
  flex-shrink: 0;
}

.chat-send:hover {
  background: #404040;
  transform: scale(1.05);
}

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

.chat-send svg {
  width: 20px;
  height: 20px;
}

/* Clickable Chips */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: #ffffff;
  color: #171717;
  font-size: 14px;
  font-weight: 400;
  border: 1px solid #e5e5e5;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: -0.01em;
}

.chat-chip:hover {
  border-color: #171717;
  background: #fafafa;
}

.chat-chip:active {
  transform: scale(0.98);
}

.chat-chip-best {
  border-color: #171717;
  font-weight: 500;
}

.chat-chip-outline {
  background: #ffffff;
  color: #171717;
  border: 1px solid #e5e5e5;
}

.chat-chip-outline:hover {
  border-color: #171717;
  background: #fafafa;
}

.chat-chip-film-info {
  background: #ffffff;
  color: #171717;
  border: 1px solid #171717;
  width: 100%;
  justify-content: center;
}

.chat-chip-film-info:hover {
  background: #171717;
  color: #ffffff;
}

.chat-chip-location {
  background: #171717;
  color: #ffffff;
  border-color: #171717;
  width: 100%;
  justify-content: center;
}

.chat-chip-location:hover {
  background: #404040;
  border-color: #404040;
}

.chat-chips-divider {
  text-align: center;
  color: #a3a3a3;
  font-size: 13px;
  margin: 10px 0;
  letter-spacing: -0.01em;
}

.chat-chip-other {
  background: #ffffff;
  color: #737373;
  border: 1px dashed #d4d4d4;
}

.chat-chip-other:hover {
  background: #fafafa;
  color: #171717;
  border-color: #737373;
}

.chat-chip-search {
  background: #171717;
  color: #ffffff;
  border-color: #171717;
}

.chat-chip-search:hover {
  background: #404040;
  border-color: #404040;
}

/* External Search Results */
.chat-external-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}

.external-result-card {
  display: block;
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  padding: 14px;
  text-decoration: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.1s ease;
}

.external-result-card:hover {
  border-color: #171717;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.external-result-source {
  font-size: 11px;
  font-weight: 600;
  color: #737373;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.external-result-title {
  font-size: 14px;
  font-weight: 500;
  color: #171717;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Typing cursor effect */
.chat-bubble.typing::after {
  content: '|';
  animation: blink 0.7s infinite;
  margin-left: 1px;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}

/* Notify Form (chat) */
.chat-notify-form {
  width: 100%;
}

.chat-notify-form form {
  display: flex;
  gap: 8px;
}

.chat-notify-email {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e5e5e5;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  background: #fafafa;
  color: #171717;
  transition:
    border-color 0.2s ease,
    background 0.2s ease;
}

.chat-notify-email::placeholder {
  color: #a3a3a3;
}

.chat-notify-email:focus {
  border-color: #171717;
  background: #ffffff;
}

.chat-notify-submit {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #171717;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
}

.chat-notify-submit:hover {
  background: #404040;
  transform: scale(1.05);
}

.chat-notify-submit:active {
  transform: scale(0.95);
}

.chat-notify-privacy {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: #737373;
  cursor: pointer;
}

.chat-notify-privacy input[type='checkbox'] {
  width: 14px;
  height: 14px;
  accent-color: #171717;
}

.chat-notify-privacy a {
  color: #171717;
  text-decoration: underline;
}

.chat-notify-status {
  font-size: 13px;
  margin-top: 6px;
  min-height: 18px;
}

/* Mobile fullscreen */
@media (max-width: 480px) {
  .chat-overlay {
    padding: 0;
  }

  .chat-container {
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    position: relative;
  }

  /* Header fisso in alto */
  .chat-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  }

  /* Indicatore swipe-down */
  .chat-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: #e5e5e5;
    border-radius: 2px;
  }

  .chat-header {
    padding-top: 24px;
  }

  .chat-fab {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 16px;
  }

  .chat-message {
    max-width: 90%;
  }

  .chat-chips {
    gap: 6px;
  }

  .chat-chip {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Abandon chat button */
  .chat-abandon {
    display: block;
    width: 100%;
    padding: 10px;
    background: none;
    border: none;
    border-top: 1px solid #e5e5e5;
    color: #737373;
    font-size: 13px;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: color 0.2s ease;
  }

  .chat-abandon:active {
    color: #171717;
  }

  /* Share button mobile - più grande per touch */
  .chat-container .chat-share-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .chat-container .chat-share-btn svg {
    width: 18px;
    height: 18px;
  }
}
