/*
 * English Coach AI inline chat
 * Test version: displayed only when ?chat_test=1 is present.
 */

.eca-chat-entry {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9000;
  display: none;
}

.eca-chat-entry.is-visible {
  display: block;
}

.eca-chat-entry-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: #1f5eff;
  color: #fff;
  font: inherit;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  cursor: pointer;
}

.eca-chat-entry-button:hover,
.eca-chat-entry-button:focus-visible {
  transform: translateY(-1px);
}

.eca-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 82px;
  z-index: 8999;
  display: none;
  flex-direction: column;
  width: min(390px, calc(100vw - 28px));
  height: min(600px, calc(100vh - 120px));
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,.22);
  overflow: hidden;
}

.eca-chat-panel.is-open {
  display: flex;
}

.eca-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #1f5eff;
  color: #fff;
}

.eca-chat-title {
  font-weight: 700;
}

.eca-chat-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.eca-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f6f7fb;
}

.eca-chat-message {
  display: flex;
  margin-bottom: 12px;
}

.eca-chat-message.user {
  justify-content: flex-end;
}

.eca-chat-bubble {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  background: #fff;
  color: #222;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.eca-chat-message.user .eca-chat-bubble {
  background: #1f5eff;
  color: #fff;
}

.eca-chat-quick {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  background: #fff;
  border-top: 1px solid #eee;
}

.eca-chat-quick button {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #d7dbe5;
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.eca-chat-status {
  min-height: 22px;
  padding: 2px 14px;
  background: #fff;
  color: #666;
  font-size: 12px;
}

.eca-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #eee;
}

.eca-chat-input {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 100px;
  padding: 10px;
  border: 1px solid #ccd1dc;
  border-radius: 10px;
  font: inherit;
}

.eca-chat-send {
  border: 0;
  border-radius: 10px;
  padding: 0 15px;
  background: #1f5eff;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.eca-chat-send:disabled {
  opacity: .55;
  cursor: default;
}

@media (max-width: 640px) {
  .eca-chat-entry {
    position: fixed;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 10001;
  }

  .eca-chat-entry-button {
    min-height: 46px;
    padding: 0 16px;
  }

  .eca-chat-panel {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    bottom: calc(68px + env(safe-area-inset-bottom));
    z-index: 10000;

    width: auto;
    max-width: none;

    height: 72vh;
    height: 72dvh;
    max-height: 620px;

    margin: 0;

    border-radius: 18px;
    overflow: hidden;
  }

  .eca-chat-panel.is-open {
    display: flex;
    flex-direction: column;
  }

  .eca-chat-header {
    flex: 0 0 auto;
  }

  .eca-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .eca-chat-quick {
    flex: 0 0 auto;
  }

  .eca-chat-form {
    flex: 0 0 auto;
    padding-bottom: max(
      10px,
      env(safe-area-inset-bottom)
    );
    background: #fff;
  }
}

.eca-chat-disclaimer {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 12px 9px;
  background: #fff;
  color: #777;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
}
