/* 
 * MyPost2 Analytics CSS - Complete Styles
 * Beautiful analytics dashboard with modern data visualization
 */
/* ==== CSS VARIABLES (ROOT) ==== */
:root {
  /* Colors */
  --mp2-primary: #0073aa;
  --mp2-primary-dark: #005a87;
  --mp2-secondary: #666;
  --mp2-success: #46b450;
  --mp2-warning: #ffb900;
  --mp2-danger: #dc3232;
  --mp2-gray-50: #f9fafb;
  --mp2-gray-100: #f3f4f6;
  --mp2-gray-200: #e5e7eb;
  --mp2-gray-300: #d1d5db;
  --mp2-gray-400: #9ca3af;
  --mp2-gray-500: #6b7280;
  --mp2-gray-600: #4b5563;
  --mp2-gray-700: #374151;
  --mp2-gray-800: #1f2937;
  --mp2-gray-900: #111827;
  
  /* Cards Colors */  
  --mp2-pastel-pink: #FFD1DC;
  --mp2-pastel-mint: #B5EAD7;
  --mp2-pastel-blue: #A2D2FF;
  --mp2-pastel-salmon: #FFCBC1;
  --mp2-pastel-lime: #E2F0CB;
  --mp2-pastel-lavender: #D8BFD8;
  
  /* Spacing */
  --mp2-space-xs: 0.25rem;
  --mp2-space-sm: 0.5rem;
  --mp2-space-md: 1rem;
  --mp2-space-lg: 1.5rem;
  --mp2-space-xl: 1rem;
  --mp2-space-2xl: 3rem;
  
  /* Typography */
  --mp2-font-size-xs: 0.75rem;
  --mp2-font-size-sm: 0.875rem;
  --mp2-font-size-base: 1rem;
  --mp2-font-size-lg: 1.125rem;
  --mp2-font-size-xl: 1.25rem;
  --mp2-font-size-2xl: 1.5rem;
  --mp2-font-size-3xl: 1.875rem;
  
  /* Borders */
  --mp2-radius-sm: 0.25rem;
  --mp2-radius-md: 0.375rem;
  --mp2-radius-lg: 0.5rem;
  --mp2-radius-xl: 0.75rem;
  
  /* Shadows */
  --mp2-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --mp2-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --mp2-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}


/* Active preset button styling */
.mp2-date-preset.mp2-active-preset {
    border: 2px solid #dc3232 !important;
    background-color: #fff !important;
    color: #dc3232 !important;
    font-weight: bold !important;
}

.mp2-date-preset {
    transition: all 0.2s ease;
}

.mp2-date-preset:hover:not(.mp2-active-preset) {
    background-color: #f0f0f0;
}

/* ==== ANALYTICS LAYOUT ==== */
.mp2-analytics-header {
  margin-bottom: var(--mp2-space-xl);
}

.mp2-analytics-header h1 {
  font-size: var(--mp2-font-size-3xl);
  font-weight: 700;
  color: var(--mp2-gray-800);
  margin: 0 0 var(--mp2-space-sm) 0;
}

/* ==== DATE FILTER ==== */
.mp2-date-filter {
  background: #7cadf7;
  padding: var(--mp2-space-lg);
  margin: var(--mp2-space-xl) 0;
  border: 1px solid var(--mp2-gray-200);
  border-radius: var(--mp2-radius-lg);
  box-shadow: var(--mp2-shadow-sm);
}

.mp2-date-filter h2 {
  margin: 0 0 var(--mp2-space-lg) 0;
  color: var(--mp2-gray-800);
  font-size: var(--mp2-font-size-xl);
  font-weight: 600;
}

.mp2-date-filter-form {
  display: flex;
  align-items: center;
  gap: var(--mp2-space-md);
  flex-wrap: wrap;
}

.mp2-date-filter-form label {
  font-weight: 600;
  color: var(--mp2-gray-700);
  margin-right: var(--mp2-space-sm);
}

.mp2-input, .mp2-select {
  padding: var(--mp2-space-sm) var(--mp2-space-md);
  border: 1px solid var(--mp2-gray-300);
  border-radius: var(--mp2-radius-md);
  font-size: var(--mp2-font-size-sm);
}

