/**
 * Minimal Composer layout that mirrors the provided Figma frame:
 * single rounded field with embedded icons, matching colors and padding.
 */

:host {
  display: block;
  width: 100%;
  font-family: inherit;
}

.bcx-composer {
  width: 100%;
  display: flex;
  flex-direction: column;
  /* Inherits from <bcx-message-composer> host (floating: Inter stack from widget; is-component: page font) */
  font-family: inherit;
}

.bcx-composer__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-shrink: 0;
  gap: var(--bcx-space-2, 8px);
}

.bcx-composer__actions--no-attachments {
  justify-content: flex-end;
}

.bcx-composer__image-previews {
  display: flex;
  gap: var(--bcx-space-2, 8px);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--bcx-space-2, 8px);
  margin-top: 0;
  padding: var(--bcx-space-2, 8px) var(--bcx-space-3, 12px);
  border-radius: var(--bcx-component-radius-item, var(--bcx-radius-md, 12px));
  background: var(--bcx-bg-secondary, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--bcx-border-soft, rgba(0, 0, 0, 0.08));
  box-sizing: border-box;
  min-height: 0;
  animation: bcx-composer-preview-strip-in 0.2s ease-out;

  .dark & {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
  }
}

@keyframes bcx-composer-preview-strip-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bcx-composer__image-preview {
  width: 56px;
  height: 56px;
  border-radius: var(--bcx-component-radius-item, var(--bcx-radius-sm));
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--bcx-bg-secondary, #f8f9fa);
  transition: all 0.2s ease;
  flex-shrink: 0;

  .dark & {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
  }

  &:hover {
    transform: scale(1.02);
    border-color: rgba(0, 0, 0, 0.12);

    .dark & {
      border-color: rgba(255, 255, 255, 0.18);
    }

    .bcx-composer__image-remove {
      opacity: 1;
      transform: scale(1);
    }
  }
}

.bcx-composer__image-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bcx-composer__image-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--bcx-radius-full);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.2s ease;
  z-index: 10;

  .dark & {
    background: rgba(0, 0, 0, 0.7);
  }

  /* Touch / coarse pointer: always show remove — no hover */
  @media (hover: none), (pointer: coarse) {
    opacity: 0.92;
    transform: scale(1);
  }

  &:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: scale(1.1);

    .dark & {
      background: rgba(239, 68, 68, 0.95);
    }
  }

  &:active {
    transform: scale(0.95);
  }
}

.bcx-composer__image-remove svg {
  width: 12px;
  height: 12px;
  stroke: var(--bcx-white, #fff);
  stroke-width: 2.5;
}

.bcx-composer__field {
  background-color: var(--bcx-bg-secondary, #f9f9f9);
  border-radius: var(--bcx-component-radius-input, var(--bcx-radius-md));
  height: 110px;
  padding: var(--bcx-space-3);
  padding-top: 0;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: var(--bcx-space-2);
  transition: border var(--bcx-transition-fast);
  border: 1px solid var(--bcx-border-soft, rgba(0, 0, 0, 0.1));
  position: relative;
  z-index: 1; /* Ensure field is above messages when focused */

  .dark & {
    background-color: var(--bcx-dark-bg-secondary, #2b2a2a);
  }
}

.bcx-composer__field:focus-within {
  border-color: var(--bcx-primary-400);
  box-shadow: 0 0 0 4px var(--bcx-primary-100);
  outline: none;
  z-index: 2; /* Higher z-index when focused to ensure outline is visible */
}

.bcx-composer__media-btn {
  width: 36px;
  height: 36px;
  border: none;
  transition:
    transform 0.2s ease,
    background 0.2s ease;
  border-radius: var(--bcx-component-radius-button, var(--bcx-radius-sm));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--bcx-light-text-tertiary, #0f172a);
  background: rgba(0, 17, 51, 0.05);
  font-family: inherit;

  .dark & {
    background: var(--bcx-dark-bg-tertiary, #414141);
    color: var(--bcx-white, #fff);
  }
}

.bcx-composer__media-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.bcx-composer__media-btn:not(:disabled):hover {
  opacity: 0.8;
  transform: scale(1.05);
  transition: all 0.2s ease;
}

.bcx-composer__input {
  width: 100%;
  flex: 1;
  min-height: 36px;
  border: none;
  background: transparent;
  color: var(--bcx-light-text-primary, #1f2937);
  font-size: 15px;
  line-height: 1.4;
  padding: 0;
  padding-top: var(--bcx-space-3);
  margin: 0;
  resize: none;
  font-family: inherit;

  .dark & {
    color: var(--bcx-dark-text-quaternary, #d9d9d9);
  }
}

.bcx-composer__input::placeholder {
  color: var(--bcx-light-text-quaternary, #6b7280);
  font-weight: 400;
  font-family: inherit;
}

.dark .bcx-composer__input::placeholder {
  color: var(--bcx-dark-text-tertiary, #9ca3af);
}

.bcx-composer__input:focus {
  outline: none;
}

.bcx-composer__submit {
  width: 36px;
  height: 36px;
  border: none;
  transition:
    transform 0.2s ease,
    background 0.2s ease;
  border-radius: var(--bcx-component-radius-button, var(--bcx-radius-sm));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--bcx-primary-500);
  font-family: inherit;
}

.bcx-composer__submit:disabled {
  cursor: not-allowed;
  background: var(--bcx-primary-400);
  opacity: 0.6;
}

.bcx-composer__submit:not(:disabled):hover {
  opacity: 0.8;
  transform: scale(1.05);
  transition: all 0.2s ease;
}

.bcx-composer__submit-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bcx-composer__submit-icon svg {
  width: 18px;
  height: 18px;
  stroke: var(--bcx-white, #fff);
}

.bcx-composer__spinner {
  animation: bcx-composer-spin 1s linear infinite;
  transform-origin: center;
}

@keyframes bcx-composer-spin {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg); /* AUDYT: translate3d zamiast translateZ(0) dla spójności */
  }
  to {
    transform: translate3d(0, 0, 0) rotate(360deg); /* AUDYT: translate3d zamiast translateZ(0) dla spójności */
  }
}

@media (max-width: 480px) {
  .bcx-composer__media-btn {
    width: 38px;
    height: 38px;
  }
  .bcx-composer__submit {
    width: 38px;
    height: 38px;
  }
}
