/* CnC Dashboard Styles */
:root {
  --primary-color: #2E4D44; /* C&C Green Header */
  --secondary-color: #1e3a32; /* Darker version of header green */
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --bg-color: #FAF5EA; /* C&C Canvas/Background */
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e8dcc6; /* Tinted border to match canvas */
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --cnc-accent: #E1C289; /* C&C Action Color */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-color);
  background-image: 
    radial-gradient(circle at 1px 1px, rgba(46, 77, 68, 0.08) 1px, transparent 0);
  background-size: 20px 20px;
  color: var(--text-primary);
  line-height: 1.6;
}

.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.dashboard-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border-bottom: 1px solid var(--secondary-color);
  padding: 1rem 2rem 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: all 0.3s ease;
}

/* Compact header when scrolling */
.dashboard-header.compact {
  padding: 0.5rem 2rem 0;
}

.dashboard-header.compact .header-content {
  padding-bottom: 0.5rem;
}

.dashboard-header.compact .logo {
  width: 60px;
  height: 30px;
}

.dashboard-header.compact h1 {
  font-size: 1.25rem;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-grow: 1;
  padding-bottom: 1rem;
}

.logo-container {
  flex-shrink: 0;
  padding: 0.5rem;
  display: flex;
  align-items: center;
}

.logo {
  width: 100px;
  height: 50px;
  object-fit: contain;
  filter: brightness(1.1);
}

.header-text {
  flex-grow: 1;
}

.dashboard-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  margin: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.9);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success-color);
  animation: pulse 2s infinite;
}

