/* --- Global Panchang Styles --- */
.panchang-page {
  padding: 20px 0;
}

/* Header and Date Controls */
.panchang-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.panchang-header .title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.panchang-date-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panchang-date-controls .date-input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #ccc;
  border-radius: 8px;
  overflow: hidden;
}

.panchang-date-controls input[type="date"] {
  border: none;
  padding: 8px 10px;
  font-size: 1rem;
  line-height: 1.5;
  cursor: pointer;
  background: transparent;
}

.panchang-date-controls .spinner-btn {
  background: #f7f7f7;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.2s;
}

.panchang-date-controls .spinner-btn:hover {
  background: #eee;
}

/* Metadata Display */
.panchang-metadata {
  display: flex;
  justify-content: flex-start;
  gap: 20px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.panchang-metadata strong {
  font-weight: 600;
  color: var(--brand-text-primary, #111827);
}

.separator {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin: 20px 0;
}

.section-heading {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 30px 0 15px 0;
  color: #3b82f6;
  /* Use primary brand color for section headings */
}


/* --- Main Summary Grid (The 5 Elements + Sun) --- */
.panchang-summary-grid {
  display: grid;
  /* 3 columns on large screens, responsive fallbacks */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.panchang-card {
  position: relative;
  padding: 20px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  transition: box-shadow 0.3s;
}

.panchang-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* --- Primary Card Hover Animation --- */
/* A slightly elevated, subtle glow and lift on hover/focus for the primary panchang card */
.panchang-primary-card {
  position: relative;
  padding: 22px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  transition: transform 300ms cubic-bezier(.2,.9,.2,1),
              box-shadow 300ms ease, filter 300ms ease;
  will-change: transform, box-shadow;
  overflow: hidden;
}

.panchang-primary-card::after {
  /* Decorative glow layer that animates on hover */
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: 0 10px 30px rgba(59,130,246,0);
  transition: box-shadow 300ms ease, opacity 300ms ease;
}

.panchang-primary-card:hover,
.panchang-primary-card:focus-within {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 20px 40px rgba(16, 24, 40, 0.12);
}

.panchang-primary-card:hover::after,
.panchang-primary-card:focus-within::after {
  box-shadow: 0 30px 60px rgba(59,130,246,0.08);
}

.panchang-primary-card .planet-name {
  transition: transform 300ms cubic-bezier(.2,.9,.2,1), text-shadow 300ms ease, color 200ms ease;
}

.panchang-primary-card:hover .planet-name,
.panchang-primary-card:focus-within .planet-name {
  transform: translateY(-4px);
  text-shadow: 0 6px 20px rgba(59,130,246,0.14);
}

/* Keyboard focus accessibility */
.panchang-primary-card:focus-within {
  outline: 2px solid rgba(16,185,129,0.08);
  outline-offset: 2px;
}
.panchang-card h3 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1rem;
  font-weight: 500;
  color: #6b7280;
  text-transform: uppercase;
}

.panchang-card .main-display {
  margin-bottom: 10px;
}

.planet-name {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--brand-primary, #3b82f6);
  display: inline-block;
}

.sub-display {
  font-size: 0.9rem;
  color: #6b7280;
}

/* Nakshatra card meta (ruler and animal) */
.nakshatra-card .nakshatra-meta {
  margin-top: 8px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.nakshatra-card .nakshatra-meta .muted-text {
  font-size: 0.9rem;
  color: var(--brand-text-muted, #6b7280);
}

.nakshatra-card .ruling-planet strong,
.nakshatra-card .animal-symbol strong {
  color: var(--brand-text-primary, #111827);
  font-weight: 600;
}

.nakshatra-card .animal-symbol {
  font-style: italic;
}

/* Veto-day highlighting: soft red background when a nakshatra's veto day
   matches the current weekday (vara). Applied by JS adding `.veto-day`. */
.nakshatra-card.veto-day {
  background: #fff5f5; /* very light coral */
  border-color: #fed7d7; /* light coral border */
  box-shadow: 0 6px 18px rgba(248, 113, 113, 0.06);
}
.nakshatra-card.veto-day .planet-name {
  color: #b91c1c; /* slightly stronger red for the name */
}

/* Vara Card Specifics */
.vara-card hr {
  border: none;
  border-top: 1px solid #eee;
  margin: 10px 0;
}

/* MODIFIED: Changed sun-times-display to a grid */
.sun-times-display {
  display: grid;
  grid-template-columns: 1fr;
  /* Two columns for pairs */
  gap: 5px 5px;
  font-size: 0.95rem;
  font-weight: 500;
  color: #4b5563;
}

.sun-time-item {
  display: flex;
  justify-content: space-between;
}

.sun-time-item span {
  font-weight: 450;
  color: var(--brand-text-primary, #4a26ad);
}

.sun-time-item.next-day-time {
  grid-column: 1 / -1;
  /* Make the next sunrise span the whole row */
  padding-top: 5px;
  border-top: 1px dashed #eee;
  font-size: 0.9rem;
}


/* Info icon/tooltip styling */
.info-icon {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: #9ca3af;
  transition: color 0.2s;
}

.info-icon:hover {
  color: var(--brand-primary, #3b82f6);
}

.tooltip-content {
  display: none;
  position: absolute;
  top: 50px;
  /* Offset from top */
  right: 0;
  width: 300px;
  padding: 15px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.1);
  color: #4a4d6a;
  z-index: 30;
  font-size: 0.9rem;
  line-height: 1.5;
}

.tooltip-content.visible {
  display: block;
}

/* Show tooltip when hovering the nakshatra card or the info icon */
.panchang-card:hover .tooltip-content,
.panchang-card .info-icon:hover + .tooltip-content {
  display: block;
}

/* Tooltip inner layout for nakshatra details */
.tooltip-content .nakshatra-title {
  font-weight: 700;
  margin-bottom: 8px;
}
.tooltip-content .nakshatra-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.tooltip-content .nakshatra-row .label {
  color: var(--brand-text-muted, #6b7280);
  font-size: 0.85rem;
}
.tooltip-content .nakshatra-row .value {
  color: var(--brand-text-primary, #111827);
  font-weight: 600;
}
.tooltip-content .nakshatra-desc {
  margin-top: 8px;
  font-size: 0.9rem;
  color: #374151;
}

/* --- Details Grid (Muhurta and Tithi Timeline) --- */
.panchang-details-grid {
  display: grid;
  /* Muhurta (left) takes 2/3 space, Tithi Timeline (right) takes 1/3 */
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
}

/* --- Secondary Timelines Grid (Nakshatra, Yoga, Karana) --- */
.panchang-secondary-timelines {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  /* 3 columns for 3 cycles */
  gap: 20px;
  margin-bottom: 30px;
}


@media (max-width: 900px) {
  .panchang-details-grid {
    grid-template-columns: 1fr;
    /* Stack on smaller screens */
  }
}

.details-card {
  padding: 20px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}

.details-card .card-title {
  margin-top: 0;
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 15px;
}

/* --- Transitions Timeline Styling --- */
.transitions-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
  max-height: 300px;
  /* Constrain height for timeline cards */
  overflow-y: auto;
  /* Allow scrolling */
  padding-right: 10px;
  /* Space for scrollbar */
}

.transition-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  gap: 6px; /* fixed horizontal gap between left and right sections */
  border-radius: 6px;
  border: 1px solid #f3f4f6;
  background: #fafafa;
  position: relative;
  font-size: 0.9rem;
}

.transition-item.current {
  background: #eff6ff;
  /* Light blue background for current segment */
  border-color: #93c5fd;
  font-weight: 600;
}

.transition-left {
  display: flex;
  align-items: center;
  gap: 6px; /* tighten spacing between id and name */
}

.transition-id {
  font-weight: 700;
  color: #4b5563;
  width: 20px;
  text-align: center;
}

.transition-name {
  flex-grow: 1;
}

/* Stacked two-row layout for Nakshatra and Yoga timelines only */
.nakshatra-transitions-card .transition-item,
.yoga-transitions-card .transition-item {
  display: grid;
  grid-template-columns: 32px 1fr; /* smaller id column to reduce gap */
  grid-template-rows: auto auto;
  gap: 4px 6px; /* row-gap, column-gap: keep a fixed 6px between left and right */
  align-items: center;
}

.nakshatra-transitions-card .transition-left .transition-id,
.yoga-transitions-card .transition-left .transition-id {
  grid-row: 1 / span 2;
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto; /* let grid column size control width */
}

.nakshatra-transitions-card .transition-right,
.yoga-transitions-card .transition-right {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.nakshatra-transitions-card .transition-right .transition-name,
.yoga-transitions-card .transition-right .transition-name {
  grid-row: 1;
  font-weight: 600;
}

.nakshatra-transitions-card .transition-right .transition-time,
.yoga-transitions-card .transition-right .transition-time {
  grid-row: 2;
  color: var(--brand-text-muted);
  font-size: 0.95em;
}

.day-offset {
  font-size: 0.7em;
  vertical-align: super;
  margin-left: 2px;
}

.transition-time {
  color: #4b5563;
  font-weight: 500;
  white-space: nowrap;
}

.current-badge {
  background: #3b82f6;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-left: 10px;
}

/* --- Muhurta Table Styling (Enhanced) --- */
.muhurta-table-wrap {
  overflow-x: auto;
}

.muhurta-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}

.muhurta-table th,
.muhurta-table td {
  padding: 12px 15px;
  border: 1px solid #eee;
  text-align: left;
}

.muhurta-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #4b5563;
  text-transform: uppercase;
  font-size: 0.9rem;
}

.muhurta-table tr.red td {
  background: #fef2f2;
  border-left: 4px solid #ef4444;
  color: #991b1b;
  font-weight: 500;
}

.muhurta-table tr.green td {
  background: #f0fdf4;
  border-left: 4px solid #10b981;
  color: #047857;
  font-weight: 600;
}

.muhurta-table td:nth-child(2),
.muhurta-table td:nth-child(3) {
  font-weight: 700;
}

/* Advice/Takeaway Styling */
.advice {
  font-weight: 500;
  color: #b91c1c;
  margin-bottom: 15px;
}

.cosmic-takeaway-card {
  background: #f0f9ff;
  /* Light, inviting background */
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  font-size: 1.1rem;
  line-height: 1.6;
}

.cosmic-takeaway-card h4 {
  margin-top: 0;
  color: #1d4ed8;
  font-size: 1.3rem;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .panchang-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .panchang-date-controls {
    width: 100%;
    margin-top: 10px;
  }

  .panchang-date-controls input[type="date"] {
    flex-grow: 1;
  }

  .panchang-metadata {
    flex-direction: column;
    gap: 5px;
  }

  .panchang-summary-grid,
  .panchang-details-grid,
  .panchang-secondary-timelines {
    grid-template-columns: 1fr;
  }

  /* On narrow screens allow slightly more vertical spacing for readability */
  .transition-item {
    gap: 10px;
  }

  .muhurta-table {
    min-width: 0;
  }
}