/* @section:memory-map - Memory Map Page Styles */

.memory-container {
  padding: 12px;
  max-width: 1400px;
}

/* Header with filters and actions */
.memory-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.memory-title {
  font-size: var(--t-lg);
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.memory-title-icon {
  font-size: var(--t-xl);
}

.memory-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.memory-filter-btn {
  padding: 5px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  color: #64748b;
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.memory-filter-btn:hover {
  border-color: #818cf8;
  color: #818cf8;
}

.memory-filter-btn.active {
  background: #818cf8;
  border-color: #818cf8;
  color: #fff;
}

.memory-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.memory-action-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.memory-action-btn.primary {
  background: #818cf8;
  color: #fff;
}

.memory-action-btn.primary:hover {
  background: #6366f1;
}

.memory-action-btn.secondary {
  background: #f1f5f9;
  color: #475569;
}

.memory-action-btn.secondary:hover {
  background: #e2e8f0;
}

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

/* Stats Row */
.memory-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.memory-stat {
  background: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 100px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.memory-stat-value {
  font-size: var(--t-2xl);
  font-weight: 700;
  color: #1e293b;
}

.memory-stat-label {
  font-size: var(--t-xs);
  color: #64748b;
  margin-top: 2px;
}

.memory-stat.bullish .memory-stat-value { color: #16a34a; }
.memory-stat.bearish .memory-stat-value { color: #dc2626; }

/* Memory Grid */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* Memory Card */
.memory-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
  position: relative;
}

.memory-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.memory-card.selected {
  border-color: #818cf8;
}

.memory-card.dormant {
  opacity: 0.6;
}

.memory-card.resolved {
  opacity: 0.4;
  background: #f8fafc;
}

.memory-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.memory-card-name {
  font-size: var(--t-base);
  font-weight: 600;
  color: #1e293b;
  line-height: 1.3;
  flex: 1;
  margin-right: 8px;
}

.memory-card-category {
  font-size: var(--t-2xs);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  background: #f1f5f9;
  color: #64748b;
  white-space: nowrap;
}

.memory-card-category.geopolitical { background: #fef3c7; color: #92400e; }
.memory-card-category.macro { background: #dbeafe; color: #1e40af; }
.memory-card-category.sector { background: #dcfce7; color: #166534; }
.memory-card-category.ticker { background: #f3e8ff; color: #7c3aed; }
.memory-card-category.theme { background: #e0e7ff; color: #4338ca; }
.memory-card-category.relationship { background: #fce7f3; color: #be185d; }
.memory-card-category.event { background: #fee2e2; color: #991b1b; }

/* Scores Row */
.memory-card-scores {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.memory-sentiment {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--t-sm);
  font-weight: 600;
}

.memory-sentiment.positive { color: #16a34a; }
.memory-sentiment.negative { color: #dc2626; }
.memory-sentiment.neutral { color: #64748b; }

.memory-sentiment-arrow {
  font-size: var(--t-xs);
}

.memory-importance {
  font-size: var(--t-sm);
  color: #64748b;
}

.memory-importance-bar {
  display: inline-flex;
  height: 6px;
  width: 50px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  margin-left: 4px;
  vertical-align: middle;
}

.memory-importance-fill {
  height: 100%;
  background: #818cf8;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Assets */
.memory-card-assets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.memory-asset-tag {
  font-size: var(--t-2xs);
  padding: 2px 6px;
  background: #f1f5f9;
  color: #818cf8;
  border-radius: 4px;
  font-weight: 600;
}

/* Footer */
.memory-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--t-xs);
  color: #94a3b8;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.memory-card-time {
  display: flex;
  align-items: center;
  gap: 4px;
}

.memory-card-signals {
  color: #64748b;
}

/* ============================================ */
/* DETAIL PANEL (Slide-in drawer) */
/* ============================================ */

.memory-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

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

.memory-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100%;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.memory-detail-panel.active {
  transform: translateX(0);
}

.memory-detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.memory-detail-close {
  background: none;
  border: none;
  font-size: var(--t-xl);
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.memory-detail-close:hover {
  color: #1e293b;
}

.memory-detail-title {
  flex: 1;
}

.memory-detail-name {
  font-size: var(--t-lg);
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 4px;
}

.memory-detail-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.memory-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

/* Score Gauges */
.memory-gauges {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.memory-gauge {
  text-align: center;
}

.memory-gauge-label {
  font-size: var(--t-xs);
  color: #64748b;
  margin-bottom: 6px;
}

.memory-gauge-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.memory-gauge-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.memory-gauge-fill.sentiment {
  position: absolute;
  left: 50%;
  transform-origin: left center;
}

.memory-gauge-fill.sentiment.positive {
  background: linear-gradient(90deg, #a3e635, #22c55e);
}

.memory-gauge-fill.sentiment.negative {
  background: linear-gradient(90deg, #f87171, #ef4444);
  left: auto;
  right: 50%;
  transform-origin: right center;
}

.memory-gauge-fill.importance {
  background: linear-gradient(90deg, #818cf8, #6366f1);
}

.memory-gauge-fill.confidence {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.memory-gauge-value {
  font-size: var(--t-sm);
  font-weight: 600;
  color: #1e293b;
  margin-top: 4px;
}

/* Section styles */
.memory-section {
  margin-bottom: 20px;
}

.memory-section-title {
  font-size: var(--t-sm);
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.memory-section-content {
  font-size: var(--t-base);
  color: #334155;
  line-height: 1.6;
}

/* Assets list in detail */
.memory-detail-assets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.memory-detail-asset {
  padding: 4px 10px;
  background: #818cf8;
  color: #fff;
  border-radius: 4px;
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.memory-detail-asset:hover {
  background: #6366f1;
}

/* Trade implications */
.memory-trades-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.memory-trade-item {
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: var(--t-sm);
  color: #334155;
  border-left: 3px solid #818cf8;
}

/* Timeline */
.memory-timeline {
  position: relative;
  padding-left: 20px;
}

.memory-timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e2e8f0;
}

.memory-timeline-item {
  position: relative;
  padding-bottom: 16px;
}

.memory-timeline-item::before {
  content: '';
  position: absolute;
  left: -17px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #818cf8;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #e2e8f0;
}

.memory-timeline-item.positive::before { background: #22c55e; }
.memory-timeline-item.negative::before { background: #ef4444; }

.memory-timeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.memory-timeline-date {
  font-size: var(--t-xs);
  color: #94a3b8;
}

.memory-timeline-delta {
  font-size: var(--t-xs);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
}

.memory-timeline-delta.positive { background: #dcfce7; color: #166534; }
.memory-timeline-delta.negative { background: #fee2e2; color: #991b1b; }

.memory-timeline-source {
  font-size: var(--t-xs);
  color: #818cf8;
  margin-left: auto;
}

.memory-timeline-summary {
  font-size: var(--t-sm);
  color: #334155;
  line-height: 1.5;
}

.memory-timeline-reasoning {
  font-size: var(--t-xs);
  color: #64748b;
  margin-top: 4px;
  font-style: italic;
}

/* Detail Actions */
.memory-detail-actions {
  padding: 16px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
}

.memory-detail-actions button {
  flex: 1;
  padding: 10px 14px;
  border: none;
  border-radius: 6px;
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.memory-detail-actions .btn-edit {
  background: #f1f5f9;
  color: #475569;
}

.memory-detail-actions .btn-edit:hover {
  background: #e2e8f0;
}

.memory-detail-actions .btn-delete {
  background: #fee2e2;
  color: #dc2626;
}

.memory-detail-actions .btn-delete:hover {
  background: #fecaca;
}

/* ============================================ */
/* MODAL (Create/Edit Memory) */
/* ============================================ */

.memory-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.memory-modal-overlay.active {
  display: flex;
}

.memory-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.memory-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.memory-modal-title {
  font-size: var(--t-lg);
  font-weight: 700;
  color: #1e293b;
}

.memory-modal-close {
  background: none;
  border: none;
  font-size: var(--t-2xl);
  color: #64748b;
  cursor: pointer;
  line-height: 1;
}

.memory-modal-body {
  padding: 20px;
}

.memory-form-group {
  margin-bottom: 16px;
}

.memory-form-label {
  display: block;
  font-size: var(--t-sm);
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.memory-form-input,
.memory-form-textarea,
.memory-form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: var(--t-base);
  color: #1e293b;
  background: #fff;
  transition: border-color 0.15s;
}

.memory-form-input:focus,
.memory-form-textarea:focus,
.memory-form-select:focus {
  outline: none;
  border-color: #818cf8;
}

.memory-form-textarea {
  resize: vertical;
  min-height: 80px;
}

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

.memory-form-hint {
  font-size: var(--t-xs);
  color: #94a3b8;
  margin-top: 4px;
}

.memory-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.memory-modal-footer button {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.memory-modal-footer .btn-cancel {
  background: #f1f5f9;
  color: #475569;
}

.memory-modal-footer .btn-cancel:hover {
  background: #e2e8f0;
}

.memory-modal-footer .btn-save {
  background: #818cf8;
  color: #fff;
}

.memory-modal-footer .btn-save:hover {
  background: #6366f1;
}

/* ============================================ */
/* EMPTY STATE */
/* ============================================ */

.memory-empty {
  text-align: center;
  padding: 60px 20px;
  color: #64748b;
}

.memory-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.memory-empty-title {
  font-size: var(--t-lg);
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

.memory-empty-text {
  font-size: var(--t-base);
  margin-bottom: 20px;
}

.memory-empty-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ============================================ */
/* LOADING STATE */
/* ============================================ */

.memory-loading {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
}

.memory-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* ============================================ */
/* RESPONSIVE */
/* ============================================ */

@media (max-width: 768px) {
  .memory-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .memory-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .memory-grid {
    grid-template-columns: 1fr;
  }

  .memory-detail-panel {
    width: 100%;
  }

  .memory-gauges {
    grid-template-columns: 1fr;
  }

  .memory-form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================ */
/* SENTIMENT SPARKLINE CHART */
/* ============================================ */

.memory-sentiment-chart {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  justify-content: center;
}

.sentiment-sparkline {
  max-width: 100%;
}

/* Updated Timeline Styles */
.memory-timeline-sentiment {
  font-size: var(--t-xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f1f5f9;
}

.memory-timeline-sentiment.positive {
  background: #dcfce7;
  color: #166534;
}

.memory-timeline-sentiment.negative {
  background: #fee2e2;
  color: #991b1b;
}

.memory-timeline-delta {
  font-size: var(--t-2xs);
  color: #94a3b8;
  font-weight: 500;
}
