/* Import Google font - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

:root {
  --text-color: #FFFFFF;
  --icon-color: #ACACBE;
  --icon-hover-bg: #5b5e71;
  --placeholder-color: #dcdcdc;
  --outgoing-chat-bg: #343541;
  --incoming-chat-bg: #444654;
  --outgoing-chat-border: #64656d;
  --incoming-chat-border: #444654;
}

.light-mode {
  --text-color: #343541;
  --icon-color: #a9a9bc;
  --icon-hover-bg: #f1f1f3;
  --placeholder-color: #6c6c6c;
  --outgoing-chat-bg: #FFFFFF;
  --incoming-chat-bg: #F7F7F8;
  --outgoing-chat-border: #FFFFFF;
  --incoming-chat-border: #D9D9E3;
}

body {
  background: var(--outgoing-chat-bg);
}

/* Chats container styling */
.chat-container-main {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.chat-container {
  overflow-y: auto;
  flex-grow: 1;
  height: calc(100vh - 132px) !important;
  /* padding-bottom: 0; */
}

:where(.chat-container, textarea)::-webkit-scrollbar {
  width: 6px;
}

:where(.chat-container, textarea)::-webkit-scrollbar-track {
  background: var(--incoming-chat-bg);
  border-radius: 25px;
}

:where(.chat-container, textarea)::-webkit-scrollbar-thumb {
  background: var(--icon-color);
  border-radius: 25px;
}

.chat-container .chat {
  padding: 25px 10px;
  display: flex;
  justify-content: center;
  color: var(--text-color);
}

.chat-container .chat.outgoing {
  background: var(--outgoing-chat-bg);
  border: 1px solid var(--outgoing-chat-border);
}

.chat-container .chat.incoming {
  background: var(--incoming-chat-bg);
  border: 1px solid var(--incoming-chat-border);
}

span.material-symbols-rounded,
button.material-symbols-rounded {
  user-select: none;
  cursor: pointer;
  font-family: 'Material Symbols Rounded', sans-serif !important;
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
}

#mic-btn {
  font-family: 'Material Symbols Rounded', sans-serif !important;
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
}

.chat .chat-content span {
  cursor: pointer;
  font-size: 1.3rem;
  color: var(--icon-color);
  visibility: hidden;
}

.chat:hover .chat-content:not(:has(.typing-animation), :has(.error)) span {
  visibility: visible;
}

.chat .chat-details img {
  width: 35px;
  height: 35px;
  align-self: flex-start;
  object-fit: cover;
  border-radius: 2px;
}

.chat .chat-details p {
  white-space: pre-wrap;
  padding: 0 50px 0 25px;
  word-break: break-word;
}

.chat .chat-details p.error {
  color: #e55865;
}

.chat .typing-animation {
  padding-left: 25px;
  display: inline-flex;
}

.typing-animation .typing-dot {
  height: 7px;
  width: 7px;
  border-radius: 50%;
  margin: 0 3px;
  opacity: 0.7;
  background: var(--text-color);
  animation: animateDots 1.5s var(--delay) ease-in-out infinite;
}

.typing-animation .typing-dot:first-child {
  margin-left: 0;
}

@keyframes animateDots {
  0%, 44% {
    transform: translateY(0px);
  }

  28% {
    opacity: 0.4;
    transform: translateY(-6px);
  }

  44% {
    opacity: 0.2;
  }
}

.copy-content {
  color: #555 !important;
}

/* Typing container styling */

.typing-textarea textarea {
  resize: none;
  max-height: 250px;
}

.typing-textarea textarea::placeholder {
  color: var(--placeholder-color);
}

.typing-content span {
  width: 55px;
  /* height: 55px; */
  display: flex;
  border-radius: 4px;
  font-size: 1.35rem;
  align-items: center;
  justify-content: center;
  color: var(--icon-color);
}

.typing-textarea span {
  position: absolute;
  right: 0;
  bottom: 0;
  visibility: visible;
}

.typing-textarea textarea:valid~span {
  visibility: visible;
}

.typing-controls span {
  margin-left: 7px;
  font-size: 1.4rem;
  outline: 1px solid var(--incoming-chat-border);
}

.typing-textarea {
  position: relative;
  /* to ensure absolute positioning inside it works properly */
}

#chat-input {
  padding-right: calc(20px + 32px);
  /* Assuming 32px is the width of the send button + margin */
}

#send-btn {
  position: absolute;
  right: 1px;
  top: 50%;
  width: 40px;
  transform: translateY(-50%);
  z-index: 10;
}

table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}

th, td {
  padding: 8px;
  text-align: left;
}

#customFileButton, #attachment-btn {
  top: 50%;
  z-index: 10;
  height: 40px;
  width: 40px;
  right: 70px;
  position: absolute;
  transform: translateY(-50%);
}

#attachment-btn {
  right: 36px;
}

/* side bar */
.menu-list-wrap:hover .menu-list-btn-wrap {
  display: block;
}

.hide-sidbar-btn {
  transform: rotate(180deg);
}

.sidebar-wrapper {
  scrollbar-width: none;
  transition-duration: 0.4s;
  z-index: 9999;
}

.sidebar-wrapper::-webkit-scrollbar {
  display: none;
}

.sidebar-wrapper-position {
  margin-left: -256px;
}

.display-btn-sidbar {
  display: none;
}