.status-dot.error {
  background-color: var(--error-color);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Date Range Control */
.date-range-control {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1rem;
  margin: 0 0 1rem 0;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
}

/* Compact version when scrolling */
.date-range-control.compact {
  padding: 0.5rem 1rem;
  margin: 0 0 0.5rem 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(15px);
}

.date-range-control.compact .date-range-header {
  margin-bottom: 0.5rem;
}

.date-range-control.compact .date-range-icon {
  font-size: 1rem;
}

.date-range-control.compact .date-range-title {
  font-size: 0.875rem;
}

.date-range-control.compact .current-range {
  font-size: 0.875rem;
}

.date-range-control.compact .date-range-options {
  gap: 0.5rem;
  flex-wrap: wrap;
}

.date-range-control.compact .quick-select {
  gap: 0.25rem;
}

.date-range-control.compact .quick-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.date-range-control.compact .range-slider-container {
  gap: 0.5rem;
}

.date-range-control.compact .slider-label {
  font-size: 0.75rem;
}

.date-range-control.compact .slider-value {
  font-size: 0.75rem;
}

.date-range-control.compact .custom-date-toggle {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.date-range-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: white;
}

.date-range-icon {
  font-size: 1.2rem;
}

.date-range-title {
  font-weight: 600;
  font-size: 1rem;
}

.current-range {
  margin-left: auto;
  background: rgba(225, 194, 137, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  border: 1px solid rgba(225, 194, 137, 0.3);
}

.date-range-options {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.quick-select {
  display: flex;
  gap: 0.5rem;
}

.quick-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.quick-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.quick-btn.active {
  background: var(--cnc-accent);
  color: var(--primary-color);
  border-color: var(--cnc-accent);
  font-weight: 600;
}

.range-slider-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 200px;
}

.slider-label {
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.range-slider {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cnc-accent);
  border: 2px solid white;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.range-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cnc-accent);
  border: 2px solid white;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider-value {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.custom-date-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.custom-date-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.custom-date-toggle.active {
  background: var(--cnc-accent);
  color: var(--primary-color);
  border-color: var(--cnc-accent);
}

.custom-date-picker {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.date-inputs {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.date-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.date-input-group label {
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
}

.date-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.date-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

.apply-custom-dates {
  background: var(--cnc-accent);
  color: var(--primary-color);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.apply-custom-dates:hover {
  background: #d4a975;
  transform: translateY(-1px);
}

/* Responsive Date Range Control */
@media (max-width: 768px) {
  .date-range-control {
    margin: 0.5rem 1rem 0;
    padding: 0.75rem;
  }
  
  .date-range-options {
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }
  
  .quick-select {
    justify-content: center;
  }
  
  .range-slider-container {
    min-width: auto;
  }
  
  .date-inputs {
    flex-direction: column;
    align-items: stretch;
  }
  
  .current-range {
    margin-left: 0;
    margin-top: 0.5rem;
    text-align: center;
  }
}

/* Main Dashboard */
.dashboard-main {
  flex: 1;
  padding: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  align-content: start; /* Align items to start */
}

/* Dashboard Cards */
.dashboard-card {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: all 0.2s ease;
  position: relative;
  /* Fixed heights to prevent dashboard resizing */
  min-height: 300px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
}

/* Special heights for different widget types */
.dashboard-card.chart-large {
  max-height: 500px;
}

.dashboard-card.campaigns-wide {
  max-height: 600px;
}

.dashboard-card.analytics-large {
  max-height: 700px;
}

/* Make content areas scrollable */
.dashboard-card .stats-grid,
.dashboard-card .table-container,
.dashboard-card .chart-container,
.dashboard-card .campaigns-container,
.dashboard-card .analytics-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 0.5rem;
}

/* Ensure charts don't overflow */
.dashboard-card .chart-container {
  max-height: calc(100% - 60px);
  position: relative;
}

/* Custom scrollbar styling */
.dashboard-card .stats-grid::-webkit-scrollbar,
.dashboard-card .table-container::-webkit-scrollbar,
.dashboard-card .campaigns-container::-webkit-scrollbar,
.dashboard-card .analytics-container::-webkit-scrollbar {
  width: 6px;
}

.dashboard-card .stats-grid::-webkit-scrollbar-track,
.dashboard-card .table-container::-webkit-scrollbar-track,
.dashboard-card .campaigns-container::-webkit-scrollbar-track,
.dashboard-card .analytics-container::-webkit-scrollbar-track {
  background: var(--bg-color);
  border-radius: 3px;
}

.dashboard-card .stats-grid::-webkit-scrollbar-thumb,
.dashboard-card .table-container::-webkit-scrollbar-thumb,
.dashboard-card .campaigns-container::-webkit-scrollbar-thumb,
.dashboard-card .analytics-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.dashboard-card .stats-grid::-webkit-scrollbar-thumb:hover,
.dashboard-card .table-container::-webkit-scrollbar-thumb:hover,
.dashboard-card .campaigns-container::-webkit-scrollbar-thumb:hover,
.dashboard-card .analytics-container::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-color) 0%, var(--cnc-accent) 100%);
  border-radius: 12px 12px 0 0;
}

.dashboard-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.dashboard-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0; /* Prevent header from shrinking */
}

/* Executive Dashboard */
.executive-dashboard {
  background: #F5F0E6; /* Slightly darker than canvas but still light */
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  grid-column: 1 / -1; /* Span full width of main grid */
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}

.executive-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
}

.executive-header h2 {
  color: var(--primary-color);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.executive-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

.executive-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  max-width: 100%;
}

/* Stack into single column on mobile */
@media (max-width: 768px) {
  .executive-dashboard {
    margin: 0;
    border-radius: 12px;
    padding: 1rem;
  }
  
  .executive-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Analytics Section Header */
.analytics-section-header {
  grid-column: 1 / -1;
  text-align: center;
  margin: 2rem 0 1rem 0;
  padding: 1rem 0;
  border-bottom: 2px solid var(--border-color);
}

.analytics-section-header h2 {
  color: var(--primary-color);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.analytics-section-header p {
  color: var(--text-secondary);
  font-size: 1rem;
  font-style: italic;
}

.executive-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.executive-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.executive-card .card-header {
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 1rem;
  margin-bottom: 1rem;
}

.executive-card .card-header h3 {
  color: var(--primary-color);
  font-size: 1.1rem;
  font-weight: 600;
}

.card-count {
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
}

.leads-list, .visits-list, .opens-list, .clicks-list {
  max-height: 250px;
  overflow-y: auto;
}

.lead-item, .visit-item, .open-item, .click-item {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
}

.lead-item:hover, .visit-item:hover, .open-item:hover, .click-item:hover {
  background-color: var(--bg-color);
}

.lead-item:last-child, .visit-item:last-child, .open-item:last-child, .click-item:last-child {
  border-bottom: none;
}

/* Enhanced Lead Item Styling */
.lead-item.qualified-lead {
  border-left: 4px solid var(--success-color);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.05) 0%, transparent 20%);
}

