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

/* --- Modern Reset & Base --- */
:root {
  --font-sans: 'Outfit', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Color Palette - Deep Calming Slate & Indigo Accent */
  --bg-base: hsl(222, 25%, 8%);
  --bg-sidebar: hsl(222, 25%, 11%);
  --bg-card: hsla(222, 25%, 14%, 0.65);
  --bg-card-hover: hsla(222, 25%, 18%, 0.85);
  --bg-input: hsla(222, 25%, 6%, 0.8);
  --bg-glass-modal: hsla(222, 25%, 10%, 0.85);
  
  --border-color: hsla(217, 10%, 60%, 0.1);
  --border-focus: hsla(220, 95%, 60%, 0.4);
  
  --accent-indigo: hsl(220, 95%, 65%);
  --accent-indigo-glow: hsla(220, 95%, 65%, 0.15);
  --accent-amber: hsl(35, 90%, 55%);
  --accent-amber-glow: hsla(35, 90%, 55%, 0.15);
  --accent-sage: hsl(145, 55%, 50%);
  --accent-sage-glow: hsla(145, 55%, 50%, 0.15);
  
  --text-primary: hsl(210, 20%, 98%);
  --text-secondary: hsl(210, 12%, 80%);
  --text-muted: hsl(210, 10%, 55%);
  
  --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  
  /* Categories custom accent colors */
  --cat-career: var(--accent-indigo);
  --cat-relationship: hsl(325, 75%, 65%);
  --cat-mind: var(--accent-amber);
  --cat-selfworth: hsl(270, 70%, 65%);
  --cat-habit: var(--accent-sage);
  --cat-general: hsl(180, 60%, 50%);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-secondary);
  overflow: hidden;
  height: 100dvh;
  width: 100vw;
  display: flex;
}

/* --- Calming Ambient Glow --- */
.ambient-glow {
  position: absolute;
  top: 10%;
  right: 15%;
  width: 40vw;
  height: 40vw;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.12) 0%, rgba(168, 85, 247, 0.05) 50%, rgba(0, 0, 0, 0) 100%);
  z-index: -1;
  pointer-events: none;
  filter: blur(80px);
  animation: float-glow 25s infinite alternate ease-in-out;
}

@keyframes float-glow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-5%, 10%) scale(1.1); }
}

/* --- Custom Scrollbars --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* --- Layout Wrapper --- */
.app-container {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

/* --- Sidebar Section --- */
.sidebar {
  width: 380px;
  min-width: 340px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.logo-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo-section h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-section h1 span.icon {
  font-size: 1.6rem;
  animation: gentle-spin 4s infinite linear;
}

@keyframes gentle-spin {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(15deg); }
  100% { transform: rotate(0deg); }
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px var(--accent-indigo-glow);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1.1rem;
}

/* --- Category Filters --- */
.category-filters-container {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.05);
}

.category-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 8px 0;
  scrollbar-width: none; /* Firefox */
}

.category-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.filter-chip {
  padding: 6px 12px;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.filter-chip.active {
  background-color: var(--accent-indigo);
  border-color: var(--accent-indigo);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-indigo-glow);
}

/* --- Question List --- */
.question-list-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.question-item {
  padding: 16px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  animation: slide-in 0.4s ease-out both;
}

@keyframes slide-in {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.question-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: transparent;
  transition: background-color var(--transition-fast);
}

.question-item:hover {
  background-color: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.question-item.active {
  background-color: var(--bg-card-hover);
  border-color: var(--accent-indigo-glow);
  box-shadow: var(--shadow-md);
}

.question-item.active::before {
  background-color: var(--category-color, var(--accent-indigo));
}

.item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  color: var(--category-color, var(--accent-indigo));
  background-color: var(--category-bg, var(--accent-indigo-glow));
}

.item-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.question-item h3 {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 1px 6px;
  border-radius: 4px;
}

.empty-list {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* --- Floating Add Button inside Sidebar Footer --- */
.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  background-color: var(--bg-sidebar);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  font-size: 0.9rem;
  padding: 12px 18px;
  transition: all var(--transition-fast);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background-color: var(--accent-indigo);
  color: #fff;
  flex: 1;
}

.btn-primary:hover {
  background-color: hsl(220, 95%, 70%);
  box-shadow: 0 0 16px var(--accent-indigo-glow);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-icon-only {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
  font-size: 1.1rem;
}

/* --- Main Display Area --- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  position: relative;
  z-index: 5;
}

.top-nav {
  display: none; /* Shown only on mobile for menu toggling */
  padding: 16px 24px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  justify-content: space-between;
  align-items: center;
}