.mp2-date-presets {
  margin-left: var(--mp2-space-lg);
  display: flex;
  align-items: center;
  gap: var(--mp2-space-sm);
}

/* ==== OVERVIEW STATS ==== */
.mp2-overview-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: var(--mp2-space-xl) 0;
}

.mp2-stat-card {
  /* Use a variable for background, with a fallback to white */
  background: var(--card-bg, white);
  padding: var(--mp2-space-lg);
  border: 1px solid var(--mp2-gray-200);
  border-left: 10px solid #b1b4b5;
  border-radius: var(--mp2-radius-lg);
  box-shadow: var(--mp2-shadow-sm);
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mp2-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--mp2-shadow-md);
}

.mp2-stat-card h3 {
  font-size: var(--mp2-font-size-3xl);
  font-weight: 700;
  color: var(--mp2-primary);
  margin: 0 0 var(--mp2-space-sm) 0;
}

.mp2-stat-card p {
  font-size: var(--mp2-font-size-base);
  font-weight: 600;
  color: var(--mp2-gray-700);
  margin: 0 0 var(--mp2-space-xs) 0;
}

.mp2-stat-card small {
  font-size: var(--mp2-font-size-xs);
  color: var(--mp2-gray-500);
}

/* ==== BADGES ==== */
.mp2-badge {
  display: inline-block;
  padding: var(--mp2-space-xs) var(--mp2-space-sm);
  font-size: var(--mp2-font-size-xs);
  font-weight: 500;
  border-radius: var(--mp2-radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mp2-badge-primary {
  background: var(--mp2-primary);
  color: white;
}

.mp2-badge-secondary {
  background: var(--mp2-gray-500);
  color: white;
}

.mp2-badge-gray {
  background: var(--mp2-gray-200);
  color: var(--mp2-gray-700);
}

/* ==== BUTTONS ==== */
.mp2-btn-accent {
  background: var(--mp2-warning);
  color: white;
  border: none;
  padding: var(--mp2-space-sm) var(--mp2-space-md);
  border-radius: var(--mp2-radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.mp2-btn-accent:hover {
  background: #e6a200;
}

.mp2-btn-danger {
  background: var(--mp2-danger);
  color: white;
  border: none;
  padding: var(--mp2-space-sm) var(--mp2-space-md);
  border-radius: var(--mp2-radius-md);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.mp2-btn-danger:hover {
  background: #c62d2d;
}

/* ==== TABLES ==== */
.mp2-table {
  width: 100%;
  background: white;
  border: 1px solid var(--mp2-gray-200);
  border-radius: var(--mp2-radius-lg);
  overflow: hidden;
  box-shadow: var(--mp2-shadow-sm);
  border-collapse: collapse; /* Crucial for consistent borders */
}

.mp2-table th {
  background: #e5e7eb;
  padding: var(--mp2-space-md);
  text-align: center;
  font-weight: 600;
  color: var(--mp2-gray-700);
  border-bottom: 1px solid var(--mp2-gray-200);
}

.mp2-table td {
  padding: var(--mp2-space-md);
  border-right: 1px solid #e5e7eb; /* Fixed syntax */
  vertical-align: middle;
}

.mp2-table tr:last-child td {
  border-bottom: none;
}

.mp2-table tr:hover td {
  background: var(--mp2-gray-50); /* Changed to affect cells */
}

/* Table Column Specific Styles */
.mp2-col-rank {
  width: 80px;
  text-align: center;
}

.mp2-col-title {
  min-width: 200px;
}

.mp2-col-original {
  width: 120px;
}

.mp2-col-performance {
  width: 120px;
}

.mp2-col-visitors {
  width: 100px;
  text-align: center;
}

.mp2-col-events {
  width: 100px;
  text-align: center;
}

.mp2-col-type {
  width: 100px;
  text-align: center;
}

.mp2-col-actions {
  width: 120px;
  text-align: center;
}

/* ==== RANKING TABLE ==== */
.mp2-ranking-table {
  margin: var(--mp2-space-xl) 0;
}

.mp2-rank-display {
  display: flex;
  align-items: center;
  gap: var(--mp2-space-sm);
}

.mp2-rank-number {
  background: var(--mp2-gray-100);
  color: var(--mp2-gray-700);
  padding: var(--mp2-space-xs) var(--mp2-space-sm);
  border-radius: var(--mp2-radius-sm);
  font-weight: 600;
  font-size: var(--mp2-font-size-sm);
}

.mp2-trophy {
  font-size: var(--mp2-font-size-lg);
}

.mp2-repost-info {
  display: flex;
  flex-direction: column;
  gap: var(--mp2-space-xs);
}

.mp2-repost-url {
  font-size: var(--mp2-font-size-xs);
  color: var(--mp2-gray-500);
  text-decoration: none;
}

.mp2-repost-url:hover {
  color: var(--mp2-primary);
}

/* ==== PERFORMANCE SECTION ==== */
.mp2-performance-overview {
  margin: var(--mp2-space-xl) 0;
  border-radius: var(--mp2-radius-lg);
  box-shadow: var(--mp2-shadow-sm);
  overflow: hidden;
}

.mp2-performance-overview h2 {
  margin: 0;
  padding: var(--mp2-space-xl);
  background: #7cadf7; /* Beige/orange background */
  color: var(--mp2-gray-800);
  font-size: var(--mp2-font-size-2xl);
  font-weight: 700;
  border-bottom: 1px solid var(--mp2-gray-200);
}

.mp2-performance-content {
  background: white;
  padding: var(--mp2-space-xl);
  border: 1px solid var(--mp2-gray-200);
  border-top: none;
}

.mp2-performance-ranking {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--mp2-space-xl);
  margin-top: var(--mp2-space-xl);
}

.mp2-performance-score {
  text-align: center;
  font-size: var(--mp2-font-size-2xl);
  font-weight: 700;
  color: var(--mp2-success);
}

.mp2-performance-fill {
  height: 100%;
  background: linear-gradient(90deg, #0758eb, #f710e6);
  transition: width 0.3s ease;
}

/* ==== CHART SECTION ==== */
.mp2-chart-section {
  margin: var(--mp2-space-xl) 0;
  border-radius: var(--mp2-radius-lg);
  box-shadow: var(--mp2-shadow-sm);
  overflow: hidden;
}

.mp2-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--mp2-space-lg);
  flex-wrap: wrap;
  gap: var(--mp2-space-md);
}

.mp2-chart-title {
  font-size: var(--mp2-font-size-xl);
  font-weight: 600;
  color: var(--mp2-gray-800);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--mp2-space-sm);
}

.mp2-chart-controls {
  display: flex;
  align-items: center;
  gap: var(--mp2-space-md);
}

.mp2-chart-controls label {
  margin-right: var(--mp2-space-sm);
  font-weight: 600;
  color: var(--mp2-gray-700);
}

.mp2-chart-container {
  background: white;
  padding: var(--mp2-space-xl);
  border: 1px solid var(--mp2-gray-200);
  border-top: none;
  border-radius: 0;
  position: relative;
  height: 400px;
}

.mp2-chart-canvas {
  max-height: 350px;
}

/* ==== TRAFFIC SOURCES ==== */
.mp2-traffic-sources {
  background: #bbd4fa;
  padding: var(--mp2-space-xl);
  margin: var(--mp2-space-xl) 0;
  border: 1px solid var(--mp2-gray-200);
  border-radius: var(--mp2-radius-lg);
  box-shadow: var(--mp2-shadow-sm);
}

.mp2-traffic-sources h2 {
  margin: 0 0 var(--mp2-space-xl) 0;
  color: var(--mp2-gray-800);
  font-size: var(--mp2-font-size-2xl);
  font-weight: 700;
}

.mp2-traffic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--mp2-space-lg);
  margin-top: var(--mp2-space-xl);
}

