/* ============================================================
   Juken AI — Stylesheet
   ============================================================ */

:root {
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --sidebar-width: 260px;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-hint: #94a3b8;
  --color-success: #22c55e;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
}
.sidebar-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-600);
}
.sidebar-logo p {
  font-size: 11px;
  color: var(--color-text-hint);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all 0.15s;
}
.nav-item:hover {
  background: #f8fafc;
  color: var(--color-text);
}
.nav-item.active {
  background: var(--brand-50);
  color: var(--brand-700);
}

/* --- Main content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  max-width: 1200px;
}

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 16px;
}

/* --- Grid --- */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* --- Stat cards --- */
.stat-card {
  background: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 16px;
}
.stat-card .label {
  font-size: 12px;
  color: var(--color-text-hint);
}
.stat-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 4px;
}
.stat-card .sub {
  font-size: 11px;
  color: var(--color-text-hint);
  margin-top: 2px;
}

/* --- Alerts --- */
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid;
}
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--brand-600); color: white; }
.btn-primary:hover { background: var(--brand-700); }
.btn-secondary { background: #f1f5f9; color: var(--color-text-secondary); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-ghost { background: transparent; color: var(--brand-600); }
.btn-ghost:hover { background: var(--brand-50); }

/* --- Form elements --- */
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

/* --- Unit pills --- */
.unit-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid;
}
.pill-good  { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.pill-ok    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.pill-warn  { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.pill-bad   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* --- Chat --- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--brand-600);
  color: white;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 16px;
}
.chat-input-area input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
}
.chat-input-area input:focus {
  box-shadow: none;
}
.chat-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.chat-action-btn {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #f1f5f9;
  color: var(--color-text-secondary);
  border: none;
  cursor: pointer;
}
.chat-action-btn:hover { background: #e2e8f0; }

/* --- Toggle buttons (correct/incorrect) --- */
.toggle-group {
  display: flex;
  gap: 4px;
}
.toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.toggle-btn.correct { background: #f0fdf4; color: #22c55e; }
.toggle-btn.correct.active { background: #dcfce7; color: #16a34a; }
.toggle-btn.incorrect { background: #fef2f2; color: #ef4444; }
.toggle-btn.incorrect.active { background: #fee2e2; color: #dc2626; }

/* --- Task list --- */
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.task-item:last-child { border-bottom: none; }

.task-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.task-check.done {
  background: var(--color-success);
  border-color: var(--color-success);
}

.task-type-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
}
.badge-drill   { background: #eff6ff; color: #1e40af; }
.badge-review  { background: #f0fdf4; color: #166534; }
.badge-new     { background: #faf5ff; color: #6b21a8; }
.badge-past    { background: #fffbeb; color: #92400e; }

/* --- Loading spinner --- */
.loading-dots {
  display: flex;
  gap: 6px;
}
.loading-dots span {
  width: 8px; height: 8px;
  background: #cbd5e1;
  border-radius: 50%;
  animation: bounce 1s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.1s; }
.loading-dots span:nth-child(3) { animation-delay: 0.2s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* --- Utilities --- */
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.gap-3 { gap: 12px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-secondary { color: var(--color-text-secondary); }
.text-hint { color: var(--color-text-hint); }
.font-bold { font-weight: 700; }
.space-y-4 > * + * { margin-top: 16px; }
.space-y-2 > * + * { margin-top: 8px; }
