/* Cross-device hardening for Jennifer Thompson Portfolio Assistant */

.jt-chatbot {
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
}

.jt-chat-panel {
  max-height: calc(100dvh - 110px);
}

.jt-chat-launcher,
.jt-chat-close,
.jt-chat-suggestion,
.jt-chat-send,
.jt-chat-link {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.jt-chat-input {
  font-size: 16px;
}

/* Tablet portrait and smaller laptops */
@media (min-width: 561px) and (max-width: 1024px) {
  .jt-chatbot {
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
  }

  .jt-chat-panel {
    width: min(420px, calc(100vw - 36px));
    height: min(620px, calc(100dvh - 112px));
    bottom: 72px;
  }

  .jt-chat-launcher {
    min-height: 58px;
  }

  .jt-chat-launcher-icon {
    width: 40px;
    height: 40px;
  }

  .jt-chat-suggestion {
    min-height: 48px;
    padding: 11px 13px;
  }

  .jt-chat-close,
  .jt-chat-send {
    min-height: 44px;
  }
}

/* Phone portrait */
@media (max-width: 560px) {
  .jt-chatbot {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: auto;
  }

  .jt-chat-launcher {
    min-height: 54px;
    padding: 8px 13px 8px 8px;
    gap: 8px;
  }

  .jt-chat-launcher-icon {
    width: 38px;
    height: 38px;
  }

  .jt-chat-launcher-text {
    font-size: 13px;
  }

  .jt-chat-panel {
    position: fixed;
    inset: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 20px;
  }

  .jt-chat-header {
    padding: 14px;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
  }

  .jt-chat-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 15px;
  }

  .jt-chat-title {
    font-size: 17px;
  }

  .jt-chat-subtitle {
    font-size: 11px;
  }

  .jt-chat-close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .jt-chat-log {
    padding: 13px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .jt-chat-message {
    max-width: 94%;
    font-size: 13px;
  }

  .jt-chat-suggestion {
    min-height: 48px;
    padding: 11px 12px;
    font-size: 12px;
  }

  .jt-chat-footer {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .jt-chat-form {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .jt-chat-input {
    min-height: 46px;
    font-size: 16px;
  }

  .jt-chat-send {
    min-width: 68px;
    min-height: 46px;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .jt-chat-panel {
    inset: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    border-radius: 16px;
  }

  .jt-chat-header {
    padding: 11px;
  }

  .jt-chat-header-icon {
    width: 42px;
    height: 42px;
  }

  .jt-chat-title {
    font-size: 16px;
  }

  .jt-chat-subtitle {
    display: none;
  }

  .jt-chat-log {
    padding: 10px;
  }

  .jt-chat-message {
    max-width: 96%;
  }

  .jt-chat-launcher-text {
    display: none;
  }

  .jt-chat-launcher {
    width: 56px;
    height: 56px;
    padding: 7px;
    border-radius: 18px;
  }

  .jt-chat-launcher-icon {
    width: 42px;
    height: 42px;
  }
}

/* Short-height and landscape phones */
@media (max-height: 560px) and (orientation: landscape) {
  .jt-chat-panel {
    position: fixed;
    inset: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 16px;
  }

  .jt-chat-header {
    padding: 9px 12px;
  }

  .jt-chat-header-icon {
    width: 38px;
    height: 38px;
  }

  .jt-chat-title {
    font-size: 15px;
  }

  .jt-chat-subtitle {
    display: none;
  }

  .jt-chat-log {
    padding: 9px 12px;
  }

  .jt-chat-message {
    margin-bottom: 7px;
    padding: 8px 10px;
  }

  .jt-chat-suggestions {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .jt-chat-suggestion {
    min-height: 40px;
    padding: 7px 9px;
  }

  .jt-chat-footer {
    padding: 8px 10px;
  }

  .jt-chat-disclaimer {
    display: none;
  }
}

/* Pointer devices keep hover treatment, touch devices do not depend on hover */
@media (hover: none) and (pointer: coarse) {
  .jt-chat-launcher:hover,
  .jt-chat-suggestion:hover,
  .jt-chat-send:hover {
    box-shadow: inherit;
  }

  .jt-chat-launcher:active,
  .jt-chat-suggestion:active,
  .jt-chat-send:active {
    transform: scale(0.98);
  }
}
