/* AI Summary Panel Styles */

/* Panel */
.summary-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 420px;
  height: 100vh;
  background: white;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1002;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Colored indicator on right edge */
.summary-panel::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(135deg, #800020 0%, #5a0018 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.summary-panel.open::after {
  opacity: 1;
}

.summary-panel.open {
  right: 40px;
}

/* Header */
.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #800020 0%, #5a0018 100%);
  color: white;
}

.summary-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
}

.summary-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.summary-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Tab navigation */
.summary-tab-nav {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  background: white;
  flex-shrink: 0;
}

.summary-tab-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  background: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  outline: none;
}

.summary-tab-btn:hover {
  color: #800020;
}

.summary-tab-btn.active {
  background: linear-gradient(135deg, #800020 0%, #5a0018 100%);
  color: white;
}

.summary-tab-btn:focus {
  outline: none;
}

/* Content area */
.summary-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Heading */
.summary-heading {
  font-size: 1.75rem;
  font-weight: 700;
  color: #800020;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
  min-height: 2.5rem;
}

/* Body */
.summary-body {
  flex: 1;
  font-size: 15px;
  line-height: 1.8;
  color: #374151;
}

.summary-body p {
  margin: 0 0 1rem 0;
  text-align: justify;
}

.summary-body p:last-child {
  margin-bottom: 0;
}

.summary-body strong {
  color: #800020;
  font-weight: 600;
}

.summary-body br {
  display: block;
  content: "";
  margin-top: 0.25rem;
}

/* Markdown headers */
.summary-h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #800020;
  margin: 1.5rem 0 0.75rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #800020;
  line-height: 1.3;
}

.summary-h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #800020;
  margin: 1.25rem 0 0.5rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid #800020;
  line-height: 1.4;
}

.summary-h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #4b0014;
  margin: 1rem 0 0.4rem 0;
  font-style: italic;
  line-height: 1.4;
}

/* Section headings (book summaries) - legacy support */
.summary-section-heading {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #800020;
  margin: 1.25rem 0 0.4rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid #e5e7eb;
}

/* Loading dots */
.summary-loading {
  display: flex;
  gap: 6px;
  padding: 8px 0;
}

.summary-loading span {
  width: 8px;
  height: 8px;
  background: #800020;
  border-radius: 50%;
  animation: summary-bounce 1.2s infinite ease-in-out;
  opacity: 0.6;
}

.summary-loading span:nth-child(2) { animation-delay: 0.2s; }
.summary-loading span:nth-child(3) { animation-delay: 0.4s; }

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

/* Error */
.summary-error {
  color: #dc2626;
  font-size: 14px;
  padding: 8px 0;
}

/* Dark mode loading dots - use text color instead of red */
[data-theme="dark"] .summary-loading span {
  background: #9ca3af;
}

/* Footer / metrics */
.summary-footer {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  border-top: 1px solid #e5e7eb;
  background: white;
  flex-shrink: 0;
}

.summary-metrics {
  font-size: 12px;
  color: #9ca3af;
}

.summary-cache-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}

.summary-cache-badge.cached {
  background: #10b981;
  color: white;
}

.summary-cache-badge.fresh {
  background: #f59e0b;
  color: white;
}

/* Summary Tab styles moved to tabs.css */

/* Dark mode */
[data-theme="dark"] .summary-panel {
  background: #16213e;
  color: #f0f0f0;
}

[data-theme="dark"] .summary-tab-nav {
  background: #16213e;
  border-bottom-color: #2d3748;
}

[data-theme="dark"] .summary-tab-btn {
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .summary-tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.3);
}

[data-theme="dark"] .summary-tab-btn.active {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  color: white;
  border-color: #dc2626;
}

[data-theme="dark"] .summary-heading {
  color: #f87171;
  border-bottom-color: #2d3748;
}

[data-theme="dark"] .summary-h2 {
  color: #f87171;
  border-bottom-color: #f87171;
}

[data-theme="dark"] .summary-h3 {
  color: #f87171;
  border-left-color: #f87171;
}

[data-theme="dark"] .summary-h4 {
  color: #fca5a5;
}

[data-theme="dark"] .summary-section-heading {
  color: #f87171;
  border-top-color: #2d3748;
}

[data-theme="dark"] .summary-body {
  color: #d1d5db;
}

[data-theme="dark"] .summary-body strong {
  color: #f87171;
}

[data-theme="dark"] .summary-footer {
  background: #16213e;
  border-top-color: #2d3748;
}

[data-theme="dark"] .summary-metrics {
  color: #6b7280;
}

/* Mobile Responsive - Tablets */
@media (max-width: 768px) {
  .summary-panel {
    width: 100%;
    right: -100%;
  }

  .summary-panel.open {
    right: 0;
  }

  .summary-tab {
    padding: 16px 10px;
    font-size: 13px;
  }
}

/* Mobile Responsive - Phones */
@media (max-width: 480px) {
  .summary-panel {
    width: 100%;
    height: 100%;
    height: 100dvh;
    right: -100%;
  }

  .summary-panel.open {
    right: 0;
  }

  .summary-header {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    min-height: 56px;
  }

  .summary-title {
    font-size: 16px;
  }
}
