/* ============================================
   VisitorAnalytics 1.0 - Advanced Analytics
   Cohort, forecast, churn, re-identification,
   visit prediction
   ============================================ */

/* ============ Cohort / Retention ============ */
.retention-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.retention-table th,
.retention-table td {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border: 1px solid var(--va-border);
}

.retention-table th {
    background: var(--va-sidebar);
    font-weight: 600;
    color: var(--va-text-dim);
    font-size: 0.75rem;
}

.retention-table .cohort-header { text-align: left; min-width: 100px; }
.retention-table .size-header   { min-width: 60px; }
.retention-table .week-header   { min-width: 50px; }

.retention-table .cohort-label {
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    color: var(--va-text);
}

.retention-table .cohort-size {
    color: var(--va-text-muted);
    font-size: 0.8rem;
}

.retention-cell {
    background: rgba(61, 214, 140, var(--retention, 0));
    color: var(--va-text);
    font-weight: 500;
    transition: all 0.2s ease;
}

.retention-cell:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(61, 214, 140, 0.5);
    z-index: 1;
    position: relative;
}

/* Cohort Badge */
.cohort-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.cohort-badge.badge-primary { background: rgba(78, 205, 196, 0.15); color: #4ECDC4; }
.cohort-badge.badge-info    { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }
.cohort-badge.badge-success { background: rgba(61, 214, 140, 0.15); color: #3DD68C; }

/* Legend */
.legend-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--va-text-dim);
}

.legend-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--va-border);
    flex-shrink: 0;
}

.legend-note {
    font-size: 0.8rem;
    color: var(--va-text-muted);
    line-height: 1.6;
    margin: 0;
    padding-top: 1rem;
    border-top: 1px solid var(--va-border);
}

.light .retention-table th {
    background: #f8fafc;
    color: #64748b;
    border-color: #e2e8f0;
}

.light .retention-table td {
    border-color: #e2e8f0;
}

.light .retention-table .cohort-label {
    color: #1e293b;
}

.light .legend-item {
    color: #475569;
}

.light .legend-color {
    border-color: #e2e8f0;
}

.light .legend-note {
    color: #64748b;
    border-top-color: #e2e8f0;
}