.lead-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.lead-name {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0;
  flex: 1;
}

.form-badge {
  background: var(--cnc-accent);
  color: var(--primary-color);
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.lead-contact {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.lead-contact span {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.lead-service {
  background: var(--bg-color);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--primary-color);
  font-weight: 500;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border-color);
}

.lead-message {
  background: #f8fafc;
  padding: 0.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-style: italic;
  color: var(--text-primary);
  border-left: 3px solid var(--cnc-accent);
  margin-bottom: 0.5rem;
}

.lead-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.qualified-badge {
  background: var(--success-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.lead-details {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.visit-page {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.visit-details {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.email-subject {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.email-details {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.timestamp {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-style: italic;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-style: italic;
}

.no-data {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  background: var(--bg-color);
  border-radius: 8px;
  font-style: italic;
}

.card-header h2 {
  margin-bottom: 0;
  flex-grow: 1;
}

.date-range {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-color);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  font-weight: 500;
  white-space: nowrap;
}

.chart-large {
  grid-column: span 2;
}

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

.stat-item {
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--bg-color) 0%, #ffffff 100%);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.stat-item:hover {
  border-color: var(--cnc-accent);
  box-shadow: 0 4px 12px rgba(225, 194, 137, 0.2);
}

.stat-value {
  display: block;
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.stat-label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Charts */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-large .chart-container {
  height: 400px;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: var(--bg-color);
  font-weight: 600;
  color: var(--text-primary);
}

.data-table tr:hover {
  background: var(--bg-color);
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  color: var(--text-secondary);
  font-style: italic;
}

.loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-color);
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error State */
.error {
  color: var(--error-color);
  padding: 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 0.875rem;
}

/* Footer */
.dashboard-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  padding: 1rem 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Mobile Date Footer - hidden on desktop */
.mobile-date-footer {
  display: none;
}

.mobile-date-control {
  background: var(--primary-color) !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 1rem !important;
  width: 100% !important;
  margin: 0 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Hide desktop date control in header */
  .dashboard-header .date-range-control {
    display: none !important;
  }

  /* Show mobile date footer */
  .mobile-date-footer {
    display: block;
  }

  /* Style mobile date controls */
  .mobile-date-control,
  .mobile-date-control * {
    color: white !important;
  }

  .mobile-date-control .date-range-header {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
    margin-bottom: 0.75rem;
  }

  .mobile-date-control .date-range-options {
    gap: 1rem;
    flex-direction: column;
  }

  .mobile-date-control .quick-select {
    gap: 0.5rem;
    justify-content: center;
  }

  .mobile-date-control .quick-btn {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  .mobile-date-control .quick-btn.active,
  .mobile-date-control .quick-btn:hover {
    background: var(--cnc-accent) !important;
    color: var(--primary-color) !important;
    border-color: var(--cnc-accent) !important;
  }

  .mobile-date-control .range-slider-container {
    gap: 0.5rem;
  }
  .dashboard-header {
    padding: 0.75rem 1rem;
    flex-direction: row;
    gap: 0;
    position: relative;
    z-index: 1000;
  }

  /* Hide the full header content on mobile */
  .header-content {
    display: none;
  }

  /* Show simple mobile header */
  .dashboard-header::before {
    content: "CC Dashboard";
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--cnc-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
  }

  .logo {
    width: 80px;
    height: 40px;
  }

  .dashboard-main {
    padding: 1rem;
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .chart-large {
    grid-column: span 1;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .dashboard-header h1 {
    font-size: 1.5rem;
    text-align: center;
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .date-range {
    align-self: flex-end;
    font-size: 0.7rem;
  }

  /* Table responsiveness */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    min-width: 100%;
    font-size: 0.8rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.5rem;
    white-space: nowrap;
  }

  /* Campaign traffic items */
  .campaign-traffic-item {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }

  .traffic-metrics {
    justify-content: space-around;
    gap: 0.5rem;
  }

  /* Analytics tabs */
  .analytics-tabs {
    flex-direction: column;
    gap: 0.5rem;
  }

  .tab-button {
    width: 100%;
    padding: 0.75rem;
  }

  /* Remove fixed heights and scrollbars for mobile */
  .dashboard-card {
    min-height: auto !important;
    max-height: none !important;
  }

  .chart-container,
  .table-container {
    min-height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 0.9rem;
  }

  /* Mobile header */
  .dashboard-header {
    padding: 0.5rem 1rem;
  }

  .dashboard-header::before {
    font-size: 1rem;
    color: var(--cnc-accent);
    justify-content: center;
    text-align: center;
  }

  .dashboard-main {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  /* More compact date controls on phones - normal footer */
  .mobile-date-control {
    padding: 0.75rem !important;
    gap: 0.5rem;
  }

  .mobile-date-control .quick-btn {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.8rem !important;
  }

  .quick-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }

  .dashboard-card {
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }

  .stat-label {
    font-size: 0.8rem;
  }

  .card-header h2 {
    font-size: 1.1rem;
  }

  /* Remove fixed heights and scrollbars for mobile */
  .dashboard-card {
    min-height: auto !important;
    max-height: none !important;
  }

  .chart-container,
  .table-container {
    min-height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
  }

  .date-range {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
  }

  /* Ensure no horizontal overflow */
  .dashboard-card,
  .chart-container,
  .table-container {
    max-width: 100%;
    overflow-x: auto;
  }

  .campaign-traffic-header {
    flex-direction: column;
    gap: 1rem;
    padding: 0.75rem;
  }

  .traffic-summary {
    text-align: center;
  }

  .traffic-total {
    font-size: 1.5rem;
  }
}

/* Campaign Traffic Widget Styles */
.campaign-traffic-header {
  display: flex;
  justify-content: space-around;
  margin-bottom: 1rem;
  padding: 1rem;
  background: linear-gradient(135deg, var(--bg-color) 0%, #ffffff 100%);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.traffic-summary {
  text-align: center;
}

.traffic-total {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.traffic-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.campaign-traffic-container {
  max-height: 400px;
  overflow-y: auto;
}

.campaign-traffic-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.campaign-traffic-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.campaign-info {
  flex: 1;
  min-width: 0;
}

.campaign-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.campaign-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.traffic-metrics {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.traffic-metric {
  text-align: center;
  min-width: 60px;
}

.metric-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--success-color);
}

.metric-label {
  font-size: 0.625rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.no-traffic {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
  font-style: italic;
}

.no-traffic .metric-value {
  color: var(--text-secondary);
}

/* Advanced Analytics Hub Styles */
.analytics-large {
  grid-column: span 2;
  min-height: 600px;
}

.analytics-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 1rem;
  flex-wrap: wrap;
}

.tab-button {
  padding: 0.75rem 1rem;
  border: none;
  background: var(--bg-color);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
}

.tab-button:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-1px);
  border-color: var(--primary-color);
}

.tab-button.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

.tab-content h3 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.analytics-container {
  min-height: 400px;
}

/* Funnel Analysis Styles */
.funnel-item {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(90deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  align-items: center;
}

.funnel-campaign {
  font-weight: 600;
  color: var(--text-primary);
}

.funnel-stat {
  text-align: center;
}

.funnel-number {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--success-color);
}

.funnel-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Content Performance Styles */
.content-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.content-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.content-info {
  flex: 1;
}

.content-path {
  font-family: monospace;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.content-type {
  background: var(--cnc-accent);
  color: var(--primary-color);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.content-metrics {
  display: flex;
  gap: 1rem;
}

/* Temporal Analysis Styles */
.temporal-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}

.day-column {
  text-align: center;
  padding: 1rem 0.5rem;
  background: var(--bg-color);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.day-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.day-visitors {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--success-color);
  margin-bottom: 0.25rem;
}

.day-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.best-day {
  background: linear-gradient(135deg, var(--success-color), #10b981);
  color: white;
  border-color: var(--success-color);
}

.best-day .day-name,
.best-day .day-visitors,
.best-day .day-label {
  color: white;
}

/* Journey Analysis Styles */
.journey-item {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.journey-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.journey-campaign {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.journey-date {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.journey-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  text-align: center;
}

.journey-metric .metric-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* Quality Analysis Styles */
.quality-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.quality-high {
  background: linear-gradient(90deg, #d1fae5 0%, #ffffff 100%);
  border-color: var(--success-color);
}

.quality-medium {
  background: linear-gradient(90deg, #fef3c7 0%, #ffffff 100%);
  border-color: var(--warning-color);
}

.quality-low {
  background: linear-gradient(90deg, #fee2e2 0%, #ffffff 100%);
  border-color: var(--error-color);
}

.quality-date {
  font-weight: 600;
  color: var(--text-primary);
}

.quality-metrics {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.quality-score {
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.875rem;
}

.quality-score.high {
  background: var(--success-color);
  color: white;
}

.quality-score.medium {
  background: var(--warning-color);
  color: white;
}

.quality-score.low {
  background: var(--error-color);
  color: white;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .analytics-large {
    grid-column: span 1;
  }
  
  .analytics-tabs {
    flex-direction: column;
  }
  
  .funnel-item {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 0.5rem;
  }
  
  .temporal-chart {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
  }
}

/* Campaign Styles */
.campaigns-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.campaign-item {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  transition: all 0.2s ease;
}

.campaign-item:hover {
  background: #ffffff;
  box-shadow: var(--shadow);
}

.campaign-item.has-traffic {
  border-left: 4px solid var(--success-color);
}

.campaign-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.campaign-title {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 200px;
}

.campaign-date {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.traffic-indicator {
  background: var(--success-color);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.campaign-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 1rem;
}

.metric {
  text-align: center;
}

.metric-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
}

.metric-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

@media (max-width: 768px) {
  .campaign-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .campaign-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .campaign-metrics {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  
  .metric-value {
    font-size: 1.1rem;
  }
}

/* Loading Indicator - Subtle header-based approach */
.loading-indicator {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
}

.loading-indicator.active {
  display: flex;
}

.loading-indicator .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Subtle dimming for widgets during loading - REMOVED to prevent chart borking */
.dashboard-main.loading {
  /* Just prevent interaction, no visual changes */
  pointer-events: none;
}

/* Form Analytics Widget */
.form-status {
  background: var(--success-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  animation: pulse 2s infinite;
}

.form-stats-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.form-stat-item {
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--bg-color) 0%, #ffffff 100%);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.form-stat-item.primary-stat {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  border-color: var(--primary-color);
}

.form-stat-item.primary-stat .stat-value {
  color: white;
  font-size: 2.25rem;
}

.form-stat-item.primary-stat .stat-label {
  color: rgba(255, 255, 255, 0.9);
}

.form-stat-item:hover {
  border-color: var(--cnc-accent);
  box-shadow: 0 4px 12px rgba(225, 194, 137, 0.2);
  transform: translateY(-2px);
}

.forms-breakdown {
  max-height: 200px;
  overflow-y: auto;
}

.form-breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.form-breakdown-item:hover {
  background: white;
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.form-breakdown-item.top-performer {
  border-left: 4px solid var(--success-color);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.05) 0%, var(--bg-color) 20%);
}

.form-info {
  flex: 1;
}

.form-title {
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.form-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.form-metrics {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.form-metric {
  text-align: center;
  min-width: 60px;
}

.form-metric-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--success-color);
}

.form-metric-label {
  font-size: 0.625rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Mobile responsive for form analytics */
@media (max-width: 768px) {
  .form-stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  
  .form-breakdown-item {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }
  
  .form-metrics {
    justify-content: space-around;
    gap: 0.5rem;
  }
}

@media (max-width: 480px) {
  .form-stats-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .form-stat-item.primary-stat .stat-value {
    font-size: 1.75rem;
  }
}