/* Reponsive Media Query */
@media screen and (max-width: 776px) {
  .sidbar-responsive {
    margin-left: -256px;
  }

  .display-btn-sidbar {
    display: block;
  }
}

/* Safari-specific fix for the Start New Chat button */
@media not all and (min-resolution:.001dpcm) {
  @supports (-webkit-appearance:none) and (display:flow-root) {
    .sidebar-wrapper {
      /* Force hardware acceleration in Safari */
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
    }
    
    .sidebar-wrapper > div#start-new-chat-div {
      position: fixed !important;
      bottom: 0 !important;
      z-index: 999 !important;
      display: flex !important;
      opacity: 1 !important;
      visibility: visible !important;
      /* Additional Safari rendering fixes */
      -webkit-transform: translateZ(0);
      transform: translateZ(0);
      -webkit-backface-visibility: hidden;
      backface-visibility: hidden;
      will-change: transform, opacity;
      background-color: inherit;
      padding-bottom: 10px !important;
    }
    
    /* Fix for the button text being partially visible */
    .sidebar-wrapper > div#start-new-chat-div button {
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      width: 100% !important;
      opacity: 1 !important;
      visibility: visible !important;
      transform: translateZ(0);
      height: auto !important;
      min-height: 48px !important;
      padding: 10px !important;
      position: relative;
      overflow: visible;
    }
    
    .sidebar-wrapper > div#start-new-chat-div button span {
      opacity: 1 !important;
      visibility: visible !important;
      transform: translateZ(0);
      font-size: 1em !important;
      position: relative !important;
      display: inline-block !important;
      width: auto !important;
      height: auto !important;
      white-space: nowrap !important;
      text-overflow: clip !important;
      overflow: visible !important;
    }
    
    /* Replace the button completely in Safari */
    .sidebar-wrapper > div#start-new-chat-div button {
      position: relative !important;
      background-color: #333 !important;
      color: transparent !important; /* Hide original text */
    }
    
    .sidebar-wrapper > div#start-new-chat-div button::after {
      content: "Start new chat";
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex !important;
      align-items: center !important;
      justify-content: center !important;
      color: white !important;
      font-size: 1em !important;
      font-weight: 600 !important; 
      z-index: 100;
      text-align: center;
      padding-left: 30px;
    }
    
    /* Add the SVG icon */
    .sidebar-wrapper > div#start-new-chat-div button::before {
      content: "";
      position: absolute;
      left: 24px;
      top: 50%;
      transform: translateY(-50%);
      width: 20px;
      height: 20px;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='h-5 w-5' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z' /%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-size: contain;
      z-index: 101;
    }
  }
}

@media screen and (max-width: 600px) {
  .default-text h1 {
    font-size: 2.3rem;
  }

  :where(.default-text p, textarea, .chat p) {
    font-size: 0.95rem !important;
  }

  .chat-container {
    height: 100%;
    padding-bottom: auto;
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 10px;
  }

  .chat-container .chat {
    padding: 20px 10px;
  }

  .chat-container .chat img {
    height: 32px;
    width: 32px;
  }

  .chat-container .chat p {
    padding: 0 20px;
  }

  .chat .chat-content:not(:has(.typing-animation), :has(.error)) span {
    visibility: visible;
  }

  .typing-container {
    padding: 15px 10px;
  }

  .typing-textarea textarea {
    height: 45px;
    padding: 10px 40px 10px 10px;
  }

  .typing-content span {
    height: 45px;
    width: 45px;
    margin-left: 5px;
  }

  span.material-symbols-rounded,
  button.material-symbols-rounded,
  #mic-btn {
    font-size: 1.25rem !important;
    font-family: 'Material Symbols Rounded', sans-serif !important;
  }
}


input[type="file"] {
  display: none;
}

/* Sidebar styling for fixed chat button */
.sidebar-wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-wrapper > .mt-1 {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 70px; /* Space for the start new chat button */
}

.sidebar-wrapper > div#start-new-chat-div {
  position: fixed;
  bottom: 0;
  width: 256px; /* Same as sidebar width */
  background-color: inherit;
  border-right: inherit;
  z-index: 20;
  display: flex;
  opacity: 1;
  visibility: visible;
}

@media only screen and (max-width: 768px) {
  body {
    max-height: 100dvh;
    overflow: hidden;
  }

  body .chat-container-main {
    min-height: 100dvh !important;
  }

  .sidebar-gorazd {
    max-height: 90dvh;
  }

  .sidebar-wrapper{
    display: flex;
    flex-direction: column;
  }

  .sidebar-wrapper > .mt-1 {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 80px; /* Space for the fixed button */
  }

  .sidebar-wrapper > div#start-new-chat-div {
    z-index: 300;
    opacity: 1;
    display: flex;
    position: fixed;
    bottom: 0;
    width: 256px; /* Same as sidebar width */
    background-color: inherit; /* Match sidebar background */
    border-right: inherit; /* Match sidebar border */
  }

  #elements-in-action-buttons{
    gap: 10px!important;
  }

  #elements-in-action-buttons>*{
    min-width: calc(50% - 5px)!important;
    flex: 1;
  }

  #elements-in-action-buttons>p:nth-child(3)>span{
    width: 100%;
  }

  #chat-input{
    font-size: 16px!important;
  }
}

.chat-table tr:nth-child(1) td {
  font-weight: bold;
}

table,
th,
td {
  border: 1px solid black;
  border-collapse: collapse;
}

th,
td {
  padding: 8px;
  text-align: left;
}