/**
 * Devani AI Assistant - widget.css
 * Styling widget chat + video launcher.
 * Semua class pakai prefix "devani-" supaya tidak bentrok dengan tema WordPress.
 *
 * v1.1: ukuran frame video desktop 120x180 (rasio 2:3, bisa dioverride lewat
 *       CSS custom properties dari widget.js jika diubah di admin),
 *       mobile 100x160 via media query.
 */

/* ===== Container ===== */
#devani-ai-widget {
  position: fixed;
  bottom: 20px;
  left: 10px;
  z-index: 99999;
  font-family: 'Segoe UI', Arial, sans-serif;
}

/* ===== Launcher: video frame ===== */
#devani-video-launcher {
  cursor: pointer;
  text-align: center;
  user-select: none;
  transition: transform 0.2s ease;
}
#devani-video-launcher:hover { transform: scale(1.05); }

#devani-video-frame {
  position: relative;
  width: var(--devani-frame-w, 120px);   /* desktop 120px */
  height: var(--devani-frame-h, 180px);  /* desktop 180px — rasio 2:3 */
  overflow: hidden;
  border-radius: 14px;
  background: transparent; /* video transparan (webm) tampil bersih; fallback mp4 juga tetap ok */
  box-shadow: none;
}

#devani-video-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;  /* video sudah di-crop 2:3 via ffmpeg; tidak perlu zoom */
  transform: scale(1.0);
  display: block;
  pointer-events: none;
}

#devani-launcher-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(90, 110, 70, 0.85); /* hijau tua semi transparan — sesuaikan warna tema Devani */
  color: #fff;
  font-weight: bold;
  font-size: 14px;
  padding: 6px 0;
  text-align: center;
  border-radius: 0 0 14px 14px;
}

/* ===== Launcher: tombol biasa (jika tidak pakai video) ===== */
#devani-launcher-btn {
  background: linear-gradient(135deg, #5a6e46, #3e5230); /* hijau tua — sesuaikan tema */
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* ===== Launcher: ukuran mobile ===== */
@media (max-width: 768px) {
  #devani-video-frame {
    width: 100px;   /* mobile 100px */
    height: 160px;  /* mobile 160px */
  }
  #devani-launcher-label {
    font-size: 12px;
    padding: 4px 0;
  }
}

/* ===== Chat box ===== */
#devani-chat-box {
  display: none; /* WAJIB — tersembunyi sampai launcher diklik */
  width: 360px;
  max-width: calc(100vw - 20px);
  height: 450px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 10px;
}

.devani-chat-header {
  background: linear-gradient(135deg, #5a6e46, #3e5230);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.devani-chat-title {
  font-weight: bold;
  font-size: 15px;
}

.devani-chat-subtitle {
  font-size: 11px;
  opacity: 0.85;
}

#devani-chat-close {
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
}
#devani-chat-close:hover { opacity: 1; }

/* ===== Chat logs ===== */
#devani-chat-logs {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  background: #f6f5f1;
  font-size: 14px;
  line-height: 1.5;
}

.devani-msg-user,
.devani-msg-bot {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 85%;
  word-wrap: break-word;
}

.devani-msg-user {
  background: #5a6e46;
  color: #fff;
  margin-left: auto;
  text-align: left;
}

.devani-msg-bot {
  background: #ffffff;
  border: 1px solid #e2e0d8;
  margin-right: auto;
}

.devani-msg-bot a {
  color: #3e5230;
  font-weight: 600;
  text-decoration: underline;
}

.devani-msg-img img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 6px;
  cursor: pointer;
}

.devani-loading {
  font-style: italic;
  opacity: 0.7;
}

.devani-error {
  background: #fdecea;
  border-color: #f5c6cb;
  color: #a94442;
}

/* ===== Input area ===== */
.devani-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border-top: 1px solid #e8e6de;
}

#devani-user-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid #d8d6cc;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
}
#devani-user-input:focus { border-color: #5a6e46; }

#devani-send-btn {
  background: #5a6e46;
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
}
#devani-send-btn:disabled { opacity: 0.6; cursor: wait; }

/* ===== v1.4 VOICE: mic & speaker buttons ===== */
#devani-mic-btn {
  background: #f6f5f1;
  border: 1px solid #d8d6cc;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.15s ease;
}
#devani-mic-btn:hover { background: #e8e6de; }
#devani-mic-btn.devani-mic-active {
  background: #c0392b;
  border-color: #c0392b;
  animation: devani-pulse 1.2s infinite;
}
@keyframes devani-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(192, 57, 43, 0); }
}
#devani-speak-toggle {
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.85;
  margin-right: 10px;
}
#devani-speak-toggle:hover { opacity: 1; }
.devani-speak-btn {
  display: inline-block;
  font-size: 13px;
  cursor: pointer;
  opacity: 0.55;
  margin-left: 8px;
  vertical-align: middle;
  transition: opacity 0.15s ease;
}
.devani-speak-btn:hover { opacity: 1; }

/* ===== v1.5: input area 2 baris + lang selector ===== */
.devani-chat-input-area {
  flex-direction: column;
  gap: 8px;
}

.devani-input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.devani-input-actions #devani-send-btn {
  margin-left: auto;
  min-width: 84px;
  flex: 0 0 auto;
}

#devani-lang-select {
  background: #f6f5f1;
  border: 1px solid #d8d6cc;
  border-radius: 18px;
  font-size: 12px;
  color: #3e5230;
  padding: 6px 4px;
  max-width: 130px;
  cursor: pointer;
  outline: none;
  flex: 0 1 auto;
}
#devani-lang-select:focus { border-color: #5a6e46; }

@media (max-width: 768px) {
  #devani-lang-select {
    font-size: 11px;
    max-width: 110px;
    padding: 5px 2px;
  }
  .devani-input-actions #devani-send-btn {
    min-width: 72px;
    padding: 9px 12px;
  }
}

/* ===== v1.6.1 RESIZE HANDLE (port Nadi v9.9/v9.10) ===== */
#devani-chat-box {
  position: relative;   /* anchor handle absolut (di-set juga dari JS) */
}
#devani-resize-handle {
  position: absolute;
  left: auto;
  right: 0;
  top: 0;
  width: 18px;
  height: 18px;
  cursor: nesw-resize;  /* sudut kanan-atas — desktop & mobile sama (widget di kiri-bawah) */
  z-index: 99999;
  touch-action: none;
  user-select: none;
    background: linear-gradient(225deg,
    transparent 50%,
    rgba(225, 225, 225, 225) 50%);   /* segitiga grip di kiri-bawah handle (menghadap badan chat) */
  border-radius: 0 0 0 8px;   /* radius ke sudut dalam (kiri-bawah) — paritas Nadi mobile */
}

/* ===== v1.6.2: ukuran mobile chat-box TANPA !important =====
   Rule diletakkan DI AKHIR file (setelah base #devani-chat-box) supaya
   menang atas base rule berdasarkan urutan, TANPA !important — sehingga
   inline style hasil drag resize (JS) tetap MENANG di mobile.
   Sebelumnya `!important` di sini mematikan resize di mobile. ===== */
@media screen and (max-width: 768px) {
  #devani-chat-box {
    width: 290px;
    height: 480px;
  }
}
