/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
  color: #2d3748;
  line-height: 1.6;
}

/* Purple theme variables */
:root {
  --primary-purple: #B19CD9;
  --primary-purple-dark: #9370DB;
  --primary-purple-light: #E6E6FA;
  --primary-purple-lighter: #F0F0FF;
  --accent-purple: #DDA0DD;
  --text-dark: #2d3748;
  --text-light: #718096;
  --white: #ffffff;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary-purple) 0%, var(--primary-purple-dark) 100%);
  color: white;
  padding: 2rem 0;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Navigation */
.nav {
  background: var(--white);
  border-bottom: 1px solid var(--primary-purple-light);
  padding: 0;
  box-shadow: var(--shadow);
}

.nav-list {
  display: flex;
  list-style: none;
  max-width: 1400px;
  margin: 0 auto;
  overflow-x: auto;
}

.nav-item {
  flex-shrink: 0;
}

.nav-link {
  display: block;
  padding: 1rem 1.5rem;
  color: var(--text-dark);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  border-bottom: 3px solid transparent;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.nav-link:hover {
  background: var(--primary-purple-lighter);
  color: var(--primary-purple-dark);
}

.nav-link.active {
  color: var(--primary-purple-dark);
  border-bottom-color: var(--primary-purple);
  background: var(--primary-purple-lighter);
}

/* Main content */
.main {
  padding: 2rem 0;
  min-height: calc(100vh - 200px);
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease-in;
}

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

/* Cards */
.card {
  background: var(--white);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  border: 1px solid var(--primary-purple-light);
}

.card-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--primary-purple-light);
}

.card-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-purple-dark);
  margin-bottom: 0.5rem;
}

.card-subtitle {
  color: var(--text-light);
  font-size: 0.95rem;
}

/* KPI Cards */
.kpi-grid {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}


.kpi-card {
  background: linear-gradient(135deg, var(--white) 0%, var(--primary-purple-lighter) 100%);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--primary-purple-light);
  transition: transform 0.3s ease;
  flex: 1;
  min-width: 0;
}

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

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-purple-dark);
  margin-bottom: 0.3rem;
}

.kpi-label {
  color: var(--text-light);
  font-size: 0.8rem;
  font-weight: 500;
}

.kpi-description {
  color: var(--text-light);
  font-size: 0.7rem;
  margin-top: 0.3rem;
}

/* Charts container */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.chart-container {
  background: var(--white);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--primary-purple-light);
}

.chart-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-purple-dark);
  margin-bottom: 1rem;
  text-align: center;
}

.chart-description {
  text-align: center;
  margin-top: 1rem;
  color: #666;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Insights Grid */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.insight-item h4 {
  color: var(--primary-purple-dark);
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.insight-item p {
  color: var(--text-light);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Coming Soon */
.coming-soon {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
  font-style: italic;
}

/* Additional styles for new sections */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    min-width: 150px;
}

.filter-label {
    font-weight: 500;
    color: var(--primary-purple-dark);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.filter-select,
.filter-input {
    padding: 0.5rem;
    border: 1px solid var(--primary-purple);
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    background-color: white;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary-purple-dark);
    box-shadow: 0 0 0 2px rgba(177, 156, 217, 0.2);
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-purple);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-purple-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--primary-purple-light);
    color: var(--primary-purple-dark);
    border: 1px solid var(--primary-purple);
}

.btn-secondary:hover {
    background-color: var(--primary-purple);
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.recommendations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.recommendation-item {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease;
}

.recommendation-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.recommendation-item h4 {
    color: var(--primary-purple-dark);
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.recommendation-item p {
    margin: 0;
    color: var(--text-color);
    line-height: 1.6;
}

.sort-arrow {
    font-size: 0.8rem;
    color: var(--primary-purple);
    margin-left: 0.5rem;
}

.table th {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.table th:hover {
    background-color: var(--primary-purple-light);
}

/* Data Explorer Table Styles */
#dataTable {
    font-size: 0.75rem;
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    table-layout: fixed;
}

#dataTable th,
#dataTable td {
    padding: 0.4rem 0.3rem;
    text-align: left;
    border-bottom: 1px solid var(--primary-purple-light);
    font-size: 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#dataTable th {
    background: var(--primary-purple-lighter);
    font-weight: 600;
    color: var(--primary-purple-dark);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

#dataTable tr:hover {
    background: var(--primary-purple-lighter);
}

#dataTable td {
    font-size: 0.7rem;
    color: var(--text-dark);
}

