/**
 * GIA HUY NEXUS - Custom In-House Live Chat Widget Styling
 * Theme: GitHub Dark Pro matching system aesthetic
 * Includes: Speed Dial Contact Fan-out Menu & File/Image Uploads
 */

/* ==========================================================
 * 1. FLOATING ACTION CONTAINER & LAUNCHER
 * ========================================================== */
#gh-contact-dial-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 12px;
  z-index: 999998;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Main Trigger Button */
#gh-livechat-launcher {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1f6feb 0%, #0969da 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(31, 111, 235, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.2);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  user-select: none;
  position: relative;
}

#gh-livechat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 32px rgba(31, 111, 235, 0.65);
}

#gh-livechat-launcher:active {
  transform: scale(0.95);
}

#gh-livechat-launcher .gh-launcher-icon-chat,
#gh-livechat-launcher .gh-launcher-icon-close {
  position: absolute;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

#gh-livechat-launcher .gh-launcher-icon-chat {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

#gh-livechat-launcher .gh-launcher-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

#gh-livechat-launcher.is-active .gh-launcher-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

#gh-livechat-launcher.is-active .gh-launcher-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Unread Badge */
.gh-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #f85149;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 10px;
  padding: 0 5px;
  border: 2px solid #0d1117;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  animation: gh-badge-pulse 2s infinite;
  display: none;
}

.gh-chat-badge.has-unread {
  display: block;
}

@keyframes gh-badge-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ==========================================================
 * 2. SPEED-DIAL CONTACT FAN-OUT MENU
 * ========================================================== */
#gh-speed-dial-menu {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.9);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.22s;
}

#gh-speed-dial-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.gh-dial-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
  outline: none;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.gh-dial-item:hover {
  transform: translateX(-4px) scale(1.04);
}

.gh-dial-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

/* Button Colors */
.gh-dial-livechat .gh-dial-btn {
  background: linear-gradient(135deg, #2f81f7 0%, #1f6feb 100%);
  box-shadow: 0 4px 16px rgba(47, 129, 247, 0.5);
}

.gh-dial-telegram .gh-dial-btn {
  background: linear-gradient(135deg, #229ED9 0%, #0088cc 100%);
  box-shadow: 0 4px 16px rgba(34, 158, 217, 0.5);
}

.gh-dial-zalo .gh-dial-btn {
  background: linear-gradient(135deg, #0068FF 0%, #0052cc 100%);
  box-shadow: 0 4px 16px rgba(0, 104, 255, 0.5);
}

.gh-dial-phone .gh-dial-btn {
  background: linear-gradient(135deg, #2ea043 0%, #238636 100%);
  box-shadow: 0 4px 16px rgba(46, 160, 67, 0.5);
}

.gh-dial-email .gh-dial-btn {
  background: linear-gradient(135deg, #d29922 0%, #b08800 100%);
  box-shadow: 0 4px 16px rgba(210, 153, 34, 0.5);
}

/* Label Pill on Left */
.gh-dial-label {
  background: #161b22;
  color: #f0f6fc;
  border: 1px solid #30363d;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0.95;
  transition: all 0.15s ease;
}

.gh-dial-item:hover .gh-dial-label {
  background: #21262d;
  border-color: #58a6ff;
  color: #58a6ff;
  opacity: 1;
}

/* ==========================================================
 * 3. CHAT MAIN WINDOW
 * ========================================================== */
#gh-livechat-box {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 390px;
  height: 580px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(240, 246, 252, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.25s;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#gh-livechat-box.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.gh-chat-header {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.gh-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gh-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1f6feb 0%, #238636 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
}

.gh-chat-avatar .gh-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #3fb950;
  border: 2px solid #161b22;
  border-radius: 50%;
}

.gh-chat-title-group h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #f0f6fc;
  line-height: 1.2;
}

.gh-chat-title-group .gh-chat-status {
  font-size: 11px;
  color: #3fb950;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
}

.gh-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gh-chat-icon-btn {
  background: transparent;
  border: none;
  color: #8b949e;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.gh-chat-icon-btn:hover {
  background: #21262d;
  color: #f0f6fc;
}

/* User Sub-bar / Profile status */
.gh-chat-user-bar {
  background: #12161f;
  padding: 6px 14px;
  border-bottom: 1px solid #21262d;
  font-size: 11px;
  color: #8b949e;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gh-chat-user-bar .gh-user-name {
  color: #58a6ff;
  font-weight: 600;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gh-chat-user-bar .gh-user-edit-btn {
  color: #8b949e;
  cursor: pointer;
  text-decoration: underline;
  background: none;
  border: none;
  font-size: 11px;
  padding: 0;
}

.gh-chat-user-bar .gh-user-edit-btn:hover {
  color: #f0f6fc;
}

/* Guest edit form overlay */
.gh-guest-form-card {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 10px 14px;
  display: none;
  flex-direction: column;
  gap: 6px;
}

.gh-guest-form-card.is-visible {
  display: flex;
}

.gh-guest-input {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #f0f6fc;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.gh-guest-input:focus {
  border-color: #58a6ff;
}

.gh-guest-btn-save {
  background: #238636;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-end;
}

/* ==========================================================
 * 4. MESSAGES TIMELINE & RICH MEDIA CARDS
 * ========================================================== */
.gh-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #0d1117;
  scroll-behavior: smooth;
  position: relative;
}

.gh-chat-body::-webkit-scrollbar {
  width: 5px;
}
.gh-chat-body::-webkit-scrollbar-thumb {
  background: #21262d;
  border-radius: 3px;
}

/* Drag & Drop Overlay */
.gh-drag-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 17, 23, 0.9);
  border: 2px dashed #58a6ff;
  border-radius: 12px;
  margin: 8px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #58a6ff;
  font-size: 14px;
  font-weight: 600;
  z-index: 50;
  pointer-events: none;
}
.gh-drag-overlay.is-active {
  display: flex;
}

/* Message Item */
.gh-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 84%;
  animation: gh-msg-fade 0.2s ease-out;
}

