/* ============================================
   MODAL STYLES
   Chapter transition and general modals
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 1100px;
  max-height: 80vh;
  height: 80vh;
  width: 90%;
  animation: modalSlideIn 0.3s ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  padding: 24px 24px 16px 24px;
  border-bottom: 2px solid #e5e7eb;
  text-align: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 28px;
  color: #1f2937;
  font-weight: 700;
}

.modal-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  min-height: 0;
}

.modal-message {
  font-size: 18px;
  color: #374151;
  margin: 0 0 12px 0;
  text-align: center;
  line-height: 1.6;
}

.modal-subtitle {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
  text-align: center;
  padding: 4px 0;
}

.modal-stats {
  background: #f9fafb;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-stats .stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
}

.modal-stats .stat-item:last-child {
  border-bottom: none;
}

.modal-stats .stat-label {
  font-size: 14px;
  color: #6b7280;
  font-weight: 600;
}

.modal-stats .stat-value {
  font-size: 16px;
  color: #1f2937;
  font-weight: 700;
}

.modal-footer {
  padding: 16px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-actions {
  padding: 16px 24px 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.modal-button {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
}

.modal-button-primary {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.modal-button-primary:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.modal-button-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 2px solid #d1d5db;
}

.modal-button-secondary:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
  transform: translateY(-1px);
}

.modal-btn {
  padding: 14px 24px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.modal-btn-primary {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.modal-btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.modal-btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 2px solid #d1d5db;
}

.modal-btn-secondary:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

/* Chapter badge in header */
.chapter-badge {
  display: inline-block;
  background: #f59e0b;
  color: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

/* Chapter intro page styles */
.chapter-intro {
  max-width: 600px;
  margin: 60px auto;
  padding: 40px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.chapter-intro h2 {
  color: #1f2937;
  margin: 0 0 16px 0;
  font-size: 24px;
}

.chapter-intro p {
  color: #6b7280;
  font-size: 16px;
  line-height: 1.6;
  margin: 0 0 12px 0;
}

.chapter-intro a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

.chapter-intro a:hover {
  text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .modal-content {
    width: 95%;
  }

  .modal-header h2 {
    font-size: 24px;
  }

  .modal-message {
    font-size: 16px;
  }

  .modal-btn {
    padding: 12px 20px;
    font-size: 14px;
  }
  
  .modal-actions {
    flex-direction: column-reverse;
  }
  
  .modal-button {
    width: 100%;
    min-width: auto;
  }
}

/* Throughput Modal Specific Styles */
.throughput-chart-area {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.throughput-chart-area h3 {
  margin: 0 0 8px 0;
  font-size: 14px;
  flex-shrink: 0;
}

.throughput-chart-area canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.chart-insight {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  background: white;
  border-radius: 8px;
  border-left: 4px solid #3b82f6;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  max-width: 600px;
  width: 100%;
}

.chart-insight.pattern-stable {
  border-left-color: #10b981;
  background: #f0fdf4;
}

.chart-insight.pattern-volatile {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.chart-insight.pattern-growing {
  border-left-color: #06b6d4;
  background: #ecfeff;
}

.chart-insight.pattern-falling {
  border-left-color: #ef4444;
  background: #fef2f2;
}

.chart-insight.pattern-empty {
  border-left-color: #6b7280;
  background: #f9fafb;
}

.insight-icon {
  font-size: 24px;
  line-height: 1;
}

.insight-message {
  flex: 1;
  font-size: 14px;
  color: #374151;
  line-height: 1.5;
  font-weight: 500;
}

.chart-lower {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chart-projection {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

.chart-projection h3 {
  margin: 0 0 8px 0;
  font-size: 12px;
  flex-shrink: 0;
}

.chart-projection canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  flex: 1;
}

.chart-extra {
  padding: 12px;
  background: #ffffff;
  border: 2px dashed #e5e7eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
  box-sizing: border-box;
}

.chart-extra:empty::before {
  content: "Área reservada para métricas futuras";
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  font-style: italic;
  align-self: center;
  margin: auto;
}

.chart-extra .chart-insight {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  padding: 12px;
  box-sizing: border-box;
  border: none;
  box-shadow: none;
  margin: 0;
}

.chart-extra .chart-insight .insight-icon {
  font-size: 32px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.chart-extra .chart-insight .insight-message {
  font-size: 13px;
  text-align: center;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

.throughput-extra-area {
  min-height: 100px;
  padding: 16px;
  background: #ffffff;
  border: 2px dashed #e5e7eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 14px;
  font-style: italic;
}

.throughput-extra-area:empty::before {
  content: "Área reservada para conteúdo futuro";
}

.throughput-list {
  max-height: 400px;
  overflow-y: auto;
  background: #f9fafb;
  border-radius: 8px;
  padding: 12px;
}

.throughput-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 4px;
  background: white;
  border-radius: 6px;
  border-left: 3px solid #e5e7eb;
  transition: all 0.2s ease;
}

.throughput-item:hover {
  border-left-color: #3b82f6;
  transform: translateX(2px);
}

.throughput-item.has-cards {
  border-left-color: #10b981;
}

.throughput-day {
  font-size: 14px;
  color: #374151;
  font-weight: 600;
}

.throughput-count {
  font-size: 14px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 600;
}

.throughput-item.has-cards .throughput-count {
  background: #d1fae5;
  color: #065f46;
}
