@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap");

body {
  font-family: "Inter", sans-serif;
  background-color: #f0f4f8;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  color: #1e293b;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.login-container {
  background-color: #ffffff;
  padding: 48px;
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1),
    0 8px 10px -6px rgb(0 0 0 / 0.1);
  text-align: center;
  width: 100%;
  max-width: 380px;
  border: 1px solid #e2e8f0;
}

h1 {
  font-weight: 700;
  font-size: 26px;
  margin-bottom: 32px;
  color: #0f172a;
}

.form-group {
  margin-bottom: 24px;
  text-align: left;
}

label {
  display: block;
  margin-bottom: 10px;
  font-weight: 500;
  font-size: 14px;
}

input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 16px;
  box-sizing: border-box;
  transition: all 0.2s ease-in-out;
}

input[type="password"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

button {
  width: 100%;
  padding: 14px;
  background-color: #3b82f6;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}

button:hover {
  background-color: #2563eb;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.error-message {
  color: #ef4444;
  font-size: 14px;
  margin-top: -10px;
  margin-bottom: 15px;
  text-align: center;
}

/* Messenger Styles */
.messenger-container {
  display: flex;
  height: 95vh;
  width: 95vw;
  max-height: 1200px;
  max-width: 1600px;
  background-color: #fff;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  overflow: hidden;
}

.sidebar {
  width: 340px;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  background-color: #f8fafc;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid #e2e8f0;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
}

.chat-list {
  overflow-y: auto;
  flex-grow: 1;
  padding: 0 8px;
}

.chat-group {
  padding: 16px 0;
}

.chat-group h3 {
  margin: 0 0 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-item {
  display: flex;
  padding: 12px 16px;
  border-radius: 12px;
  margin: 0 0 4px;
  cursor: pointer;
  transition: background-color 0.2s;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.chat-item:hover {
  background-color: #f1f5f9;
}

.chat-item.active {
  background-color: #3b82f6;
  color: white;
}
.chat-item.active:hover {
  background-color: #2563eb;
}

.chat-item.active .last-message,
.chat-item.active .last-message-time {
  color: #dbeafe;
}

.chat-item--closed {
  opacity: 0.6;
}

.chat-info {
  flex-grow: 1;
  overflow: hidden;
}

.chat-name {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 15px;
}

.last-message {
  font-size: 14px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s;
}

.chat-meta {
  margin-left: 16px;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 12px;
}

.last-message-time {
  color: #94a3b8;
  transition: color 0.2s;
}

.unread-indicator {
  width: 10px;
  height: 10px;
  background-color: #3b82f6;
  border-radius: 50%;
  border: 2px solid #f8fafc;
}

.chat-item.active .unread-indicator {
  background-color: #fff;
  border-color: #3b82f6;
}

.chat-window {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
}

.chat-header {
  padding: 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.chat-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.close-ticket-btn {
  padding: 8px 16px;
  border-radius: 8px;
  background-color: #ef4444;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.close-ticket-btn:hover {
  background-color: #dc2626;
  box-shadow: 0 4px 14px 0 rgba(239, 68, 68, 0.3);
}

.message-list {
  flex-grow: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  min-width: 0;
}

.message-bubble {
  display: inline-block;
  position: relative;
  padding: 12px 16px;
  border-radius: 24px;
  line-height: 1.5;
  word-break: break-word;
  max-width: 100%;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  min-width: 0;
}
.message-content {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.message-attachment-image,
.message-attachment-video {
  max-width: 250px;
  border-radius: 16px;
}
.message-bubble p {
  margin: 0;
}

.message-bubble.is-loading .message-content p {
  padding-right: 25px;
}

.message-loader {
  position: absolute;
  bottom: 8px;
  right: 12px;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: #64748b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.message.sent .message-loader {
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
}

.message.sent {
  align-self: flex-end;
  align-items: flex-end;
}

.message.sent .message-bubble {
  background-color: #3b82f6;
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.15);
}

.message.received {
  align-self: flex-start;
  align-items: flex-start;
}

.message.received .message-bubble {
  background-color: #f1f5f9;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 6px;
}

.message-timestamp {
  font-size: 12px;
  color: #94a3b8;
  padding: 4px 12px 0;
}
.message-input-area {
  border-top: 1px solid #e2e8f0;
  background-color: #ffffff;
}

#attachment-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 24px;
}
#attachment-preview-container:not(:empty) {
  padding-top: 12px;
}

.message-input {
  display: flex;
  padding: 16px 24px;
  align-items: center;
}

#message-form {
  display: flex;
  width: 100%;
  gap: 12px;
  align-items: center;
}

#message-form #message-input-field {
  flex-grow: 1;
  height: 44px;
  box-sizing: border-box;
  padding: 10px 18px;
  border-radius: 22px;
  border: 1px solid #e2e8f0;
  font-size: 15px;
  background-color: #fff;
  transition: all 0.2s ease-in-out;
}

#message-form #message-input-field:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

#message-form button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  box-sizing: border-box;
  border-radius: 50%;
  background-color: #3b82f6;
  color: white;
  border: none;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
}

#message-form button:hover {
  background-color: #2563eb;
  box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.3);
}

#message-form button svg {
  width: 22px;
  height: 22px;
  margin-left: 2px;
}

.attachment-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  width: 44px;
  height: 44px;
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: none;
  color: #64748b;
  transition: color 0.2s, background-color 0.2s;
}

.attachment-btn:hover {
  color: #3b82f6;
  background-color: #eef2ff;
}
.attachment-btn svg {
  width: 20px;
  height: 20px;
}

.file-preview-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  font-size: 14px;
  color: #334155;
  font-weight: 500;
}

.file-preview-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.remove-file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e2e8f0;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: #64748b;
  transition: all 0.2s;
}

.remove-file-btn:hover {
  color: #fff;
  background-color: #ef4444;
  transform: scale(1.1);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.no-chat-selected {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: #64748b;
  font-size: 18px;
}

.ticket-separator {
  text-align: center;
  margin: 20px 0;
  font-size: 12px;
  color: #94a3b8;
  position: relative;
}

.ticket-separator span {
  background-color: #fff;
  padding: 0 10px;
  position: relative;
  z-index: 1;
}

.ticket-separator::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
  background-color: #e2e8f0;
  z-index: 0;
}

.message-input-disabled {
  padding: 24px;
  text-align: center;
  color: #94a3b8;
  font-style: italic;
  background-color: #f8fafc;
}

.back-btn {
  display: none;
}

.chat-header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-grow: 1;
}

@media (max-width: 768px) {
  .messenger-container {
    height: 100vh;
    width: 100vw;
    border-radius: 0;
    flex-direction: column;
    overflow: hidden;
  }
  .sidebar {
    width: 100%;
    height: 100%;
    border-right: none;
    transition: transform 0.3s ease-in-out;
  }
  .chat-window {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    background-color: #fff;
    z-index: 10;
  }
  .messenger-container.chat-view-active .sidebar {
    transform: translateX(-100%);
  }
  .messenger-container.chat-view-active .chat-window {
    transform: translateX(0);
  }
  .back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 8px;
    margin: 0;
    margin-left: -8px; /* Compensate for padding */
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    color: #334155;
    transition: background-color 0.2s;
  }
  .back-btn:hover {
    background-color: #f1f5f9;
  }
  .back-btn:focus,
  .back-btn:active {
    outline: none;
    box-shadow: none;
  }
  .chat-header {
    padding: 12px 16px;
  }
}
