/* ============================================
   Chat System Styles - Template1
   ============================================ */

/* Base Styles */
body {
  background-color: var(--bg, #f5f5f5);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Chat Container */
.chat-container {
  margin: 0;
  margin-top: 10px;
  background: #fff;
  padding: 0;
  border-radius: 0;
  max-width: 100%;
  box-shadow: none;
  height: calc(100vh - 70px);
  min-height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
}

.template1-header {
  margin-bottom: 0 !important;
  padding-bottom: 0 !important;
}

/* Profile Images */
.profile-image {
  width: 50px;
  height: 50px;
  border-radius: 40px;
  object-fit: cover;
}

/* Settings Tray */
.settings-tray {
  background: #eee;
  padding: 10px 15px;
  border-radius: 7px;
}

.settings-tray--right {
  float: right;
}

.settings-tray--right i {
  margin-top: 10px;
  font-size: 25px;
  color: grey;
  margin-left: 14px;
  transition: 0.3s;
  cursor: pointer;
}

.settings-tray--right i:hover {
  color: #74b9ff;
}

/* Search Box */
.search-box {
  background: #fafafa;
  padding: 10px 13px;
}

.search-box .input-wrapper {
  background: #fff;
  border-radius: 40px;
  padding: 5px 15px;
  display: flex;
  align-items: center;
}

.search-box .input-wrapper i {
  color: grey;
  margin-left: 7px;
  vertical-align: middle;
}

.search-box input {
  border: none;
  border-radius: 30px;
  width: 100%;
  padding: 5px 10px;
}

.search-box input::placeholder {
  color: #e3e3e3;
  font-weight: 300;
}

.search-box input:focus {
  outline: none;
}

/* Friend Drawer (Conversation Item) */
.friend-drawer {
  padding: 10px 15px;
  display: flex;
  vertical-align: baseline;
  background: #fff;
  transition: 0.3s ease;
  align-items: center;
}

.friend-drawer--grey {
  background: #eee;
}

.friend-drawer .text {
  margin-left: 12px;
  width: 70%;
  flex: 1;
}

.friend-drawer .text h6 {
  margin-top: 6px;
  margin-bottom: 0;
  font-size: 16px;
  font-weight: 600;
}

.friend-drawer .text p {
  margin: 0;
  font-size: 13px;
  color: #999;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-drawer .time {
  color: grey;
  font-size: 12px;
}

.friend-drawer--onhover:hover {
  background: #74b9ff;
  cursor: pointer;
}

.friend-drawer--onhover:hover p,
.friend-drawer--onhover:hover h6,
.friend-drawer--onhover:hover .time {
  color: #fff !important;
}

hr {
  margin: 5px auto;
  width: 60%;
  border: none;
  border-top: 1px solid #eee;
}

/* Chat Panel */
.chat-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #e5ddd5;
  background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='a' patternUnits='userSpaceOnUse' width='100' height='100' patternTransform='scale(0.5) rotate(0)'%3E%3Crect x='0' y='0' width='100' height='100' fill='hsla(0,0%25,100%25,1)'/%3E%3Cpath d='M0 50h100M50 0v100' stroke-width='0.5' stroke='hsla(259,0%25,64%25,0.05)' fill='none'/%3E%3C/pattern%3E%3C/defs%3E%3Crect fill='url(%23a)' width='100%25' height='100%25'/%3E%3C/svg%3E");
  min-height: 0;
}

/* Chat Bubbles */
.chat-bubble {
  padding: 10px 14px;
  background: #eee;
  margin: 0;
  border-radius: 9px;
  position: relative;
  animation: fadeIn 0.3s ease-in;
  word-wrap: break-word;
}

.chat-bubble:after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border: 20px solid transparent;
  border-bottom: 0;
  margin-top: -10px;
}

.chat-bubble--left:after {
  left: 0;
  border-right-color: #eee;
  border-left: 0;
  margin-left: -20px;
}

.chat-bubble--right:after {
  right: 0;
  border-left-color: #74b9ff;
  border-right: 0;
  margin-right: -20px;
}

@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-bubble--right {
  background: #dcf8c6;
  margin-left: auto;
  margin-right: 0;
}

.chat-bubble--right:after {
  border-left-color: #dcf8c6;
}

/* Chat Input Tray */
.chat-box-tray {
  background: #eee;
  display: flex;
  align-items: center;
  padding: 10px 15px;
  border-top: 1px solid #ddd;
  margin-bottom: 0;
  position: relative;
}

.chat-box-tray input,
.chat-box-tray textarea {
  margin: 0 10px;
  padding: 8px 12px;
  border: none;
  border-radius: 20px;
  flex: 1;
  resize: none;
  max-height: 100px;
}

.chat-box-tray i {
  color: grey;
  font-size: 24px;
  vertical-align: middle;
  cursor: pointer;
  transition: 0.3s;
}

.chat-box-tray i:hover {
  color: #74b9ff;
}

