/* ==========================================================================
   KAIWA (CONVERSATION) MODULE STYLES (assets/css/kaiwa.css)
   ========================================================================== */

/* Chapter List Grid */
.kaiwa-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
  animation: kamusFadeInUp .4s ease-out;
}

.kaiwa-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: 24px;
  padding: 1.75rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 10px 30px rgba(0,0,0,.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
}
html.dark-mode .kaiwa-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-color: rgba(255,255,255,.05);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.kaiwa-card-bg-icon {
  position: absolute;
  bottom: -20px;
  right: -20px;
  font-size: 8rem;
  opacity: 0.04;
  transform: rotate(-15deg);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.kaiwa-card:hover .kaiwa-card-bg-icon {
  transform: rotate(0deg) scale(1.1);
  opacity: 0.08;
  color: #10b981;
}
html.dark-mode .kaiwa-card:hover .kaiwa-card-bg-icon {
  opacity: 0.06;
}

.kaiwa-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 0;
  background: linear-gradient(90deg, #10b981, #059669);
  opacity: 0;
  transition: all 0.3s ease;
}

.kaiwa-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.5);
}
.kaiwa-card:hover::before {
  height: 6px;
  opacity: 1;
}
html.dark-mode .kaiwa-card:hover {
  box-shadow: 0 20px 40px rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.4);
}

