/* ===== Page Skeleton (key) ===== */
html, body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: #f4f6f8;
}

/* ===== Header ===== */
.header {
  background: #ffffff;
  border-bottom: 1px solid #e5e5e5;
  position: relative;
}

.header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, rgba(0, 58, 143, 0) 0%, rgba(0, 58, 143, 0.35) 35%, rgba(0, 122, 255, 0.35) 65%, rgba(0, 58, 143, 0) 100%);
  pointer-events: none;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px;   
  display: flex;
  align-items: center;
  gap: 16px;            
}

.logo {
  height: 44px;        
  width: auto;
}

.title {
  font-size: 24px;      
  font-weight: 600;
  color: #003a8f;
  line-height: 1.2;
}


/* ===== Main ===== */
.main {
  flex: 1;
  overflow-y: auto;
}

/* ===== Container (limit content width) ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== chat ===== */
.chat {
  padding-bottom: 16px;
}

.msg {
  display: flex;
  margin-bottom: 18px;
}

.msg.user {
  justify-content: flex-end;
}

.msg.ai {
  justify-content: flex-start;
}

.bubble {
  max-width: 70%;
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14.5px;
  line-height: 1.7;
}

.msg.user .bubble {
  background: #eaf2ff;
  border: 1px solid #c6d9ff;
}

.msg.ai .bubble {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(214, 222, 234, 0.9);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 6px 16px rgba(0, 58, 143, 0.08);
  border-left: 3px solid rgba(0, 58, 143, 0.35);
  position: relative;
}


/* ===== AI Answer (Primary) ===== */
.answer-bubble {
  display: flex;
  flex-direction: column;
}

/* ===== AI Reasoning (Secondary) ===== */
.reasoning-bubble {
  background: #fafafa;
  border: 1px dashed #cfd8e3;
  font-size: 13px;
  color: #555;
}
.msg.ai.reasoning {
  margin-top: -6px;
}
/* ===== Footer（Full-width input area, key） ===== */
.footer {
  background: #ffffff;
  border-top: 1px solid #ddd;
}

.input-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 16px 16px;
  display: flex;
  gap: 10px;
}

.input-wrapper textarea {
  flex: 1;
  resize: none;
  padding: 14px;
  font-size: 15px;
  border-radius: 4px;
  border: 1px solid #ccc;
  height: 52px;
  line-height: 1.4;
  box-sizing: border-box;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.input-wrapper textarea:focus {
  outline: none;
  border-color: rgba(0, 58, 143, 0.45);
  box-shadow: 0 0 0 3px rgba(0, 58, 143, 0.12);
}

.input-wrapper button {
  background: #003a8f;
  color: #ffffff;
  border: none;
  padding: 0 26px;
  font-size: 15px;
  border-radius: 4px;
  cursor: pointer;
  height: 52px;
  flex-shrink: 0;
}

.input-wrapper button:disabled {
  opacity: 0.5;
}


.select-options {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-left: 4px;
}

.select-btn {
  padding: 6px 14px;
  border-radius: 999px;        
  border: 1px solid #d0d7de;
  background: #f7f8fa;
  color: #333;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.select-btn:hover {
  background: #eef2f7;
}

.select-btn.selected {
  background: #007aff;
  color: #fff;
  border-color: #007aff;
}

.select-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}


/* Top-right control bar */
#top-controls {
  position: fixed;
  top: 12px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 1000;
  font-size: 12px;
  color: #003a8f;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 58, 143, 0.12);
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: 0 6px 16px rgba(0, 58, 143, 0.10);
  backdrop-filter: blur(6px);
}

.divider {
  width: 1px;
  height: 12px;
  background: rgba(0, 58, 143, 0.2);
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 18px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* Slider */
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #ccc;
  border-radius: 22px;
  transition: background-color 0.2s ease;
}

.slider::before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  top: 2px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

/* Checked (ON) */
.switch input:checked + .slider {
  background-color: #003a8f; /* ANA blue */
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

/* ===== Login/Logout styles ===== */
.username-display {
  color: #003a8f;
  font-weight: 500;
  margin-right: 8px;
}

.logout-btn {
  padding: 4px 10px;
  font-size: 11px;
  background: #ffffff;
  color: #003a8f;
  border: 1px solid rgba(0, 58, 143, 0.25);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: #f2f6ff;
  border-color: rgba(0, 58, 143, 0.45);
}

/* ===== Streaming status ===== */
#loading {
  width: 100%;
  display: flex;
  justify-content: center;
}

.status-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.status-text {
  position: relative;
  font-size: 16px;
  font-weight: 600;
  color: #003a8f;
  letter-spacing: 0.02em;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
  border: 1px solid rgba(0, 58, 143, 0.15);
  box-shadow:
    0 0 0 1px rgba(0, 58, 143, 0.06),
    0 6px 16px rgba(0, 58, 143, 0.12),
    0 0 18px rgba(0, 58, 143, 0.18);
  animation: statusPulse 1.4s ease-in-out infinite, statusGlow 2.6s ease-in-out infinite;
  overflow: hidden;
}

.status-icon {
  margin-right: 6px;
  font-size: 16px;
}

.status-label {
  vertical-align: middle;
}

.status-bar {
  width: 240px;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 58, 143, 0.08);
  overflow: hidden;
  position: relative;
}

.status-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #003a8f 0%, #4c8dff 100%);
  border-radius: 999px;
  transition: width 0.6s ease;
  box-shadow: 0 0 12px rgba(0, 122, 255, 0.35);
  position: relative;
  overflow: hidden;
}

.status-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: -30%;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 100%);
  animation: statusShine 2.4s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes statusShine {
  0%   { transform: translateX(-10%); }
  60%  { transform: translateX(220%); }
  100% { transform: translateX(220%); }
}

.status-text::after {
  content: "";
  position: absolute;
  inset: -2px;
  background: radial-gradient(ellipse at center, rgba(0, 122, 255, 0.18) 0%, rgba(0, 122, 255, 0) 60%);
  opacity: 0.8;
  pointer-events: none;
  animation: statusHalo 2.8s ease-in-out infinite;
}

@keyframes statusGlow {
  0%   { box-shadow: 0 0 0 1px rgba(0, 58, 143, 0.06), 0 6px 16px rgba(0, 58, 143, 0.10), 0 0 16px rgba(0, 58, 143, 0.12); }
  50%  { box-shadow: 0 0 0 1px rgba(0, 58, 143, 0.10), 0 10px 22px rgba(0, 58, 143, 0.18), 0 0 28px rgba(0, 58, 143, 0.24); }
  100% { box-shadow: 0 0 0 1px rgba(0, 58, 143, 0.06), 0 6px 16px rgba(0, 58, 143, 0.10), 0 0 16px rgba(0, 58, 143, 0.12); }
}

@keyframes statusHalo {
  0%   { transform: scale(0.98); opacity: 0.4; }
  50%  { transform: scale(1.06); opacity: 0.8; }
  100% { transform: scale(0.98); opacity: 0.4; }
}

@keyframes statusPulse {
  0%   { opacity: 0.4; transform: translateY(0); }
  50%  { opacity: 1;   transform: translateY(-2px); }
  100% { opacity: 0.4; transform: translateY(0); }
}
