/* AI Summary Panel Styles */

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

.summary-panel.open {
  right: 40px;
  border-right-color: #6b3a1f;
}

/* Header */
.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #6b3a1f;
  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 #e4d0b8;
  background: #f5ede0;
  flex-shrink: 0;
}

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

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

.summary-tab-btn.active {
  background: #fdf6ed;
  color: #8b1a2e;
  font-weight: 600;
  margin-bottom: -2px;
  border-bottom: 2px solid #fdf6ed;
}

.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: #8b1a2e;
  padding-bottom: 8px;
  border-bottom: 1px solid #e4d0b8;
  min-height: 2.5rem;
}

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

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

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

.summary-body strong {
  color: #8b1a2e;
  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: #8b1a2e;
  margin: 1.5rem 0 0.75rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #8b1a2e;
  line-height: 1.3;
}

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

.summary-h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #6b3a1f;
  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: #8b1a2e;
  margin: 1.25rem 0 0.4rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid #e4d0b8;
}

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

.summary-loading span {
  width: 8px;
  height: 8px;
  background: #8b1a2e;
  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;
}

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

.summary-metrics {
  font-size: 12px;
  color: #8a6a4a;
}

.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: var(--bg-primary, #1c0f07);
  color: var(--text-primary, #f5e6d0);
}

[data-theme="dark"] .summary-header {
  background: #4d2a14;
}

[data-theme="dark"] .summary-tab-nav {
  background: #200d05;
  border-bottom-color: #3d2010;
}

[data-theme="dark"] .summary-tab-btn {
  background: none;
  color: #d4b896;
}

[data-theme="dark"] .summary-tab-btn:hover {
  color: #d4915a;
}

[data-theme="dark"] .summary-tab-btn.active {
  background: var(--bg-primary, #1c0f07);
  color: var(--text-primary, #f5e6d0);
  font-weight: 600;
  margin-bottom: -2px;
  border-bottom: 2px solid var(--bg-primary, #1c0f07);
}

[data-theme="dark"] .summary-heading {
  color: #d4915a;
  border-bottom-color: #3d2010;
}

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

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

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

[data-theme="dark"] .summary-section-heading {
  color: #d4915a;
  border-top-color: #3d2010;
}

[data-theme="dark"] .summary-body {
  color: var(--text-primary, #f5e6d0);
}

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

[data-theme="dark"] .summary-loading span {
  background: #d4915a;
}

[data-theme="dark"] .summary-footer {
  background: var(--bg-primary, #1c0f07);
  border-top-color: #3d2010;
}

[data-theme="dark"] .summary-metrics {
  color: var(--text-muted, #a08060);
}

/* 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;
  }
}
