/* Default */
:root {
  --msg-dock-height: min(480px, 52vh);
}

#open-modal {
  cursor: pointer;
}

/* Bottom dock shell — recipe stays visible above */
#CurrentmessagesDIV {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 1000;
  height: 0;
  overflow: visible;
  background: transparent;
  transition: opacity 0.25s ease, visibility 0.25s linear;
}

#modal-content-wrapper {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  z-index: 1001;
  width: 100%;
  max-width: 100%;
  height: var(--msg-dock-height);
  max-height: var(--msg-dock-height);
  background-color: #ffffff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease, opacity 0.25s ease, visibility 0.25s linear;
}

.msg-dock-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 48px 4px 16px;
  border-bottom: 1px solid #eee;
  background: #fff;
  position: relative;
}

.msg-dock-handle {
  display: block;
  width: 40px;
  height: 4px;
  margin-bottom: 6px;
  border-radius: 2px;
  background: #ccc;
}

.msg-dock-title {
  align-self: flex-start;
  font-size: 0.95rem;
  font-weight: 700;
  color: #333;
}

.msg-dock-body {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  min-width: 0;
  position: relative;
}

#msgers {
  width: 180px;
  min-width: 140px;
  max-width: 200px;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  background: #f5f5f5;
  border-right: 1px solid #dedede;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

#msgers::-webkit-scrollbar {
  width: 6px;
}

#msgers::-webkit-scrollbar-track {
  background: transparent;
}

#msgers::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

#msgers:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.28);
}

#msg-thread-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

#modal-content-wrapper #body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  padding: 0 12px 10px;
  width: 100%;
  box-sizing: border-box;
}

#SentMsgs {
  flex: 1 1 auto;
  height: auto;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(179, 176, 0, 0.45) transparent;
}

#SentMsgs::-webkit-scrollbar {
  width: 6px;
}

#SentMsgs::-webkit-scrollbar-track {
  background: transparent;
}

#SentMsgs::-webkit-scrollbar-thumb {
  background: rgba(179, 176, 0, 0.35);
  border-radius: 3px;
}

#SentMsgs:hover::-webkit-scrollbar-thumb {
  background: rgba(179, 176, 0, 0.55);
}

#modal-content-wrapper .containerwrite {
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 0 0;
  margin-top: 0;
  border-top: 1px solid #eee;
  background: #fff;
}

#modal-content-wrapper #editor {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 !important;
  min-width: 0 !important;
  width: 100%;
  box-sizing: border-box;
}

#modal-content-wrapper #editor #tools,
#modal-content-wrapper #editor #output {
  display: none !important;
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

#modal-content-wrapper #input {
  flex: 1 1 0;
  min-width: 0;
  width: 100% !important;
  max-width: none !important;
  float: none !important;
  min-height: 40px;
  max-height: 80px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 14px;
  background: #fff !important;
  color: #333 !important;
  border: 1px solid #ddd;
  border-radius: 22px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
}

#modal-content-wrapper #input:focus {
  outline: none;
  border-color: #b3b000;
  box-shadow: 0 0 0 2px rgba(179, 176, 0, 0.15);
}

#modal-content-wrapper #input:empty:not(:focus):before {
  color: #999;
}

.msg-back-btn {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 0;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: #f5f5f5;
  color: #333;
  font-size: 0.9rem;
  cursor: pointer;
  flex-shrink: 0;
}

.msg-back-btn:hover {
  background: #ebebeb;
}

#msg-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(179, 176, 0, 0.12);
  color: #b3b000;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

#msg-send-btn:hover {
  background: #b3b000;
  color: #fff;
}

#msg-send-btn:active {
  transform: scale(0.94);
}

#msg-send-btn .fa-paper-plane {
  font-size: 20px;
  pointer-events: none;
}

/* Room for dock so cibo can scroll above it */
#Recipe.msg-dock-open {
  padding-bottom: var(--msg-dock-height);
}

/* Open */
#CurrentmessagesDIV.open {
  visibility: visible;
  opacity: 1;
  pointer-events: none;
  height: auto;
}

#modal-content-wrapper.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Close Button */
.msg-close-btn,
#close-modal-desktop {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  top: 50%;
  right: 10px;
  left: auto;
  transform: translateY(-50%);
  z-index: 1002;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #f0f0f0;
  color: #555;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.msg-close-btn:hover,
#close-modal-desktop:hover {
  background: #e53935;
  color: #fff;
}

.msg-close-btn:active,
#close-modal-desktop:active {
  transform: translateY(-50%) scale(0.94);
}

.msg-close-btn .fa-times,
#close-modal-desktop .fa-times {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

#close-button-mobile {
  position: absolute;
  z-index: 1001;
  top: 0;
  right: 0;
  font-size: 20px;
  font-family: sans-serif;
  width: 50px;
  height: 50px;
}

#close-button-mobile .cmm-one {
  border-radius: 0;
  display: block;
  height: 2px;
  width: 25px;
  position: absolute;
  right: 6px;
  top: 6px;
  background-color: #6CC4EA;
  transform: translate(0, 13px) rotate3d(0, 0, 1, -135deg);
}

#close-button-mobile .cmm-two {
  border-radius: 0;
  display: block;
  height: 2px;
  width: 25px;
  position: absolute;
  right: 6px;
  top: 6px;
  background-color: #6CC4EA;
  transform: translate(0, 13px) rotate3d(0, 0, 1, -45deg);
}

.modal-logo {
  padding: 10px;
}

.modal-content {
  padding: 70px;
}

@media (min-width: 768px) {
  #close-button-mobile {
    display: none;
  }

  #modal-content-wrapper {
    left: auto;
    right: 16px;
    bottom: 16px;
    width: min(860px, calc(100% - 32px));
    max-width: 860px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  }

  #msgers {
    width: 160px;
    min-width: 140px;
    max-width: 180px;
  }

  #Recipe.msg-dock-open {
    padding-bottom: calc(var(--msg-dock-height) + 16px);
  }
}

@media (max-width: 767px) {
  :root {
    --msg-dock-height: min(460px, 55vh);
  }

  #msgers {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  #modal-content-wrapper.open:not(.msg-thread-active) #msg-thread-panel {
    display: none;
  }

  #modal-content-wrapper.msg-thread-active #msgers {
    display: none;
  }

  #modal-content-wrapper.msg-thread-active #msg-thread-panel {
    display: flex;
    width: 100%;
  }

  #modal-content-wrapper.msg-thread-active .msg-back-btn {
    display: inline-flex;
  }

  #modal-content-wrapper #body {
    padding: 0 12px 12px;
  }
}