.mp2-traffic-card {
  background: var(--mp2-gray-50);
  padding: var(--mp2-space-lg);
  border-radius: var(--mp2-radius-md);
  border: 1px solid var(--mp2-gray-200);
}

.mp2-traffic-card h3 {
  margin: 0 0 var(--mp2-space-md) 0;
  color: var(--mp2-gray-800);
  font-size: var(--mp2-font-size-lg);
  font-weight: 600;
}

/* ==== TOP REPOSTS ==== */
.mp2-top-reposts {
  margin: var(--mp2-space-xl) 0;
  border-radius: var(--mp2-radius-lg);
  box-shadow: var(--mp2-shadow-sm);
  overflow: hidden;
}

.mp2-top-reposts h2 {
  margin: 0;
  padding: var(--mp2-space-xl);
  background: #7cadf7; /* Keep current beige/orange background */
  color: var(--mp2-gray-800);
  font-size: var(--mp2-font-size-2xl);
  font-weight: 700;
  border-bottom: 1px solid var(--mp2-gray-200);
}

.mp2-top-reposts-content {
  background: white;
  padding: var(--mp2-space-xl);
  border: 1px solid var(--mp2-gray-200);
  border-top: none;
}
/* ==== ACTION BUTTONS ==== */
.mp2-action-buttons {
  display: block;
  gap: var(--mp2-space-sm);
  align-items: center;
}

