/* styles/home.css
 * POKIダッシュボードのホーム画面専用スタイル。
 * このファイルを編集して良いのは "ホーム画面" 関連だけ。
 * base.css / transfer.css / master.css のルールには触れないこと。
 */

#homeView {
  min-height: calc(100vh - var(--header-h));
  align-items: flex-start;
  justify-content: center;
  /* 上パディング: アイコン＋挨拶＋ボックス上半分の合計を差し引いて
     検索ボックスの中心が画面中央（50vh）に来るように設定 */
  padding: calc(50vh - 340px) 20px 40px;
}
/* display: flex を hidden 属性と両立させるための定義。
   これを指定しないと `display: flex` が `hidden` 属性の display: none を上書きしてしまう。 */
#homeView:not([hidden]) { display: flex; }

.home-inner {
  width: 100%;
  max-width: 720px;
  text-align: center;
}

.home-poki {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin: 0 auto 14px;
  display: block;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.08));
}

.home-greet { margin-bottom: 22px; }
.home-greet-main {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.home-greet-sub {
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.6;
}

.home-search {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px 16px 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.06);
  transition: border-color .15s, box-shadow .15s;
  text-align: left;
}
.home-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 6px 28px rgba(92,100,255,0.18);
}

.home-search-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.55;
  resize: none;
  padding: 4px 4px 6px;
  min-height: 44px;
  max-height: 200px;
}
.home-search-input::placeholder { color: var(--text-sub); }

.home-search-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.home-mic-btn,
.home-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, opacity .15s, border-color .15s;
  font-family: inherit;
}

.home-mic-btn {
  background: var(--bg);
  color: var(--text-sub);
  border-color: var(--border);
}
.home-mic-btn:hover {
  background: var(--border);
  color: var(--text);
}

.home-send-btn {
  background: var(--accent);
  color: #fff;
}
.home-send-btn:hover { opacity: 0.9; }
.home-send-btn:disabled {
  background: var(--border);
  color: var(--text-sub);
  cursor: not-allowed;
}

.home-hint {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-sub);
  letter-spacing: 0.1px;
}

/* ===== チャットモード ===== */
.home-chat {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  height: calc(100vh - var(--header-h) - 40px);
  flex-direction: column;
  padding: 20px 20px 24px;
}
/* display: flex と hidden 属性を両立させる */
.home-chat:not([hidden]) { display: flex; }
.home-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 4px 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-msg {
  display: flex;
  gap: 10px;
  max-width: 100%;
  animation: chatMsgIn .18s ease-out;
}
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg-user { justify-content: flex-end; }
.chat-msg-assistant { justify-content: flex-start; align-items: flex-start; }
.chat-avatar {
  width: 34px; height: 34px;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}
.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  max-width: 72%;
  word-wrap: break-word;
  white-space: normal;
}
.chat-msg-user .chat-bubble {
  background: var(--accent);
  color: #fff;
  border-top-right-radius: 6px;
}
.chat-msg-assistant .chat-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-top-left-radius: 6px;
}
.chat-bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-msg-user .chat-bubble a { color: #fff; }
.chat-msg-assistant .chat-bubble a { color: var(--accent); }
.chat-bubble code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.06);
}
.chat-msg-user .chat-bubble code { background: rgba(255,255,255,0.2); }

.chat-msg-error .chat-bubble {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.chat-typing {
  display: inline-flex;
  gap: 4px;
  padding: 2px 0;
}
.chat-typing span {
  width: 6px; height: 6px;
  background: var(--text-sub);
  border-radius: 50%;
  opacity: .35;
  animation: chatDot 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chatDot {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* 👍👎 フィードバックボタン（アシスタントバブルの下に表示） */
.chat-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  margin-left: 44px; /* avatar幅 + gap */
}
.chat-fb-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s, border-color .15s, transform .1s;
  opacity: .85;
}
.chat-fb-btn:hover {
  background: var(--border);
  opacity: 1;
}
.chat-fb-btn:disabled {
  cursor: default;
  opacity: .5;
}
.chat-fb-btn.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  opacity: 1;
  transform: scale(1.05);
}
.chat-fb-note {
  font-size: 11px;
  color: var(--text-sub);
  margin-left: 4px;
}

.home-chat-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 12px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
  transition: border-color .15s, box-shadow .15s;
  margin-top: 10px;
}
.home-chat-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(92,100,255,0.15);
}
.home-chat-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.55;
  resize: none;
  padding: 4px;
  min-height: 36px;
  max-height: 200px;
}
.home-chat-input::placeholder { color: var(--text-sub); }
.home-chat-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

/* モバイル */
@media (max-width: 768px) {
  #homeView { padding: 24px 14px; }
  .home-poki { width: 110px; height: 110px; }
  .home-greet-main { font-size: 18px; }
  .home-greet-sub  { font-size: 13px; }
  .home-search-input { font-size: 14px; }
  .home-chat { padding: 14px 12px 16px; height: calc(100vh - var(--header-h) - 20px); }
  .chat-bubble { max-width: 82%; font-size: 13.5px; }
  .chat-avatar { width: 28px; height: 28px; }
}