/* --- Blank State Display --- */
.blank-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  animation: fade-in 0.5s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.blank-state .illustration {
  font-size: 4rem;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 12px var(--accent-indigo-glow));
  animation: float 6s infinite ease-in-out;
}

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

.blank-state h2 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.blank-state p {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.6;
}

/* --- Q&A Details View --- */
.qa-detail-container {
  padding: 40px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-height: 100%;
  opacity: 0;
  transform: translateY(15px);
  animation: reveal-detail 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes reveal-detail {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.detail-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 24px;
}

.detail-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.detail-meta-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-meta-right {
  display: flex;
  gap: 8px;
}

.detail-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-tag {
  font-size: 0.75rem;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
}

.qa-detail-container h2.question-title {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
}

/* Action Controls (Edit, Delete, Voice) */
.action-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.action-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.action-btn.active-voice {
  background-color: var(--accent-amber-glow);
  color: var(--accent-amber);
  border-color: var(--accent-amber);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(217, 119, 6, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}

.action-btn.delete-btn:hover {
  background-color: rgba(239, 68, 68, 0.15);
  color: hsl(0, 85%, 65%);
  border-color: rgba(239, 68, 68, 0.4);
}

/* --- Calming Answer Card --- */
.answer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  line-height: 1.8;
  font-size: 1.05rem;
  color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
}

.answer-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--category-color, var(--accent-indigo));
}

/* Answer Typography rendering markdown */
.answer-body h3 {
  font-size: 1.3rem;
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: 20px;
  font-weight: 700;
  border-left: 3px solid var(--category-color, var(--accent-indigo));
  padding-left: 12px;
  line-height: 1.3;
}

.answer-body h4 {
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-top: 24px;
  margin-bottom: 12px;
  font-weight: 600;
}

.answer-body p {
  margin-bottom: 18px;
}

.answer-body p strong {
  color: var(--text-primary);
  font-weight: 600;
  background: linear-gradient(180deg, transparent 70%, var(--category-bg) 70%);
  padding: 0 2px;
}

.answer-body ul, .answer-body ol {
  margin-bottom: 20px;
  padding-left: 20px;
}

.answer-body li {
  margin-bottom: 8px;
}

.answer-body blockquote {
  border-left: 4px solid var(--border-focus);
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.02);
  margin: 18px 0;
  font-style: italic;
  color: var(--text-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* --- Editor Modal Overlay --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background-color: var(--bg-glass-modal);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 820px;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transform: translateY(30px) scale(0.98);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-container {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* --- Form Fields --- */
.editor-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px var(--accent-indigo-glow);
}

textarea.form-control {
  min-height: 200px;
  resize: vertical;
  line-height: 1.6;
}

.editor-tabs-container {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.editor-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

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

.tab-btn.active {
  color: var(--accent-indigo);
  border-bottom-color: var(--accent-indigo);
  background: rgba(255, 255, 255, 0.02);
}

.tab-content {
  padding: 0;
}

.editor-pane {
  display: block;
}

.preview-pane {
  display: none;
  padding: 16px 20px;
  height: 250px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

.preview-pane.active {
  display: block;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Helper Text */
.form-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Dialog Overlay (Confirm/Info) --- */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.dialog-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.dialog-container {
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition-fast);
}

.dialog-overlay.active .dialog-container {
  transform: scale(1);
}

.dialog-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  color: hsl(0, 85%, 65%);
}

.dialog-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.dialog-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.dialog-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* --- Toast Notification --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-indigo);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: auto;
  animation: toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toast-in {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.toast-success {
  border-left-color: var(--accent-sage);
}

.toast.toast-error {
  border-left-color: hsl(0, 85%, 65%);
}

/* --- Mobile Hamburger Menu styling --- */
.menu-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
}

/* --- Responsive Adjustments --- */
@media (max-width: 820px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    width: 320px;
    box-shadow: var(--shadow-lg);
  }
  
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  
  .top-nav {
    display: flex;
  }
  
  .qa-detail-container {
    padding: 24px;
  }
  
  .answer-card {
    padding: 20px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  /* Backdrop overlay for sidebar when open on mobile */
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 9;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
  }
  
  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }
}