/* ==== TEST DATA GENERATOR ==== */
.mp2-test-generator {
  background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
  border: 1px solid #ffeb9c;
  border-radius: var(--mp2-radius-lg);
  padding: var(--mp2-space-xl);
  margin: var(--mp2-space-xl) 0;
  text-align: center;
}

.mp2-test-generator .mp2-no-data {
  font-size: 2rem;
  margin-bottom: var(--mp2-space-lg);
  opacity: 0.3;
}

.mp2-test-generator h2 {
  margin: 0 0 var(--mp2-space-md) 0;
  color: #856404;
  font-size: var(--mp2-font-size-xl);
  font-weight: 700;
}

.mp2-test-generator p {
  margin: 0 0 var(--mp2-space-lg) 0;
  color: #856404;
  font-size: var(--mp2-font-size-sm);
  opacity: 0.9;
}

.mp2-test-buttons {
  display: flex;
  gap: var(--mp2-space-md);
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.mp2-test-buttons .mp2-divider {
  margin: 0 var(--mp2-space-sm);
  color: var(--mp2-gray-400);
  font-weight: bold;
}

.mp2-test-status {
  margin-top: var(--mp2-space-lg);
  padding: var(--mp2-space-md);
  background: var(--mp2-gray-50);
  border-radius: var(--mp2-radius-md);
  display: none;
  font-size: var(--mp2-font-size-sm);
  font-weight: 500;
}

/* ==== DEVICE STATS ==== */
.mp2-device-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--mp2-space-lg);
  margin-top: var(--mp2-space-2xl);
}

.mp2-device-stat-card {
  background: #cdf7cd;
  border: 1px solid var(--mp2-gray-200);
  border-radius: var(--mp2-radius-lg);
  overflow: hidden;
  box-shadow: var(--mp2-shadow-sm);
}

.mp2-device-stat-card h3 {
  margin: 0;
  padding: var(--mp2-space-lg);
  background: #7cadf7;
  border-bottom: 1px solid var(--mp2-gray-200);
  font-size: var(--mp2-font-size-lg);
  font-weight: 600;
  color: var(--mp2-gray-800);
}

/* ==== NEW VISITOR BREAKDOWN CHART STYLES ==== */
.mp2-device-card-content {
  display: flex;
  padding: var(--mp2-space-md);
  gap: var(--mp2-space-md);
  align-items: flex-start;
  min-height: 180px;
}

.mp2-data-column {
  flex: 0 0 40%;
  min-width: 40%;
  font-size: var(--mp2-font-size-sm);
}

.mp2-chart-column {
  flex: 0 0 60%;
  min-width: 60%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--mp2-space-sm);
}

.mp2-mini-chart {
  width: 180px !important;
  height: 180px !important;
  max-width: 180px;
  max-height: 180px;
}

.mp2-chart-empty {
  color: var(--mp2-gray-500);
  font-style: italic;
  text-align: center;
  font-size: var(--mp2-font-size-sm);
  padding: var(--mp2-space-lg);
}

/* ==== TRAFFIC SOURCES CHART ==== */
.mp2-traffic-chart {
  width: 400px !important;
  height: 400px !important;
  max-width: 400px;
  max-height: 400px;
}

@media (max-width: 600px) {
  .mp2-traffic-chart {
    width: 250px !important;
    height: 250px !important;
    max-width: 250px;
    max-height: 250px;
  }
}