@keyframes gh-msg-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.gh-msg-row.from-admin {
  align-self: flex-start;
}
.gh-msg-row.from-user {
  align-self: flex-end;
}
.gh-msg-row.from-system {
  align-self: center;
  max-width: 90%;
  text-align: center;
}

.gh-msg-sender {
  font-size: 10px;
  color: #8b949e;
  margin-bottom: 3px;
  padding: 0 4px;
}
.gh-msg-row.from-user .gh-msg-sender {
  text-align: right;
}

.gh-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.gh-msg-row.from-admin .gh-msg-bubble {
  background: #161b22;
  color: #f0f6fc;
  border: 1px solid #30363d;
  border-top-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.gh-msg-row.from-user .gh-msg-bubble {
  background: linear-gradient(135deg, #1f6feb 0%, #0969da 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(31, 111, 235, 0.35);
}

.gh-msg-row.from-system .gh-msg-bubble {
  background: rgba(110, 118, 129, 0.15);
  color: #8b949e;
  border: 1px solid rgba(110, 118, 129, 0.2);
  font-size: 11px;
  border-radius: 8px;
  padding: 6px 12px;
}

.gh-msg-time {
  font-size: 9px;
  color: #6e7681;
  margin-top: 3px;
  padding: 0 4px;
}
.gh-msg-row.from-user .gh-msg-time {
  text-align: right;
  color: #8b949e;
}

/* Image Attachment Card */
.gh-msg-media-img {
  margin-top: 6px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  max-width: 240px;
  background: #000;
  display: block;
}

.gh-msg-media-img img {
  width: 100%;
  height: auto;
  max-height: 220px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.gh-msg-media-img img:hover {
  transform: scale(1.03);
}

/* File Attachment Card */
.gh-msg-file-card {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease;
}

.gh-msg-file-card:hover {
  background: rgba(0, 0, 0, 0.4);
}

.gh-file-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #21262d;
  color: #58a6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gh-file-meta {
  flex: 1;
  min-width: 0;
}

.gh-file-name {
  font-size: 12px;
  font-weight: 600;
  color: #f0f6fc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gh-file-size {
  font-size: 10px;
  color: #8b949e;
}

/* Quick Suggestion Chips */
.gh-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.gh-chip {
  background: #21262d;
  color: #58a6ff;
  border: 1px solid #30363d;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.gh-chip:hover {
  background: #30363d;
  border-color: #58a6ff;
  color: #ffffff;
}

/* ==========================================================
 * 5. COMPOSER & ATTACHMENT STRIP
 * ========================================================== */
.gh-chat-footer {
  background: #161b22;
  border-top: 1px solid #30363d;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Pending Attachment Strip */
.gh-attachment-preview-strip {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #1c2128;
  border-bottom: 1px solid #30363d;
  font-size: 12px;
}

.gh-attachment-preview-strip.is-visible {
  display: flex;
}

.gh-preview-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #f0f6fc;
}

.gh-preview-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid #30363d;
}

.gh-preview-name {
  font-size: 12px;
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gh-preview-remove-btn {
  background: none;
  border: none;
  color: #f85149;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

/* Input Row */
.gh-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 12px;
}

.gh-chat-attach-btn {
  background: transparent;
  border: none;
  color: #8b949e;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.gh-chat-attach-btn:hover {
  background: #21262d;
  color: #58a6ff;
}

.gh-chat-textarea {
  flex: 1;
  background: #0d1117;
  border: 1px solid #30363d;
  color: #f0f6fc;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  min-height: 38px;
  line-height: 1.4;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease;
}

.gh-chat-textarea:focus {
  border-color: #58a6ff;
  box-shadow: 0 0 0 1px #58a6ff;
}

.gh-chat-send-btn {
  background: #238636;
  border: none;
  color: #ffffff;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.gh-chat-send-btn:hover {
  background: #2ea043;
  transform: translateY(-1px);
}

.gh-chat-send-btn:active {
  transform: translateY(0);
}

.gh-chat-send-btn:disabled {
  background: #21262d;
  color: #6e7681;
  cursor: not-allowed;
  transform: none;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  #gh-livechat-box {
    right: 12px;
    left: 12px;
    bottom: 84px;
    width: auto;
    max-width: none;
    height: calc(100vh - 100px);
    max-height: none;
  }
  #gh-contact-dial-wrapper {
    bottom: 16px;
    right: 16px;
  }
}

/* ==========================================================
 * 6. IN-PAGE LIGHTBOX IMAGE MODAL
 * ========================================================== */
#gh-chat-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000000;
  cursor: zoom-out;
  padding: 24px;
  box-sizing: border-box;
  animation: gh-lightbox-fade 0.2s ease-out;
}

#gh-chat-lightbox.is-open {
  display: flex;
}

#gh-chat-lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: default;
  animation: gh-lightbox-zoom 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.gh-lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
}

.gh-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.gh-lightbox-download {
  position: absolute;
  bottom: 24px;
  background: rgba(22, 27, 34, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f0f6fc;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  backdrop-filter: blur(6px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.gh-lightbox-download:hover {
  background: #1f6feb;
  color: #fff;
  border-color: #58a6ff;
  transform: translateY(-2px);
}

@keyframes gh-lightbox-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes gh-lightbox-zoom {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