.kaiwa-card-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.kaiwa-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.kaiwa-badge-bab {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  padding: 0.35rem 0.85rem;
  border-radius: 99px;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2);
}
.kaiwa-badge-tema {
  font-size: 0.8rem;
  color: var(--gray-500, #6b7280);
  font-weight: 700;
  background: rgba(0,0,0,0.04);
  padding: 0.35rem 0.85rem;
  border-radius: 99px;
}
html.dark-mode .kaiwa-badge-tema {
  color: #94a3b8;
  background: rgba(255,255,255,0.05);
}

.kaiwa-card-body {
  flex-grow: 1;
  margin-bottom: 1.5rem;
}

.kaiwa-card-title-jp {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--gray-900, #111827);
  margin-bottom: 0.4rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
html.dark-mode .kaiwa-card-title-jp {
  color: #f8fafc;
}

.kaiwa-card-title-id {
  font-size: 0.95rem;
  color: var(--gray-600, #4b5563);
  font-weight: 500;
}
html.dark-mode .kaiwa-card-title-id {
  color: #94a3b8;
}

.kaiwa-card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  color: #10b981;
  font-weight: 800;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}
.kaiwa-action-icon {
  background: rgba(16, 185, 129, 0.15);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}
.kaiwa-card:hover .kaiwa-card-footer {
  color: #059669;
}
.kaiwa-card:hover .kaiwa-action-icon {
  background: #10b981;
  color: #fff;
  transform: translateX(4px);
}
html.dark-mode .kaiwa-card:hover .kaiwa-card-footer {
  color: #34d399;
}

/* Chat Board Header & Controls */
.kaiwa-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.50rem;
  margin-bottom: 1.5rem;
  background: var(--white, #fff);
  padding: 0.75rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--gray-200, #e5e7eb);
  align-items: center;
}
html.dark-mode .kaiwa-controls-row {
  background: #1e293b;
  border-color: rgba(255,255,255,.06);
}

.kaiwa-toggle-btn {
  padding: 0.45rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 99px;
  border: 1.5px solid var(--gray-200, #e5e7eb);
  background: var(--gray-50, #f9fafb);
  color: var(--gray-700, #4b5563);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
html.dark-mode .kaiwa-toggle-btn {
  background: #0f172a;
  border-color: rgba(255,255,255,.08);
  color: #cbd5e1;
}
.kaiwa-toggle-btn.active {
  background: #10b981;
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 10px rgba(16,185,129,.2);
}
.kaiwa-toggle-btn:hover:not(.active) {
  border-color: #10b981;
  color: #10b981;
}

/* Chat Bubbles Container */
.kaiwa-chat-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem;
  background: var(--gray-50, #f9fafb);
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 24px;
  margin-bottom: 2rem;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
html.dark-mode .kaiwa-chat-container {
  background: #0f172a;
  border-color: rgba(255,255,255,.06);
}

.kaiwa-line {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: 85%;
  animation: kamusFadeInUp .35s ease-out;
}

/* Alternate alignment */
.kaiwa-line.speaker-left {
  align-self: flex-start;
}
.kaiwa-line.speaker-right {
  align-self: flex-end;
  flex-direction: row-reverse;
}

/* Avatars */
.kaiwa-avatar-box {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--white, #fff);
  border: 1.5px solid var(--gray-200, #e5e7eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.03);
  flex-shrink: 0;
}
html.dark-mode .kaiwa-avatar-box {
  background: #1e293b;
  border-color: rgba(255,255,255,.08);
}

/* Speech Bubbles */
.kaiwa-bubble-wrapper {
  display: flex;
  flex-direction: column;
}
.kaiwa-line.speaker-right .kaiwa-bubble-wrapper {
  align-items: flex-end;
}

.kaiwa-tokoh-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--gray-500, #6b7280);
  margin-bottom: 0.25rem;
  padding: 0 4px;
}
html.dark-mode .kaiwa-tokoh-name {
  color: #94a3b8;
}

.kaiwa-bubble {
  padding: 0.9rem 1.15rem;
  border-radius: 18px;
  background: var(--white, #fff);
  border: 1px solid var(--gray-200, #e5e7eb);
  color: var(--gray-900, #111827);
  box-shadow: 0 2px 8px rgba(0,0,0,.02);
  position: relative;
  transition: all 0.2s ease;
}
html.dark-mode .kaiwa-bubble {
  background: #1e293b;
  border-color: rgba(255,255,255,.06);
  color: #f8fafc;
}

/* Speaker coloring */
.kaiwa-line.speaker-left .kaiwa-bubble {
  border-top-left-radius: 4px;
}
.kaiwa-line.speaker-right .kaiwa-bubble {
  border-top-right-radius: 4px;
  background: #e0f2fe; /* Light blue */
  border-color: #bae6fd;
}
html.dark-mode .kaiwa-line.speaker-right .kaiwa-bubble {
  background: #0369a1; /* Deep blue dark mode */
  border-color: rgba(255,255,255,.08);
}

/* Kanji, Romaji, translation line styles */
.kaiwa-txt-jp {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 4px;
}
.kaiwa-txt-romaji {
  font-size: 0.8rem;
  color: var(--gray-500, #6b7280);
  margin-bottom: 4px;
  font-weight: 500;
}
html.dark-mode .kaiwa-txt-romaji {
  color: #94a3b8;
}
.kaiwa-txt-id {
  font-size: 0.85rem;
  color: var(--gray-700, #374151);
  border-top: 1px dashed var(--gray-200, #e5e7eb);
  padding-top: 4px;
  margin-top: 4px;
}
html.dark-mode .kaiwa-txt-id {
  color: #cbd5e1;
  border-color: rgba(255,255,255,.1);
}

/* Audio triggers */
.kaiwa-audio-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 4px;
}
.kaiwa-speaker-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  opacity: 0.55;
  padding: 2px;
  transition: all 0.2s ease;
}
.kaiwa-speaker-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* Roleplay practicing mask / hidden state */
.kaiwa-bubble.muted-roleplay {
  background: var(--gray-100, #f3f4f6) !important;
  border-color: var(--gray-300, #d1d5db) !important;
  cursor: pointer;
}
html.dark-mode .kaiwa-bubble.muted-roleplay {
  background: #334155 !important;
  border-color: rgba(255,255,255,.1) !important;
}

.kaiwa-bubble.muted-roleplay .kaiwa-txt-jp,
.kaiwa-bubble.muted-roleplay .kaiwa-txt-romaji {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
  opacity: 0.3;
}
.kaiwa-bubble.muted-roleplay::after {
  content: '🔇 Giliran Anda! Klik untuk menampilkan dialog';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--gray-600, #4b5563);
  text-align: center;
  width: 90%;
  pointer-events: none;
}
html.dark-mode .kaiwa-bubble.muted-roleplay::after {
  color: #cbd5e1;
}

/* Autoplay active state highlights */
.kaiwa-line.active-speaking .kaiwa-bubble {
  border-color: #10b981 !important;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25) !important;
}
