/**
 * Year Summary Modal Styles
 * Comprehensive styling for the year deep-dive analysis modal
 */

/* Modal overlay and container */
.year-summary-modal {
  max-width: 1000px;  /* PHASE 3: Increased from 900px */
  width: 92%;         /* PHASE 3: Increased from 90% */
  max-height: 88vh;   /* PHASE 3: Reduced from 90vh to avoid cutoff */
  overflow-y: auto;
  padding: 0;         /* PHASE 3: Remove padding from modal, add to content */
}

.year-summary-content {
  display: flex;
  flex-direction: column;
  gap: 32px;          /* PHASE 3: Increased from 24px */
  padding: 28px;      /* PHASE 3: Add padding here instead of modal */
}

/* Year summary sections */
.year-summary-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 28px;      /* PHASE 3: Increased from 24px */
  margin-bottom: 8px; /* PHASE 3: Add bottom margin for extra breathing room */
}

.year-summary-section .section-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 16px 0;
}

.year-summary-section .section-subtitle svg {
  color: #3b82f6;
}

/* AI Summary Section */
.ai-summary-section {
  background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
  border-left: 4px solid #3b82f6;
}

.ai-summary-text p {
  margin: 0 0 16px 0;
  line-height: 1.7;
  color: #334155;
  font-size: 15px;
}

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

/* Year Stats Grid */
.year-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.year-stat-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  transition: all 0.2s ease;
}

.year-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.year-stat-card .stat-label {
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.year-stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 8px;
}

.year-stat-card .stat-value.dominant-category {
  font-size: 16px;
  font-weight: 600;
  color: #3b82f6;
}

.year-stat-card .stat-delta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.year-stat-card .delta-label {
  color: #64748b;
}

.year-stat-card .delta-positive {
  color: #10b981;
  font-weight: 600;
}

.year-stat-card .delta-negative {
  color: #ef4444;
  font-weight: 600;
}

.year-stat-card .delta-neutral {
  color: #94a3b8;
  font-weight: 500;
}

.year-stat-card .category-badge {
  display: inline-block;
  padding: 4px 10px;
  background: #dbeafe;
  color: #1e40af;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

/* Top Firms Table */
.top-firms-table-wrapper {
  overflow-x: auto;
}

.top-firms-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.top-firms-table thead {
  background: #f1f5f9;
}

.top-firms-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
}

.top-firms-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.15s ease;
}

.top-firms-table tbody tr:hover {
  background: #f8fafc;
}

.top-firms-table td {
  padding: 14px 16px;
  font-size: 14px;
  color: #334155;
}

.top-firms-table .rank-cell {
  font-size: 18px;
  font-weight: 700;
  width: 60px;
  text-align: center;
}

.top-firms-table .firm-name-cell {
  font-weight: 600;
  color: #1e293b;
}

.top-firms-table .amount-cell {
  font-weight: 700;
  color: #dc2626;
}

.top-firms-table .count-cell {
  color: #64748b;
}

.top-firms-table .categories-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-badge {
  display: inline-block;
  padding: 3px 8px;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.empty-text {
  color: #cbd5e1;
  font-style: italic;
  font-size: 12px;
}

/* Category Breakdown */
.category-breakdown-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;          /* PHASE 3: Increased from 24px */
  align-items: start;
  min-width: 0;       /* PHASE 3: Allow shrinking */
}

.category-chart-wrapper {
  background: white;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  max-width: 100%;    /* PHASE 3: Don't exceed container */
}

.category-chart-wrapper canvas {
  max-height: 240px;
}

.category-table-wrapper {
  overflow-x: auto;
}

.category-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
}

.category-table thead {
  background: #f1f5f9;
}

.category-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
}

.category-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
}

.category-table td {
  padding: 12px;
  font-size: 13px;
  color: #334155;
}

.category-name-cell {
  font-weight: 600;
}

.category-amount-cell {
  font-weight: 600;
  color: #dc2626;
}

.percentage-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.percentage-bar {
  height: 6px;
  background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
  border-radius: 3px;
  min-width: 2px;
}

.percentage-text {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  min-width: 45px;
}

/* Monthly Timeline */
.monthly-timeline-container {
  background: white;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  height: 300px;
}

.monthly-timeline-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Dual Section Layout */
.year-summary-dual-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;          /* PHASE 3: Increased from 24px */
  align-items: start; /* PHASE 3: Prevent stretching */
}

/* PHASE 3: Ensure sections don't overflow */
.year-summary-dual-section > .year-summary-section {
  min-width: 0;  /* Allow flex items to shrink below content size */
  overflow: hidden;
}

/* Empty States */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: #94a3b8;
  font-style: italic;
}

/* Loading Spinner */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.loading-spinner .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner p {
  color: #64748b;
  font-size: 14px;
}

/* Error Message */
.error-message {
  padding: 40px 20px;
  text-align: center;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  margin: 20px;
}

/* Responsive Breakpoints */
/* PHASE 3: Tablet breakpoint */
@media (max-width: 1024px) {
  /* On tablets, stack dual sections vertically */
  .year-summary-dual-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .year-summary-modal {
    width: 95%;
    max-height: 92vh;    /* PHASE 3: Adjusted from 95vh */
  }

  .year-summary-content {
    padding: 20px;       /* PHASE 3: Reduced padding on mobile */
    gap: 24px;           /* PHASE 3: Reduced gap on mobile */
  }

  .year-stats-grid {
    grid-template-columns: 1fr;
  }

  .category-breakdown-container {
    grid-template-columns: 1fr;
  }

  .category-chart-wrapper {
    max-width: 320px;    /* PHASE 3: Increased from 300px */
    margin: 0 auto;
  }

  .year-summary-dual-section {
    grid-template-columns: 1fr;
    gap: 20px;           /* PHASE 3: Reduced gap on mobile */
  }

  .year-summary-section {
    padding: 20px;       /* PHASE 3: Increased from 16px */
  }

  .top-firms-table {
    font-size: 12px;
  }

  .top-firms-table td,
  .top-firms-table th {
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  .year-stat-card .stat-value {
    font-size: 22px;
  }

  .year-summary-section .section-subtitle {
    font-size: 16px;
  }

  .ai-summary-text p {
    font-size: 14px;
  }

  .monthly-timeline-container {
    height: 250px;
  }
}