/* ==== UTILITY CLASSES ==== */
.mp2-no-data {
  text-align: center;
  color: var(--mp2-gray-500);
  font-style: italic;
  padding: var(--mp2-space-xl);
}

.mp2-debug-info {
  background: #f0f6fc;
  border: 1px solid #c8e1ff;
  border-radius: var(--mp2-radius-md);
  padding: var(--mp2-space-md);
  margin-top: var(--mp2-space-md);
  font-size: var(--mp2-font-size-sm);
  color: #0969da;
}

.mp2-divider {
  color: var(--mp2-gray-400);
  margin: 0 var(--mp2-space-sm);
}

/* ==== RESPONSIVE DESIGN ==== */
@media (max-width: 768px) {
  .mp2-date-filter-form {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .mp2-date-presets {
    margin-left: 0;
    margin-top: var(--mp2-space-md);
  }
  
  .mp2-chart-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .mp2-test-buttons {
    justify-content: center;
  }
  
  .mp2-action-buttons {
    flex-direction: column;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .mp2-overview-stats {
    grid-template-columns: 1fr;
  }
  
  .mp2-traffic-grid {
    grid-template-columns: 1fr;
  }
  
  .mp2-device-stats {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 1024px) {
  .mp2-device-stats {
    grid-template-columns: 1fr;
    gap: var(--mp2-space-md);
  }
}

@media (max-width: 600px) {
  .mp2-device-card-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .mp2-data-column {
    width: 100%;
  }
  
  .mp2-chart-column {
    max-width: none;
    margin-top: var(--mp2-space-sm);
  }
  
  .mp2-mini-chart {
    width: 100px !important;
    height: 100px !important;
    max-width: 100px;
    max-height: 100px;
  }
}
/* ===== analytics.css – ONLY rules missing from dashboard.css ===== */

/* chart canvas containers */
.mp2-chart-container {
    position: relative;
    height: 400px;
    margin-top: 1rem;
}
.mp2-mini-chart {
    max-height: 180px;
}

/* traffic doughnut legend wrap */
.mp2-traffic-chart {
    max-width: 320px;
    max-height: 320px;
}

/* stat-card colour overrides (already defined in dashboard.css vars) */
.mp2-stat-card.color-green  .mp2-stat-value { color: var(--color-green-light); }
.mp2-stat-card.color-blue   .mp2-stat-value { color: var(--color-blue-light); }
.mp2-stat-card.color-orange .mp2-stat-value { color: var(--color-orange-light); }
.mp2-stat-card.color-red    .mp2-stat-value { color: var(--color-red-light); }
.mp2-stat-card.color-purple .mp2-stat-value { color: var(--color-purple-light); }
.mp2-stat-card.color-indigo .mp2-stat-value { color: var(--color-indigo-light); }

[data-mp2-theme="dark"] .mp2-stat-card.color-green  .mp2-stat-value { color: var(--color-green-dark); }
[data-mp2-theme="dark"] .mp2-stat-card.color-blue   .mp2-stat-value { color: var(--color-blue-dark); }
[data-mp2-theme="dark"] .mp2-stat-card.color-orange .mp2-stat-value { color: var(--color-orange-dark); }
[data-mp2-theme="dark"] .mp2-stat-card.color-red    .mp2-stat-value { color: var(--color-red-dark); }
[data-mp2-theme="dark"] .mp2-stat-card.color-purple .mp2-stat-value { color: var(--color-purple-dark); }
[data-mp2-theme="dark"] .mp2-stat-card.color-indigo .mp2-stat-value { color: var(--color-indigo-dark); }

/* subtle zebra striping for analytics table (optional) */
.mp2-analytics-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}
[data-mp2-theme="dark"] .mp2-analytics-table tbody tr:nth-child(even) {
    background-color: #2d3139;
}

/* CSV export button tiny tweak */
#export-csv-btn {
    vertical-align: middle;
    margin-left: 6px;
}
echo '<style>
.mp2-analytics-filter-form input[type="date"]:hover {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.mp2-analytics-filter-form input[type="date"]:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.mp2-analytics-filter-form button[type="submit"]:hover {
    background: #4338ca !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(79, 70, 229, 0.3);
}
</style>';