/* Column width adjustments - optimized for better screen fit */
#dataTable th:nth-child(1), #dataTable td:nth-child(1) { width: 18%; } /* City (DMA) */
#dataTable th:nth-child(2), #dataTable td:nth-child(2) { width: 9%; }  /* ZIP Code */
#dataTable th:nth-child(3), #dataTable td:nth-child(3) { width: 11%; } /* Population */
#dataTable th:nth-child(4), #dataTable td:nth-child(4) { width: 11%; } /* Gen Z Females */
#dataTable th:nth-child(5), #dataTable td:nth-child(5) { width: 10%; } /* Concentration */
#dataTable th:nth-child(6), #dataTable td:nth-child(6) { width: 8%; }  /* Index */
#dataTable th:nth-child(7), #dataTable td:nth-child(7) { width: 10%; } /* Age 15-19 */
#dataTable th:nth-child(8), #dataTable td:nth-child(8) { width: 10%; } /* Age 20-24 */
#dataTable th:nth-child(9), #dataTable td:nth-child(9) { width: 13%; } /* Age 25-29 */

/* Summary Table Styles (without ZIP code column) */
#summaryTable {
    font-size: 0.75rem;
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    table-layout: fixed;
}

#summaryTable th,
#summaryTable td {
    padding: 0.4rem 0.3rem;
    text-align: left;
    border-bottom: 1px solid var(--primary-purple-light);
    font-size: 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#summaryTable th {
    background: var(--primary-purple-lighter);
    font-weight: 600;
    color: var(--primary-purple-dark);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

#summaryTable tr:hover {
    background: var(--primary-purple-lighter);
}

#summaryTable tr {
    transition: background-color 0.2s ease;
}

#summaryTable tr:hover {
    background: var(--primary-purple-lighter);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#summaryTable td {
    font-size: 0.7rem;
    color: var(--text-dark);
}

/* Summary Table Column width adjustments - without ZIP code */
#summaryTable th:nth-child(1), #summaryTable td:nth-child(1) { width: 20%; } /* City (DMA) */
#summaryTable th:nth-child(2), #summaryTable td:nth-child(2) { width: 13%; } /* Population */
#summaryTable th:nth-child(3), #summaryTable td:nth-child(3) { width: 13%; } /* Gen Z Females */
#summaryTable th:nth-child(4), #summaryTable td:nth-child(4) { width: 12%; } /* Concentration */
#summaryTable th:nth-child(5), #summaryTable td:nth-child(5) { width: 10%; } /* Index */
#summaryTable th:nth-child(6), #summaryTable td:nth-child(6) { width: 11%; } /* Age 15-19 */
#summaryTable th:nth-child(7), #summaryTable td:nth-child(7) { width: 11%; } /* Age 20-24 */
#summaryTable th:nth-child(8), #summaryTable td:nth-child(8) { width: 10%; } /* Age 25-29 */

/* Methodology Steps */
.methodology-steps {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-top: 2rem;
}

.step {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
  border-radius: 12px;
  border: 1px solid var(--primary-purple-light);
}

.step-number {
  background: var(--primary-purple);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

.step-content {
  flex: 1;
}

.step-content h4 {
  color: var(--primary-purple-dark);
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
}

.step-content p {
  color: var(--text-light);
  margin-bottom: 1rem;
  line-height: 1.6;
}

.formula-box {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--primary-purple-light);
  margin-bottom: 1rem;
}

.formula-box strong {
  color: var(--primary-purple-dark);
  display: block;
  margin-bottom: 0.5rem;
}

.formula-box code {
  display: block;
  background: #f8f9ff;
  padding: 0.5rem;
  border-radius: 4px;
  font-family: monospace;
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.example {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-light);
  font-style: italic;
}

.categories-table {
  margin-top: 1rem;
  overflow-x: auto;
}

.categories-table table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

.categories-table th {
  background: var(--primary-purple-lighter);
  font-weight: 600;
  color: var(--primary-purple-dark);
}

.categories-table tr:hover {
  background: var(--primary-purple-lighter);
}

/* Footer */
.footer {
  background: var(--primary-purple-dark);
  color: white;
  text-align: center;
  padding: 1rem 0;
  margin-top: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
  .header h1 {
    font-size: 2rem;
  }
  
  .nav-list {
    flex-direction: column;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
  
  .insights-grid {
    grid-template-columns: 1fr;
  }
  
  .step {
    flex-direction: column;
    text-align: center;
  }
  
  .step-number {
    align-self: center;
  }
}

/* Chart.js customization */
.chart-container canvas {
  max-height: 400px;
}

/* Loading animation */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  font-size: 1.1rem;
  color: var(--text-light);
}

.loading::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 4px solid var(--primary-purple-light);
  border-top: 4px solid var(--primary-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 1rem;
}

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