/* Cosmic Lessons - Shared Component Styles */

/* ============================================
   CSS Custom Properties (Theme)
   ============================================ */
:root {
  /* Colors */
  --color-primary: #4a37b8;
  --color-primary-light: #667eea;
  --color-primary-dark: #3730a3;

  /* Aspect colors */
  --color-challenging: #dc2626;
  --color-challenging-bg: #fee2e2;
  --color-square: #ea580c;
  --color-square-bg: #ffedd5;
  --color-flowing: #2563eb;
  --color-flowing-bg: #dbeafe;
  --color-conjunction: #7c3aed;
  --color-conjunction-bg: #ede9fe;

  /* Mood colors */
  --color-positive: #10b981;
  --color-positive-bg: #d1fae5;
  --color-mixed: #f59e0b;
  --color-mixed-bg: #fef3c7;
  --color-difficult: #ef4444;
  --color-difficult-bg: #fee2e2;

  /* Neutrals */
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-text-light: #9ca3af;
  --color-border: #e5e7eb;
  --color-bg: #f9fafb;
  --color-bg-card: #ffffff;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Border radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}


/* ============================================
   Educational Tooltips
   ============================================ */
.tooltip-trigger {
  position: relative;
  border-bottom: 1px dotted var(--color-primary);
  cursor: help;
}

.tooltip-trigger::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-text);
  color: white;
  font-size: 0.85rem;
  font-weight: normal;
  border-radius: var(--radius-md);
  white-space: nowrap;
  max-width: 300px;
  white-space: normal;
  text-align: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  pointer-events: none;
}

.tooltip-trigger::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--color-text);
  margin-bottom: -12px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.tooltip-trigger:hover::after,
.tooltip-trigger:hover::before {
  opacity: 1;
  visibility: visible;
}


/* ============================================
   Info Boxes (Educational callouts)
   ============================================ */
.info-box {
  background: #f0f9ff;
  border-left: 4px solid #3b82f6;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-sm);
  margin: var(--spacing-md) 0;
  font-size: 0.9rem;
}

.info-box-title {
  font-weight: 600;
  color: #1e40af;
  margin-bottom: var(--spacing-xs);
}

.info-box-content {
  color: #1e40af;
}

.info-box.warning {
  background: #fff7ed;
  border-left-color: #f97316;
}

.info-box.warning .info-box-title,
.info-box.warning .info-box-content {
  color: #9a3412;
}


/* ============================================
   Filter Bar & Chips
   ============================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-lg);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-md);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.filter-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.filter-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}


/* ============================================
   Planet Glyphs
   ============================================ */
.planet-glyph {
  font-size: 1.3em;
  line-height: 1;
}

