/* ============================================
   FLOATING CHAT WIDGET — Visa Simple Support
   ============================================ */

#chat-widget-bubble {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a2a4a, #0d1b33);
  border: 2px solid #f4b84a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99990;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s;
}
#chat-widget-bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(0,0,0,0.45);
}
#chat-widget-bubble.cw-active {
  transform: scale(0.9);
}
#cw-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  font-family: Arial, sans-serif;
  line-height: 1;
}

/* ---- WINDOW ---- */
#chat-widget-window {
  position: fixed;
  bottom: 148px;
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 180px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  z-index: 99991;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}
#chat-widget-window.cw-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ---- HEADER ---- */
.cw-header {
  background: linear-gradient(135deg, #1a2a4a, #0d1b33);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.cw-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cw-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f4b84a;
  color: #1a2a4a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}
.cw-header-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
}
.cw-header-status {
  font-size: 11px;
  color: #4ade80;
  line-height: 1.2;
}
.cw-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 22px;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: color 0.2s;
}
.cw-close:hover { color: #fff; }

/* ---- MESSAGES ---- */
.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cw-messages::-webkit-scrollbar { width: 4px; }
.cw-messages::-webkit-scrollbar-track { background: transparent; }
.cw-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

.cw-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: cwMsgIn 0.2s ease-out;
}
@keyframes cwMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.cw-msg-user {
  align-self: flex-end;
  align-items: flex-end;
}
.cw-msg-support {
  align-self: flex-start;
  align-items: flex-start;
}
.cw-msg-name {
  font-size: 10px;
  color: #999;
  margin-bottom: 2px;
  padding: 0 8px;
  font-weight: 600;
}
.cw-msg-bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  word-wrap: break-word;
}
.cw-msg-user .cw-msg-bubble {
  background: linear-gradient(135deg, #1a2a4a, #2a3f6a);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cw-msg-support .cw-msg-bubble {
  background: #fff;
  color: #333;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

/* ---- INPUT AREA ---- */
.cw-input-area {
  padding: 8px 10px 10px;
  border-top: 1px solid #eee;
  background: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cw-info-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cw-info-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
  background: #f9fafb;
  color: #333;
}
.cw-info-input:focus {
  border-color: #f4b84a;
  background: #fff;
}
.cw-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.cw-text-input {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: none;
  min-height: 36px;
  max-height: 80px;
  padding: 7px 14px;
  box-sizing: border-box;
  transition: border-color 0.2s;
  color: #333;
}
.cw-text-input:focus {
  border-color: #f4b84a;
}
.cw-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f4b84a, #e0a030);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}
.cw-send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(244,184,74,0.4);
}
.cw-send-btn:active {
  transform: scale(0.95);
}
.cw-file-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3f4f6;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.cw-file-btn:hover { background: #e5e7eb; }
.cw-file-name {
  font-size: 11px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  line-height: 32px;
}

/* ---- AUTO-POPUP TOOLTIP ---- */
#cw-tooltip {
  position: fixed;
  bottom: 90px;
  right: 84px;
  z-index: 99992;
  opacity: 0;
  visibility: hidden;
  transform: translateX(8px);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}
#cw-tooltip.cw-tooltip-show {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  pointer-events: auto;
}
.cw-tooltip-text {
  background: #fff;
  color: #1a2a4a;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  border: 2px solid #f4b84a;
  white-space: nowrap;
  cursor: pointer;
}
.cw-tooltip-text strong { color: #f4b84a; }
.cw-tooltip-arrow {
  position: absolute;
  top: 50%;
  right: -8px;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid #f4b84a;
}

/* ---- MOBILE ---- */
@media (max-width: 480px) {
  #chat-widget-bubble {
    bottom: 20px;
    right: 16px;
    width: 50px;
    height: 50px;
  }
  #chat-widget-bubble svg { width: 24px; height: 24px; }

  #chat-widget-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 75vh;
    max-height: 75vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    z-index: 999999;
  }
  #chat-widget-window.cw-open {
    transform: translateY(0);
  }

  #cw-tooltip {
    bottom: 80px;
    right: 16px;
  }
  .cw-tooltip-text {
    white-space: normal;
    max-width: 220px;
    font-size: 12px;
    padding: 10px 14px;
  }
}

/* File upload loading */
.cw-msg-loading .cw-msg-bubble {
  background: rgba(255,255,255,0.1);
}
.cw-file-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
}
.cw-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #f4b84a;
  border-radius: 50%;
  animation: cw-spin 0.8s linear infinite;
}
@keyframes cw-spin { to { transform: rotate(360deg); } }