/* ============ Forecast ============ */
.forecast-confidence {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.forecast-confidence.confidence-high   { background: rgba(61, 214, 140, 0.15); color: #3DD68C; }
.forecast-confidence.confidence-medium { background: rgba(255, 204, 0, 0.15);  color: #FFCC00; }
.forecast-confidence.confidence-low    { background: rgba(107, 114, 128, 0.2); color: #9CA3AF; }

.forecast-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.forecast-badge.badge-primary { background: rgba(78, 205, 196, 0.15); color: #4ECDC4; }
.forecast-badge.badge-info    { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }

.forecast-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

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

.forecast-table th {
    font-weight: 600;
    color: var(--va-text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
}

.forecast-table .date-cell      { font-weight: 500; color: var(--va-text); }
.forecast-table .day-cell       { color: var(--va-text-dim); }
.forecast-table .predicted-cell { font-weight: 600; color: #4ECDC4; }
.forecast-table .range-cell     { font-size: 0.8rem; color: var(--va-text-muted); }

/* Methodology */
.methodology-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.methodology-item {
    display: flex;
    gap: 0.75rem;
}

.methodology-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.methodology-content strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--va-text);
}

.methodology-content p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--va-text-muted);
}

/* Confidence Legend */
.confidence-legend {
    display: flex;
    gap: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--va-border);
}

.confidence-item {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

.confidence-item.high   { background: rgba(61, 214, 140, 0.2); color: #3DD68C; }
.confidence-item.medium { background: rgba(255, 204, 0, 0.2);  color: #FFCC00; }
.confidence-item.low    { background: rgba(107, 114, 128, 0.2); color: #9CA3AF; }

.light .forecast-table th  { color: #64748b; }
.light .forecast-table td  { border-color: #e2e8f0; }
.light .forecast-table .date-cell { color: #1e293b; }
.light .methodology-content strong { color: #1e293b; }
.light .confidence-legend { border-top-color: #e2e8f0; }

/* ============ Re-identification ============ */
.reid-empty-state {
    max-width: 600px;
    margin: 2rem auto;
    text-align: center;
    background: var(--va-card);
    border-radius: 12px;
    padding: 3rem;
}

.reid-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.reid-empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--va-text);
}

.reid-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.reid-metric-item {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.reid-metric-label {
    display: block;
    font-size: 0.85rem;
    color: var(--va-text-muted);
    margin-bottom: 0.25rem;
}

.reid-metric-value {
    font-size: 1.75rem;
    font-weight: 700;
}

.reid-threshold-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.reid-threshold-label {
    display: block;
    font-size: 0.85rem;
    color: var(--va-text-muted);
    margin-bottom: 0.5rem;
}

.reid-threshold-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.reid-threshold-value {
    font-weight: 600;
}

.reid-cluster-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    text-align: center;
}

.reid-cluster-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.reid-cluster-label { font-size: 0.75rem; color: var(--va-text-muted); }
.reid-cluster-value { font-weight: 600; color: var(--va-text); }

.reid-visitor-id {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.reid-confidence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reid-how-it-works {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.reid-how-item { text-align: center; padding: 1rem; }
.reid-how-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.reid-how-title { font-weight: 600; margin-bottom: 0.25rem; color: var(--va-text); }
.reid-how-desc  { font-size: 0.85rem; color: var(--va-text-muted); }

.light .reid-empty-state  { background: #f8fafc; }
.light .reid-metric-item  { background: rgba(0, 0, 0, 0.05); }
.light .reid-threshold-section { border-top-color: rgba(0, 0, 0, 0.1); }
.light .reid-visitor-id   { background: rgba(0, 0, 0, 0.05); }

@media (max-width: 768px) {
    .reid-metrics-grid,
    .reid-how-it-works {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============ Churn Prediction ============ */
.churn-legend {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.churn-feature-item {
    margin-bottom: 1rem;
}

.churn-feature-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.churn-probability {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.churn-device-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.churn-device-item {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.churn-device-icon  { font-size: 2rem; margin-bottom: 0.5rem; }
.churn-device-name  { font-weight: 600; color: var(--va-text); }
.churn-device-count { font-size: 0.85rem; margin-bottom: 0.5rem; }
.churn-device-risk  { margin-top: 0.5rem; }

.light .churn-device-item {
    background: rgba(0, 0, 0, 0.02);
}

@media (max-width: 768px) {
    .churn-device-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============ Visit Prediction ============ */
.visit-empty-state {
    max-width: 600px;
    margin: 2rem auto;
    text-align: center;
    background: var(--va-card);
    border-radius: 12px;
    padding: 3rem;
}

.visit-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.visit-empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--va-text);
}

.visit-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.visit-badge.badge-primary { background: rgba(78, 205, 196, 0.15); color: #4ECDC4; }
.visit-badge.badge-info    { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }
.visit-badge.badge-success { background: rgba(61, 214, 140, 0.15); color: #3DD68C; }
.visit-badge.badge-warning { background: rgba(255, 204, 0, 0.15);  color: #FFCC00; }

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

.visit-table th {
    text-align: left;
    padding: 0.75rem;
    font-weight: 600;
    color: #9ca3af;
    border-bottom: 1px solid var(--va-border);
    text-transform: uppercase;
    font-size: 0.75rem;
}

.visit-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--va-border);
    color: #e5e7eb;
}

.visit-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.visit-table .today-row {
    background: rgba(99, 102, 241, 0.15);
}

.visit-visitor-id {
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-family: monospace;
}

.visit-probability {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.visit-feature-item {
    margin-bottom: 0.75rem;
}

.visit-feature-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.visit-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.visit-stat-item {
    text-align: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.visit-stat-label { font-size: 0.75rem; color: var(--va-text-muted); }
.visit-stat-value { font-weight: 600; color: var(--va-text); }

.visit-how-it-works {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.visit-how-item  { text-align: center; padding: 1rem; }
.visit-how-icon  { font-size: 2rem; margin-bottom: 0.5rem; }
.visit-how-title { font-weight: 600; margin-bottom: 0.25rem; color: var(--va-text); }
.visit-how-desc  { font-size: 0.85rem; color: var(--va-text-muted); }

.light .visit-empty-state    { background: var(--va-card); }
.light .visit-table th       { color: #6b7280; border-bottom-color: var(--va-border-light); }
.light .visit-table td       { color: #1f2937; border-bottom-color: var(--va-border-light); }
.light .visit-table tbody tr:hover { background: rgba(0, 0, 0, 0.02); }
.light .visit-table .today-row     { background: rgba(99, 102, 241, 0.1); }
.light .visit-visitor-id     { background: rgba(0, 0, 0, 0.05); }
.light .visit-stats-grid     { border-top-color: rgba(0, 0, 0, 0.1); }
.light .visit-stat-item      { background: rgba(0, 0, 0, 0.03); }

@media (max-width: 768px) {
    .visit-how-it-works {
        grid-template-columns: repeat(2, 1fr);
    }
}
