/* ============================================================
   chat-log-viewer.css
   会話ログ閲覧画面 スタイル
   ============================================================ */

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans',
    'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Meiryo', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: #333;
  background: #f0f2f5;
}

/* ============================================================
   Layout
   ============================================================ */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(135deg, #1a365d 0%, #2d4a7a 100%);
  color: #fff;
  flex-shrink: 0;
}
.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
.app-header .header-sub {
  font-size: 12px;
  opacity: 0.8;
}
.app-header .header-note {
  font-size: 12px;
  opacity: 0.7;
}

/* --- Search Panel --- */
.search-panel {
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid #dde1e6;
  padding: 16px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}
.search-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.search-group label {
  font-size: 11px;
  font-weight: 600;
  color: #5a6474;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.search-group input[type="text"],
.search-group input[type="date"],
.search-group select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid #c4cad3;
  border-radius: 6px;
  font-size: 13px;
  color: #333;
  background: #fff;
  transition: border-color 0.2s;
}
.search-group input:focus,
.search-group select:focus {
  outline: none;
  border-color: #2d4a7a;
  box-shadow: 0 0 0 3px rgba(45, 74, 122, 0.12);
}
.search-group input[type="text"] { width: 140px; }
.search-group input[type="date"] { width: 160px; }

.search-chatid-composite {
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-chatid-composite .separator {
  font-size: 16px;
  font-weight: 700;
  color: #5a6474;
  line-height: 36px;
}

/* --- Input with Clear Button --- */
.input-with-clear {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100px;
}
.input-with-clear input[type="text"] {
  width: 100%;
  padding-right: 24px;
}
.input-clear-btn {
  position: absolute;
  right: 6px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: #c4cad3;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.2s;
}
.input-clear-btn:hover {
  background: #8892a0;
}
.input-clear-btn.visible {
  display: flex;
}

.btn {
  height: 36px;
  padding: 0 20px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: #1a365d;
  color: #fff;
}
.btn-primary:hover {
  background: #2d4a7a;
  box-shadow: 0 2px 6px rgba(26, 54, 93, 0.3);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: wait;
}
.btn-secondary {
  background: #e8ecf1;
  color: #5a6474;
}
.btn-secondary:hover {
  background: #dde1e6;
}

/* --- Search Buttons Row --- */
.search-buttons {
  display: flex;
  gap: 8px;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 16px 24px 24px;
  gap: 16px;
}

/* --- Detail / Conversation Panel (Full Width) --- */
.detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: hidden;
}
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e8ecf1;
  background: #fafbfc;
}
.detail-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #1a365d;
}
.detail-meta {
  font-size: 12px;
  color: #8892a0;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* 会話吹き出し */
.chat-message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-message.user {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}
.msg-avatar.bot-avatar {
  background: linear-gradient(135deg, #1a365d, #2d4a7a);
}
.msg-avatar.user-avatar {
  background: linear-gradient(135deg, #38a169, #68d391);
}

.msg-bubble {
  max-width: none;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.65;
  position: relative;
  white-space: pre-wrap;
}
.chat-message.bot .msg-bubble {
  background: #f0f4f9;
  color: #333;
  border-bottom-left-radius: 4px;
}
.chat-message.user .msg-bubble {
  background: #1a365d;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-time {
  font-size: 10px;
  color: #a0a8b4;
  margin-top: 2px;
  padding: 0 4px;
}
.chat-message.user .msg-time {
  text-align: right;
  color: #a0a8b4;
}

/* Feedback badge (解決/解決せず) */
.msg-content-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  max-width: none;
}
.chat-message.user .msg-content-wrapper {
  align-items: flex-end;
}
.feedback-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 0;
}
.feedback-good {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}
.feedback-bad {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* Placeholder */
.detail-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #a0a8b4;
  gap: 12px;
}
.detail-placeholder .ph-icon {
  font-size: 48px;
  opacity: 0.4;
}
.detail-placeholder p {
  font-size: 14px;
}

/* --- Search Result Info --- */
.search-result-info {
  padding: 10px 16px;
  font-size: 12px;
  color: #5a6474;
  background: #f7f8fa;
  border-bottom: 1px solid #e8ecf1;
  display: none;
}
.search-result-info.has-result {
  display: block;
}
.search-result-info .result-chatid {
  font-weight: 700;
  color: #1a365d;
}
.search-result-info .result-date {
  margin-left: 12px;
  color: #8892a0;
}

/* --- No result message --- */
.no-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #c53030;
  gap: 12px;
}
.no-result .nr-icon {
  font-size: 48px;
  opacity: 0.5;
}
.no-result p {
  font-size: 14px;
  color: #8892a0;
}

/* --- Loading State --- */
.loading-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #5a6474;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e8ecf1;
  border-top: 3px solid #1a365d;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* --- Error State --- */
.error-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #c53030;
  gap: 12px;
}
.error-state .err-icon {
  font-size: 48px;
  opacity: 0.5;
}
.error-state p {
  font-size: 14px;
  color: #8892a0;
}

/* --- Footer --- */
.app-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 8px;
  font-size: 11px;
  color: #a0a8b4;
  background: #f0f2f5;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4cad3; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0a8b4; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .main-content {
    padding: 12px 16px 16px;
  }
  .msg-bubble {
    max-width: none;
  }
}
