/* ============================================
   にらさきナビ - チャットボット スタイル
   韮崎市の自然をイメージした緑×空色テーマ
   ============================================ */

/* --- CSS Variables --- */
:root {
  --color-primary: #2d8a56;
  --color-primary-light: #3ba76a;
  --color-primary-dark: #1e6b40;
  --color-sky: #4ea8d1;
  --color-sky-light: #7dc4e3;
  --color-mountain: #5b8c5a;

  --color-bg: #f0f5f1;
  --color-bg-chat: #f7faf8;
  --color-surface: #ffffff;

  --color-text: #1a2e22;
  --color-text-secondary: #5a7265;
  --color-text-light: #8a9e92;

  --color-user-bubble: #2d8a56;
  --color-user-text: #ffffff;
  --color-bot-bubble: #ffffff;
  --color-bot-text: #1a2e22;

  --color-border: #d4e4da;
  --color-border-light: #e8f0eb;

  --shadow-sm: 0 1px 3px rgba(45, 138, 86, 0.08);
  --shadow-md: 0 4px 12px rgba(45, 138, 86, 0.1);
  --shadow-lg: 0 8px 32px rgba(45, 138, 86, 0.12);
  --shadow-bubble: 0 2px 8px rgba(0, 0, 0, 0.06);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  background: linear-gradient(135deg, #e8f5ec 0%, #e0f0f8 50%, #eef6f0 100%);
  color: var(--color-text);
  line-height: 1.7;
  min-height: 100dvh;
  overflow: hidden;
}

/* --- App Container --- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
  background: var(--color-bg-chat);
  box-shadow: var(--shadow-lg);
  position: relative;
}

@media (min-width: 840px) {
  .app-container {
    margin: 16px auto;
    height: calc(100dvh - 32px);
    border-radius: var(--radius-xl);
    overflow: hidden;
  }
}

/* ============================================
   Header
   ============================================ */
.chat-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 50%, var(--color-sky) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  box-shadow: 0 2px 12px rgba(45, 138, 86, 0.2);
}

.header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  font-size: 2rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.header-text h1 {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-subtitle {
  font-size: 0.75rem;
  opacity: 0.9;
  font-weight: 400;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5); }
  50% { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}

/* ============================================
   Chat Messages Area
   ============================================ */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(45, 138, 86, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(78, 168, 209, 0.03) 0%, transparent 50%),
    var(--color-bg-chat);
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-light);
}

/* --- Welcome Section --- */
.welcome-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 20px;
  animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.welcome-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

.welcome-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--color-primary);
  margin-bottom: 12px;
}

.welcome-text {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.8;
  max-width: 400px;
  margin-bottom: 28px;
}

/* --- Suggestion Chips --- */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 500px;
}

.chip {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.chip:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.chip:active {
  transform: translateY(0);
}

/* ============================================
   Message Bubbles
   ============================================ */
.message-row {
  display: flex;
  margin-bottom: 16px;
  animation: messageIn 0.35s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.bot {
  justify-content: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-row.bot .message-avatar {
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-sky));
  margin-right: 10px;
  box-shadow: var(--shadow-sm);
}

.message-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  line-height: 1.75;
  font-size: 0.95rem;
  word-break: break-word;
  position: relative;
}

.message-row.user .message-bubble {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: var(--color-user-text);
  border-bottom-right-radius: 6px;
  box-shadow: 0 2px 8px rgba(45, 138, 86, 0.2);
}

.message-row.bot .message-bubble {
  background: var(--color-bot-bubble);
  color: var(--color-bot-text);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-bubble);
  border: 1px solid var(--color-border-light);
}

/* Markdown content in bot messages */
.message-bubble p {
  margin-bottom: 8px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble strong {
  font-weight: 700;
  color: var(--color-primary-dark);
}

.message-row.user .message-bubble strong {
  color: inherit;
}

.message-bubble ul,
.message-bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message-bubble li {
  margin-bottom: 4px;
}

.message-bubble code {
  background: rgba(45, 138, 86, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}

/* --- Typing Indicator --- */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--color-text-light);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

/* ============================================
   Input Area
   ============================================ */
.chat-input-area {
  padding: 12px 20px 16px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 6px 6px 6px 16px;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.input-container:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45, 138, 86, 0.12);
}

.message-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-family);
  font-size: 0.95rem;
  color: var(--color-text);
  resize: none;
  outline: none;
  line-height: 1.6;
  padding: 8px 0;
  max-height: 120px;
  overflow-y: auto;
}

.message-input::placeholder {
  color: var(--color-text-light);
}

.send-button {
  width: 42px;
  height: 42px;
  border: none;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-normal);
  box-shadow: 0 2px 8px rgba(45, 138, 86, 0.25);
}

.send-button:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(45, 138, 86, 0.35);
}

.send-button:active {
  transform: scale(0.95);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.input-hint {
  text-align: center;
  font-size: 0.7rem;
  color: var(--color-text-light);
  margin-top: 6px;
}

/* ============================================
   Error Message
   ============================================ */
.error-bubble {
  background: #fef2f2 !important;
  border: 1px solid #fecaca !important;
  color: #991b1b !important;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 600px) {
  .chat-header {
    padding: 12px 16px;
  }

  .header-icon {
    font-size: 1.6rem;
  }

  .header-text h1 {
    font-size: 1.1rem;
  }

  .header-status {
    padding: 4px 10px;
    font-size: 0.7rem;
  }

  .chat-messages {
    padding: 16px;
  }

  .welcome-section {
    padding: 24px 12px;
  }

  .welcome-icon {
    font-size: 2.8rem;
  }

  .welcome-title {
    font-size: 1.25rem;
  }

  .welcome-text {
    font-size: 0.88rem;
  }

  .chip {
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  .message-bubble {
    max-width: 85%;
    font-size: 0.9rem;
    padding: 10px 14px;
  }

  .message-avatar {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }

  .chat-input-area {
    padding: 10px 16px 14px;
  }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