.chat-box-tray i:last-of-type {
  margin-left: 10px;
}

/* Message Metadata */
.message-time {
  font-size: 11px;
  color: #999;
  margin-top: 5px;
  text-align: right;
}

.message-sender {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 3px;
  color: #128c7e;
}

.chat-bubble--right .message-sender {
  color: #075e54;
}

.message-seen {
  font-size: 10px;
  color: #25d366;
  margin-top: 2px;
  text-align: right;
}

/* Message Text - Emoji Support */
.message-text {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
  word-wrap: break-word;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 14px;
  color: #111;
}

.chat-bubble--right .message-text {
  color: #111;
}

.message-status {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: #999;
  margin-top: 2px;
}

/* Reactions */
.reactions-container {
  margin-top: 5px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.reaction-btn {
  padding: 2px 6px;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: 0.2s;
}

.reaction-btn:hover {
  background: #f0f0f0;
}

.reaction-btn.active {
  background: #dcf8c6;
  border-color: #74b9ff;
}

/* Media Preview */
.media-preview {
  margin-top: 8px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.media-preview img,
.media-preview video {
  max-width: 200px;
  max-height: 200px;
  border-radius: 5px;
  cursor: pointer;
  transition: transform 0.2s;
}

.media-preview img:hover,
.media-preview video:hover {
  transform: scale(1.05);
}

/* File Preview */
#file-preview {
  position: absolute;
  bottom: 60px;
  right: 20px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  max-width: 300px;
}

/* Mobile Toggle Button */
.mobile-toggle-btn {
  display: none;
  position: fixed;
  top: 70px;
  right: 15px;
  z-index: 1001;
  background: #25d366;
  color: white;
  border: none;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  transition: all 0.3s;
}

.mobile-toggle-btn:active {
  transform: scale(0.95);
}

.mobile-back-btn {
  display: none;
  background: none;
  border: none;
  color: #25d366;
  font-size: 24px;
  cursor: pointer;
  padding: 5px 10px;
  margin-right: 10px;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: #eee;
  border-radius: 9px;
  margin-bottom: 10px;
  max-width: 65px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Message Actions */
.message-actions {
  position: absolute;
  top: -5px;
  right: -5px;
  display: none;
  gap: 5px;
}

.chat-bubble:hover .message-actions {
  display: flex;
}

.message-action-btn {
  background: rgba(0,0,0,0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.message-action-btn:hover {
  background: rgba(0,0,0,0.9);
  transform: scale(1.1);
}

/* Empty State */
.chat-empty-state {
  text-align: center;
  padding: 40px;
}

.chat-empty-state i {
  font-size: 48px;
  color: #ccc;
  margin-bottom: 15px;
}

.chat-empty-state p {
  color: #999;
  font-size: 16px;
}

/* Desktop Styles */
@media (min-width: 769px) {
  #bottom-nav {
    display: none !important;
  }
  
  .chat-container {
    margin-bottom: 0;
  }
  
  .chat-box-tray {
    bottom: 0 !important;
  }
  
  .chat-panel {
    padding-bottom: 80px !important;
  }
}

/* Mobile Styles */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }
  
  .chat-container {
    margin: 0;
    border-radius: 0;
    height: 100vh;
    position: relative;
    overflow: hidden;
  }
  
  .mobile-toggle-btn {
    display: block !important;
  }
  
  .chat-container:not(.sidebar-hidden) ~ .mobile-toggle-btn,
  .chat-container:not(.sidebar-hidden) .mobile-toggle-btn {
    display: block !important;
  }
  
  .chat-container.sidebar-hidden ~ .mobile-toggle-btn {
    display: none !important;
  }
  
  .mobile-back-btn {
    display: inline-block;
  }
  
  /* Sidebar on mobile */
  .chat-container .col-md-4 {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    transition: transform 0.3s ease;
    transform: translateX(0);
  }
  
  .chat-container.sidebar-hidden .col-md-4 {
    transform: translateX(-100%);
  }
  
  /* Main chat area on mobile */
  .chat-container .col-md-8 {
    width: 100%;
    height: 100%;
    position: relative;
  }
  
  .chat-container.sidebar-hidden .col-md-8 {
    width: 100%;
  }
  
  .chat-panel {
    height: calc(100vh - 140px);
    min-height: auto;
    padding: 15px 10px;
  }
  
  .chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.4;
  }
  
  .chat-bubble:after {
    border-width: 15px;
    margin-top: -7px;
  }
  
  .chat-bubble--left:after {
    margin-left: -15px;
  }
  
  .chat-bubble--right:after {
    margin-right: -15px;
  }
  
  .profile-image {
    width: 40px;
    height: 40px;
  }
  
  .settings-tray {
    padding: 12px 15px;
  }
  
  .settings-tray--right i {
    font-size: 22px;
    margin-left: 12px;
    padding: 5px;
  }
  
  .friend-drawer {
    padding: 12px 15px;
    min-height: 60px;
  }
  
  .friend-drawer .text h6 {
    font-size: 15px;
    margin-top: 4px;
  }
  
  .friend-drawer .text p {
    font-size: 12px;
  }
  
  .friend-drawer .time {
    font-size: 11px;
  }
  
  #bottom-nav {
    display: flex !important;
  }
  
  .chat-container {
    margin-bottom: 60px;
  }
  
  .chat-box-tray {
    bottom: 60px !important;
  }
  
  .chat-panel {
    padding-bottom: 140px !important;
  }
  
  .chat-container .col-md-4 > div:first-of-type + div {
    border-bottom: 2px solid #ddd;
  }
  
  .chat-container .col-md-4 > div:first-of-type + div button {
    padding: 14px 8px;
    font-size: 13px;
  }
  
  .chat-container .col-md-4 > div:first-of-type + div button i {
    font-size: 14px;
    margin-left: 4px;
  }
  
  .search-box {
    padding: 8px 12px;
  }
  
  .search-box input {
    padding: 8px 12px;
    font-size: 14px;
  }
  
  #chat-header .settings-tray {
    padding: 10px 12px;
  }
  
  #chat-header .friend-drawer {
    padding: 8px 12px;
  }
  
  #chat-header .text h6 {
    font-size: 16px;
  }
  
  #chat-header .text p {
    font-size: 12px;
  }
  
  .chat-box-tray {
    padding: 12px 10px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #eee;
    border-top: 1px solid #ddd;
    z-index: 100;
  }
  
  .chat-panel {
    padding-bottom: 80px !important;
  }
  
  .chat-container.sidebar-hidden ~ .mobile-toggle-btn,
  .chat-container.sidebar-hidden .mobile-toggle-btn {
    display: none;
  }
  
  .chat-box-tray textarea {
    padding: 10px 14px;
    font-size: 15px;
    margin: 0 8px;
    min-height: 44px;
    max-height: 120px;
  }
  
  .chat-box-tray i {
    font-size: 22px;
    padding: 8px;
    min-width: 44px;
    text-align: center;
  }
  
  .chat-box-tray button {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .message-sender {
    font-size: 13px;
    margin-bottom: 4px;
  }
  
  .message-time {
    font-size: 10px;
    margin-top: 4px;
  }
  
  .media-preview img,
  .media-preview video {
    max-width: 180px;
    max-height: 180px;
  }
  
  .reaction-btn {
    padding: 4px 8px;
    font-size: 13px;
    min-height: 32px;
  }
  
  #file-preview {
    bottom: 70px;
    right: 10px;
    max-width: calc(100% - 20px);
  }
  
  #file-preview img,
  #file-preview div {
    width: 50px;
    height: 50px;
  }
  
  .chat-container .col-md-8 > div:first-child {
    padding: 20px 15px;
  }
  
  .chat-container .col-md-8 > div:first-child button {
    padding: 12px;
    font-size: 14px;
  }
  
  .chat-container .col-md-8 > div:first-child input {
    padding: 12px 15px;
    font-size: 15px;
  }
  
  .chat-panel .profile-image {
    width: 32px;
    height: 32px;
    margin: 0 6px;
  }
  
  #conversations-list {
    padding-bottom: 10px;
  }
  
  .chat-panel::-webkit-scrollbar {
    width: 4px;
  }
  
  .chat-panel::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 2px;
  }
  
  .friend-drawer--onhover {
    -webkit-tap-highlight-color: rgba(116, 185, 255, 0.3);
  }
  
  button, a, .reaction-btn {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  }
}

