/* ================================================
   TATE+ Design System v2
   Warm Intelligence - 温かなインテリジェンス
   ================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;600;700&display=swap');

:root {
  /* ========================================
     ベースカラー（白・グレー系）
     ======================================== */
  --bg-page: #FAFAF9;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F5F5F4;

  /* ボーダー */
  --border-default: #ECECEC;
  --border-subtle: #F5F5F4;

  /* ========================================
     テキストカラー
     ======================================== */
  --text-primary: #3D3D3D;
  --text-secondary: #6B6B6B;
  --text-muted: #8C8C8C;
  --text-placeholder: #A3A3A3;
  --text-disabled: #D4D4D4;

  /* ========================================
     アクセントカラー（コーラル系・1色のみ）
     ======================================== */
  --accent-solid: #E07A5F;
  --accent-text: #C96B50;
  --accent-bg: rgba(224, 122, 95, 0.06);
  --accent-bg-hover: rgba(224, 122, 95, 0.10);
  --accent-border: rgba(224, 122, 95, 0.15);
  --accent-icon-bg: rgba(224, 122, 95, 0.12);

  /* ========================================
     セマンティックカラー（控えめに使用）
     ======================================== */
  --success-solid: #4AA37C;
  --success-text: #4AA37C;
  --success-bg: rgba(74, 163, 124, 0.06);
  --success-border: rgba(74, 163, 124, 0.12);

  --warning-solid: #B8860B;
  --warning-text: #B8860B;
  --warning-bg: rgba(217, 170, 100, 0.10);
  --warning-border: rgba(217, 170, 100, 0.15);

  --error-solid: #C96B50;
  --error-text: #C96B50;
  --error-bg: rgba(224, 122, 95, 0.10);
  --error-border: rgba(224, 122, 95, 0.15);

  /* ========================================
     タイポグラフィ
     ======================================== */
  --font-family: "Inter", "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 15px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 24px;
  --text-3xl: 28px;

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* ========================================
     スペーシング
     ======================================== */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* ========================================
     角丸
     ======================================== */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* ========================================
     シャドウ（控えめ）
     ======================================== */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.08);

  /* ========================================
     トランジション
     ======================================== */
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-secondary);
  background: var(--bg-page);
  min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

h1 { font-size: var(--text-2xl); letter-spacing: -0.02em; }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p { margin-bottom: var(--sp-4); }

a {
  color: var(--accent-text);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-solid);
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-6);
}

/* Header / Navigation */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  margin: calc(-1 * var(--sp-4)) calc(-1 * var(--sp-6)) var(--sp-6);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.logo-img {
  height: 32px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
}

.logo-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-solid);
  border-radius: var(--radius-lg);
  color: white;
}

.logo-text {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

/* Navigation Tabs */
nav {
  display: flex;
  gap: var(--sp-1);
  padding: var(--sp-1);
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
}

.nav-tab {
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-secondary);
}

.nav-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* User Info */
.user-info {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.user-email {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Legacy nav button styles (for compatibility) */
nav .btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
}

nav .btn:hover {
  color: var(--text-secondary);
  background: transparent;
  transform: none;
  box-shadow: none;
}

nav .btn.active,
nav .btn-primary {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

nav .btn-ai {
  background: var(--accent-bg);
  color: var(--accent-text);
  border: 1px solid var(--accent-border);
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--sp-4);
  margin-bottom: var(--sp-4);
  transition: border-color var(--transition-fast);
}

.card:hover {
  border-color: var(--border-subtle);
}

.card h2, .card h3 {
  margin-bottom: var(--sp-3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 40px;
  padding: 0 var(--sp-5);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  font-family: var(--font-family);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn:hover {
  background: var(--bg-elevated);
}

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

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-border);
}

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

/* Primary Button - 薄いアクセント背景 */
.btn-primary {
  background: var(--accent-bg);
  color: var(--text-primary);
  border: 1px solid var(--accent-border);
}

.btn-primary:hover {
  background: var(--accent-bg-hover);
}

.btn-primary .icon {
  color: var(--accent-text);
}

/* Large Primary Button */
.btn-primary-lg {
  width: 100%;
  padding: var(--sp-5);
  height: auto;
  border-radius: var(--radius-2xl);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  text-align: left;
}

.btn-primary-lg:hover {
  background: var(--accent-bg-hover);
}

/* Secondary Button */
.btn-secondary {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
}

/* Ghost Button */
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: transparent;
}

/* AI Button - 薄いアクセント */
.btn-ai {
  background: var(--accent-bg);
  color: var(--accent-text);
  border: 1px solid var(--accent-border);
}

.btn-ai:hover {
  background: var(--accent-bg-hover);
}

/* Forms */
input, textarea, select {
  width: 100%;
  min-height: 40px;
  padding: var(--sp-3) var(--sp-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-surface);
  transition: all var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent-border);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: var(--leading-normal);
}

input::placeholder, textarea::placeholder {
  color: var(--text-placeholder);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238C8C8C' stroke-width='1.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: var(--sp-10);
}

/* Stat Cards */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--sp-4);
}

.stat-card .stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1;
}

.stat-card .stat-value.highlight {
  color: var(--accent-text);
}

.stat-card .stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* Severity Levels - 薄い背景 */
.severity-1 {
  border-left: 3px solid var(--success-solid);
}
.severity-2 {
  border-left: 3px solid #84CC16;
}
.severity-3 {
  border-left: 3px solid var(--warning-solid);
}
.severity-4 {
  border-left: 3px solid var(--accent-solid);
}
.severity-5 {
  border-left: 3px solid var(--error-solid);
}