.planet-glyph.sun { color: #f59e0b; }
.planet-glyph.moon { color: #6366f1; }
.planet-glyph.mercury { color: #10b981; }
.planet-glyph.venus { color: #ec4899; }
.planet-glyph.mars { color: #ef4444; }
.planet-glyph.jupiter { color: #8b5cf6; }
.planet-glyph.saturn { color: #78716c; }
.planet-glyph.uranus { color: #06b6d4; }
.planet-glyph.neptune { color: #3b82f6; }
.planet-glyph.pluto { color: #1f2937; }
.planet-glyph.chiron { color: #a855f7; }


/* ============================================
   Aspect Pills
   ============================================ */
.aspect-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
}

.aspect-pill.conjunction {
  background: var(--color-conjunction-bg);
  color: var(--color-conjunction);
}

.aspect-pill.opposition {
  background: var(--color-challenging-bg);
  color: var(--color-challenging);
}

.aspect-pill.square {
  background: var(--color-square-bg);
  color: var(--color-square);
}

.aspect-pill.trine {
  background: var(--color-flowing-bg);
  color: var(--color-flowing);
}

.aspect-pill.sextile {
  background: var(--color-flowing-bg);
  color: var(--color-flowing);
}


/* ============================================
   Cards
   ============================================ */
.astro-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
}

.astro-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing-md);
}

.astro-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}

.astro-card-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-top: var(--spacing-xs);
}


/* ============================================
   Transit Cards (Enhanced)
   ============================================ */
.transit-card-v2 {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  transition: box-shadow 0.2s;
}

.transit-card-v2:hover {
  box-shadow: var(--shadow-md);
}

.transit-card-v2.challenging {
  border-left: 4px solid var(--color-challenging);
}

.transit-card-v2.flowing {
  border-left: 4px solid var(--color-flowing);
}

.transit-card-v2.mixed {
  border-left: 4px solid var(--color-mixed);
}

.transit-main {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
}

.transit-planets {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 1.1rem;
}

.transit-arrow {
  color: var(--color-text-muted);
}

.transit-interpretation {
  color: var(--color-text);
  line-height: 1.6;
  margin-bottom: var(--spacing-sm);
}

.transit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.transit-meta-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}


/* ============================================
   Timeline (Enhanced)
   ============================================ */
.timeline-container {
  position: relative;
  padding-left: var(--spacing-xl);
}

.timeline-line {
  position: absolute;
  left: 0.5rem;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-border);
}

.timeline-event {
  position: relative;
  margin-bottom: var(--spacing-lg);
  padding-left: var(--spacing-lg);
}

.timeline-marker {
  position: absolute;
  left: -1.5rem;
  top: 0.5rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid var(--color-bg-card);
}

.timeline-marker.challenging {
  background: var(--color-challenging);
}

.timeline-marker.flowing {
  background: var(--color-flowing);
}

.timeline-date {
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
}

.timeline-current {
  background: var(--color-mixed-bg);
  border-left: 4px solid var(--color-mixed);
  padding: var(--spacing-md);
  border-radius: var(--radius-sm);
}


/* ============================================
   Score Badges
   ============================================ */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.9rem;
}

.score-badge.positive {
  background: var(--color-positive-bg);
  color: var(--color-positive);
}

.score-badge.mixed {
  background: var(--color-mixed-bg);
  color: var(--color-mixed);
}

.score-badge.difficult {
  background: var(--color-difficult-bg);
  color: var(--color-difficult);
}


/* ============================================
   Date Picker
   ============================================ */
.date-picker-form {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm);
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.date-picker-form input[type="date"] {
  padding: var(--spacing-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
}

.date-picker-form .btn {
  padding: var(--spacing-sm) var(--spacing-md);
}


/* ============================================
   Responsive Utilities
   ============================================ */
@media (max-width: 768px) {
  .filter-bar {
    flex-direction: column;
  }

  .transit-main {
    flex-wrap: wrap;
  }

  .transit-meta {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .date-picker-form {
    flex-direction: column;
    width: 100%;
  }

  .date-picker-form input[type="date"] {
    width: 100%;
  }
}


/* ============================================
   Expandable Sections
   ============================================ */
.expandable {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
}

.expandable-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  cursor: pointer;
  background: var(--color-bg);
  border-radius: var(--radius-md);
}

.expandable-header:hover {
  background: var(--color-border);
}

.expandable-title {
  font-weight: 600;
  color: var(--color-text);
}

.expandable-icon {
  transition: transform 0.2s;
}

.expandable.open .expandable-icon {
  transform: rotate(180deg);
}

.expandable-content {
  display: none;
  padding: var(--spacing-md);
  border-top: 1px solid var(--color-border);
}

.expandable.open .expandable-content {
  display: block;
}


/* ============================================
   Life Area Tags
   ============================================ */
.life-area-tag {
  display: inline-flex;
  align-items: center;
  padding: var(--spacing-xs) var(--spacing-sm);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.life-area-tag.career { border-left: 3px solid #f59e0b; }
.life-area-tag.relationships { border-left: 3px solid #ec4899; }
.life-area-tag.health { border-left: 3px solid #10b981; }
.life-area-tag.creativity { border-left: 3px solid #8b5cf6; }
.life-area-tag.communication { border-left: 3px solid #3b82f6; }
.life-area-tag.home { border-left: 3px solid #6366f1; }
.life-area-tag.spirituality { border-left: 3px solid #a855f7; }


/* ============================================
   Base Layout
   ============================================ */
body {
  font-family: system-ui, sans-serif;
  margin: 2rem;
}

label {
  display: block;
  margin-top: 0.5rem;
}

.btn {
  padding: 0.5rem 0.9rem;
  border: 1px solid #444;
  background: #f6f6f6;
  cursor: pointer;
}

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card {
  border: 1px solid #ddd;
  border-radius: 0.5rem;
  padding: 1rem;
}

.muted {
  color: #666;
}

.error {
  color: #c62828;
}

.navbar {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.navbar .nav-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.navbar .nav-auth {
  margin-left: auto;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.navbar .nav-auth form {
  margin: 0;
}

.navbar a {
  text-decoration: none;
  color: #4a37b8;
}

.navbar a:hover {
  text-decoration: underline;
}

.nav-link-button {
  border: 0;
  background: transparent;
  color: #4a37b8;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: none;
}

.nav-link-button:hover {
  text-decoration: underline;
}

svg {
  max-width: 520px;
  height: auto;
}

.messages-list {
  margin: 1rem 0;
}

.message-alert {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 0.5rem;
}

.message-alert.success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #4caf50;
}

.message-alert.error {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef5350;
}

.message-alert.warning {
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ff9800;
}

.message-alert.info {
  background: #e3f2fd;
  color: #1565c0;
  border: 1px solid #2196f3;
}


/* ============================================
   Chat Widget
   ============================================ */
.chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  font-family: system-ui, sans-serif;
}

.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a37b8 0%, #6b5ce7 100%);
  border: none;
  color: white;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(74, 55, 184, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(74, 55, 184, 0.5);
}

.chat-toggle.active {
  background: #666;
}

.chat-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 100px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel.hidden,
.chat-status.hidden {
  display: none;
}

.chat-header {
  background: linear-gradient(135deg, #4a37b8 0%, #6b5ce7 100%);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.chat-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.chat-header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-chart-select {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  color: white;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  max-width: 150px;
}

.chat-chart-select option {
  color: #333;
  background: white;
}

.chat-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.8;
}

.chat-close:hover {
  opacity: 1;
}

.chat-status {
  padding: 8px 16px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.chat-status.error {
  background: #ffebee;
  color: #c62828;
}

.chat-status.warning {
  background: #fff3e0;
  color: #e65100;
}

.chat-status.success {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-text {
  flex: 1;
}

.start-ollama-btn {
  margin-left: auto;
  padding: 4px 12px;
  background: #4a37b8;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.start-ollama-btn:hover:not(:disabled) {
  background: #3a2a9a;
}

.start-ollama-btn:disabled {
  background: #999;
  cursor: wait;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome {
  text-align: center;
  color: #666;
  padding: 20px;
}

.chat-welcome p {
  margin: 0 0 8px 0;
}

.chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.4;
  font-size: 0.9rem;
}

.chat-message.user {
  background: linear-gradient(135deg, #4a37b8 0%, #6b5ce7 100%);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  background: #f0f0f0;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-message.assistant p {
  margin: 0 0 8px 0;
}

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

.chat-message.thinking {
  background: #f0f0f0;
  color: #666;
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: #4a37b8;
}

.chat-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #4a37b8;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-send:hover:not(:disabled) {
  background: #3a2a9a;
}

.chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .chat-panel {
    width: calc(100vw - 20px);
    right: -10px;
    height: calc(100vh - 90px);
    bottom: 65px;
    border-radius: 12px 12px 0 0;
  }

  .chat-widget {
    right: 15px;
    bottom: 15px;
  }
}