@media (max-width: 480px) {
  .chat-bubble {
    max-width: 90%;
    padding: 10px 14px;
    font-size: 14px;
  }
  
  .media-preview img,
  .media-preview video {
    max-width: 150px;
    max-height: 150px;
  }
  
  .friend-drawer {
    padding: 10px 12px;
  }
  
  .settings-tray {
    padding: 10px 12px;
  }
  
  .chat-box-tray {
    padding: 10px 8px;
  }
  
  .chat-box-tray textarea {
    margin: 0 6px;
    padding: 8px 12px;
  }
}

/* Emoji Picker */
.emoji-picker {
  display: none;
  position: absolute;
  bottom: 60px;
  left: 10px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px;
  max-width: 300px;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 1000;
}

.emoji-picker::-webkit-scrollbar {
  width: 6px;
}

.emoji-picker::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.emoji-picker::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

.emoji-picker::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.emoji-picker button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 5px;
  border-radius: 5px;
  transition: background 0.2s;
}

.emoji-picker button:hover {
  background: #f0f0f0;
}

.emoji-picker button:active {
  background: #e0e0e0;
}

@media (max-width: 768px) {
  .emoji-picker {
    max-width: 280px;
    max-height: 200px;
    left: 5px;
    bottom: 70px;
  }
}