/* Badges - 薄い背景 + テキスト色 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-danger {
  background: var(--error-bg);
  color: var(--error-text);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.badge-neutral {
  background: var(--bg-elevated);
  color: var(--text-muted);
}

/* List Items */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.list-item:hover {
  background: var(--bg-elevated);
}

.list-item:last-child {
  border-bottom: none;
}

/* Indicator Dots */
.indicator-new {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-solid);
}

.indicator-read {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #D4D4D4;
}

/* Icon Wrapper */
.icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.icon-wrapper.accent {
  background: var(--accent-icon-bg);
  color: var(--accent-text);
}

/* Section Headers */
.section-header {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-3);
}

/* Quick Actions Grid */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-4);
  height: auto;
  text-align: left;
}

.action-btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--text-lg);
}

.btn-primary .action-btn-icon,
.btn-ai .action-btn-icon {
  background: var(--accent-icon-bg);
  color: var(--accent-text);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--sp-5);
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* Status Card */
.status-card {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-xl);
  padding: var(--sp-4);
}

.status-card .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success-solid);
}

.status-card .status-text {
  font-size: var(--text-sm);
  color: var(--success-text);
  font-weight: var(--font-medium);
}

/* Result Area */
#result-area .card {
  animation: slideIn var(--transition-normal);
}

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

#result-content p {
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--border-subtle);
}

#result-content p:last-child {
  border-bottom: none;
}

#result-content strong {
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

/* Login Page */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-4);
}

.login-card {
  max-width: 400px;
  width: 100%;
  text-align: center;
  padding: var(--sp-10);
}

.login-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-xl);
  background: var(--accent-solid);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-5);
  color: white;
}

.login-card h1 {
  margin-bottom: var(--sp-2);
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: var(--sp-8);
}

.login-card .btn {
  width: 100%;
  height: 48px;
  font-size: var(--text-base);
}

/* User Info */
#user-info {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-left: var(--sp-3);
}

#user-info span {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#user-info .btn {
  padding: var(--sp-2) var(--sp-3);
  height: 32px;
  font-size: var(--text-xs);
}

/* Chat Styles (Counseling) */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 400px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  background: var(--bg-page);
  border-radius: var(--radius-lg);
  scroll-behavior: smooth;
}

.message {
  max-width: 80%;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
  border-radius: var(--radius-lg);
  line-height: var(--leading-normal);
  animation: messageIn var(--transition-normal);
}

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

.message-user {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  color: var(--text-primary);
  margin-left: auto;
  border-bottom-right-radius: var(--sp-1);
}

.message-assistant {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  margin-right: auto;
  border-bottom-left-radius: var(--sp-1);
}

.input-area {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-default);
}

.input-area textarea {
  flex: 1;
  min-height: 48px;
  max-height: 100px;
  resize: none;
}

/* Sessions Sidebar */
.sessions-sidebar {
  width: 260px;
  border-right: 1px solid var(--border-default);
  padding-right: var(--sp-4);
  margin-right: var(--sp-4);
}

.session-item {
  padding: var(--sp-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: var(--sp-2);
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.session-item:hover {
  background: var(--bg-elevated);
}

.session-item.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
}

/* History Page */
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--sp-4);
}

.history-item-content {
  flex: 1;
}

.history-item-meta {
  text-align: right;
  min-width: 120px;
}

.history-timestamp {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Audio Visualizer */
.audio-visualizer {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
}

.audio-bar {
  width: 6px;
  background: var(--accent-solid);
  border-radius: 3px;
  transition: height 0.1s ease-out;
}

/* Mic Button */
.mic-button {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  background: var(--accent-bg);
  border: 2px solid var(--accent-border);
  color: var(--accent-text);
  font-size: 2.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mic-button:hover {
  background: var(--accent-bg-hover);
  transform: scale(1.02);
}

.mic-button.recording {
  background: var(--error-bg);
  border-color: var(--error-border);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-2xl);
  padding: var(--sp-12);
  background: var(--bg-page);
  transition: all var(--transition-fast);
  cursor: pointer;
  text-align: center;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent-border);
  background: var(--accent-bg);
}

.drop-zone-icon {
  font-size: 3rem;
  margin-bottom: var(--sp-3);
  color: var(--text-muted);
}

.drop-zone-text {
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.drop-zone-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-default);
  border-radius: var(--radius-full);
  margin-top: var(--sp-3);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent-solid);
  border-radius: var(--radius-full);
  transition: width 0.3s ease-out;
}

/* Loading State */
.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-solid);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
  }
}

@media (max-width: 768px) {
  .container {
    padding: var(--sp-3);
  }

  header {
    flex-direction: column;
    gap: var(--sp-3);
    text-align: center;
    position: relative;
  }

  nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .sessions-sidebar {
    display: none;
  }

  .message {
    max-width: 90%;
  }

  .history-item {
    flex-direction: column;
    gap: var(--sp-2);
  }

  .history-item-meta {
    text-align: left;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    grid-template-columns: 1fr;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
  }

  .card {
    box-shadow: none;
    border: 1px solid var(--border-default);
  }

  header nav,
  .mic-button,
  .drop-zone {
    display: none;
  }
}

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

/* Focus Visible */
:focus-visible {
  outline: 2px solid var(--accent-solid);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background: var(--accent-bg-hover);
  color: var(--text-primary);
}

/* Footer */
.site-footer {
  margin-top: auto;
  padding: var(--sp-4) var(--sp-6);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-top: 1px solid var(--border-default);
}

.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 200ms ease;
}

.site-footer a:hover {
  color: var(--accent-text);
}

.footer-links {
  display: flex;
  gap: var(--sp-4);
}

.footer-credit {
  opacity: 0.8;
}
