/* ==========================================================================
   JSFLIX — Floating Live Chat & LINE@ Widget
   ========================================================================== */

/* --- Floating Launcher Button --- */
.jsflix-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand, #e50914) 0%, #b80610 100%);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 24px rgba(229, 9, 20, 0.4), 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  outline: none;
}

.jsflix-chat-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 28px rgba(229, 9, 20, 0.55), 0 4px 12px rgba(0, 0, 0, 0.5);
}

.jsflix-chat-launcher:active {
  transform: scale(0.96);
}

/* Online Pulse Indicator */
.jsflix-chat-online-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: #10b981;
  border: 2.5px solid var(--ink, #0a0a0c);
  border-radius: 50%;
}

.jsflix-chat-online-dot::after {
  content: '';
  position: absolute;
  top: -2.5px;
  left: -2.5px;
  right: -2.5px;
  bottom: -2.5px;
  border-radius: 50%;
  border: 2px solid #10b981;
  animation: chatPulse 2s infinite ease-out;
  opacity: 0.8;
}

@keyframes chatPulse {
  0% {
    transform: scale(1);
    opacity: 0.9;
  }
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

/* Unread Badge */
.jsflix-chat-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background: #f59e0b;
  color: #000;
  font-size: 11px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--ink, #0a0a0c);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* --- Options Popover (Web Chat vs LINE@) --- */
.jsflix-chat-popover {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 310px;
  background: rgba(18, 18, 24, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 9995;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.95);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.jsflix-chat-popover.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.jsflix-popover-head {
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.jsflix-popover-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.jsflix-popover-desc {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
  margin: 0;
  line-height: 1.4;
}

.jsflix-popover-options {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.jsflix-popover-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.jsflix-popover-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateX(3px);
}

.jsflix-btn-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.jsflix-btn-icon-box.web {
  background: linear-gradient(135deg, rgba(229, 9, 20, 0.2) 0%, rgba(229, 9, 20, 0.35) 100%);
  color: #ff4d58;
  border: 1px solid rgba(229, 9, 20, 0.4);
}

.jsflix-btn-icon-box.line {
  background: linear-gradient(135deg, rgba(6, 199, 85, 0.2) 0%, rgba(6, 199, 85, 0.35) 100%);
  color: #06c755;
  border: 1px solid rgba(6, 199, 85, 0.4);
}

.jsflix-btn-text strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
}

.jsflix-btn-text span {
  display: block;
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
}

/* --- Live Web Chat Window --- */
.jsflix-chat-window {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  height: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  background: #111116;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.jsflix-chat-window.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.jsflix-chat-header {
  padding: 14px 16px;
  background: linear-gradient(180deg, #18181f 0%, #131318 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

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

.jsflix-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand, #e50914) 0%, #ff4d58 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  position: relative;
  box-shadow: 0 2px 8px rgba(229, 9, 20, 0.35);
}

.jsflix-chat-avatar .online-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #10b981;
  border: 2px solid #18181f;
  border-radius: 50%;
}

.jsflix-chat-header-text h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.jsflix-chat-header-text span {
  font-size: 11px;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 4px;
}

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

.jsflix-chat-tool-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text-dim, #9ca3af);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s ease;
}

.jsflix-chat-tool-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* Chat Messages Stream */
.jsflix-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: radial-gradient(circle at top, rgba(229, 9, 20, 0.03) 0%, transparent 60%), #0d0d12;
  scroll-behavior: smooth;
}

.jsflix-chat-body::-webkit-scrollbar {
  width: 5px;
}

.jsflix-chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* System notice / welcome banner */
.jsflix-chat-welcome {
  text-align: center;
  padding: 14px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  margin-bottom: 8px;
}

.jsflix-chat-welcome p {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
  margin: 0;
  line-height: 1.5;
}

/* Message bubbles */
.jsflix-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: msgFadeIn 0.2s ease-out;
}

@keyframes msgFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.jsflix-msg-row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.jsflix-msg-row.admin {
  align-self: flex-start;
  align-items: flex-start;
}

.jsflix-msg-sender {
  font-size: 10px;
  color: var(--text-dim, #9ca3af);
  margin-bottom: 3px;
  padding: 0 4px;
}

.jsflix-msg-bubble {
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.45;
  border-radius: 16px;
  word-break: break-word;
  position: relative;
}

.jsflix-msg-row.user .jsflix-msg-bubble {
  background: linear-gradient(135deg, var(--brand, #e50914) 0%, #b80610 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(229, 9, 20, 0.25);
}

.jsflix-msg-row.admin .jsflix-msg-bubble {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f3f4f6;
  border-bottom-left-radius: 4px;
}

.jsflix-msg-time {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 3px;
  padding: 0 4px;
}

/* Chat Input Footer */
.jsflix-chat-footer {
  padding: 12px 14px;
  background: #15151b;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.jsflix-chat-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.jsflix-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: #fff;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.jsflix-chat-input:focus {
  border-color: var(--brand, #e50914);
  background: rgba(255, 255, 255, 0.08);
}

.jsflix-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.jsflix-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--brand, #e50914);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.jsflix-chat-send-btn:hover {
  background: #ff2a37;
  transform: scale(1.05);
}

.jsflix-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Responsive for Mobile */
@media (max-width: 768px) {
  .jsflix-chat-launcher {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }

  .jsflix-chat-popover {
    right: 16px;
    left: 16px;
    bottom: calc(130px + env(safe-area-inset-bottom, 0px));
    width: auto;
  }

  .jsflix-chat-window {
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    z-index: 9999;
  }
}
