/* Enhanced Analytics Dashboard Styles */
.analytics-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.analytics-header {
    text-align: center;
    margin-bottom: 20px;
}

.analytics-header h1 {
    color: #2d3748;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Learning Summary Section */
.learning-summary {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left: 4px solid #0ea5e9;
    border-radius: 0 12px 12px 0;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.1);
}

.summary-title {
    color: #0c4a6e;
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-text {
    color: #0c4a6e;
    line-height: 1.6;
    margin: 0;
    font-size: 14px;
}

/* KPI Cards */
.analytics-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.analytics-stat-card {
    background: rgb(255, 255, 255);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0);
    border: 1px solid #e2e8f0;
    transition: transform 0.2s ease;
}

.analytics-stat-card:hover {
    transform: translateY(-1px);
}

.analytics-stat-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.analytics-stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.analytics-stat-icon i {
    width: 16px;
    height: 16px;
}

.analytics-stat-icon.accuracy {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.analytics-stat-icon.time {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.analytics-stat-icon.games {
    background-color: #fbbf24;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.analytics-stat-icon.games i[data-lucide="trophy"] {
    color: white !important;
    width: 16px !important;
    height: 16px !important;
}

.analytics-stat-content {
    flex: 1;
}

.analytics-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 2px;
    line-height: 1;
}

.analytics-stat-label {
    color: #718096;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
}

.analytics-stat-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
}

.analytics-stat-trend.trend-up { 
    color: #38a169;
}

.analytics-stat-trend.trend-down { 
    color: #e53e3e;
}

.analytics-stat-trend.trend-tracking {
    color: #6b7280;
    font-style: italic;
}

/* Chart Section */
.analytics-chart-container {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
}

.analytics-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 24px;
}

.analytics-section-title {
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.5;
}

.analytics-time-period-options {
    display: flex;
    gap: 4px;
}

.analytics-time-period-btn {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.5;
    display: inline-flex;
    align-items: center;
}

.analytics-time-period-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.analytics-time-period-btn:hover {
    border-color: #667eea;
    background: #edf2f7;
}

.analytics-time-period-btn.active:hover {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

.analytics-chart-content {
    height: 200px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 8px;
    display: flex;
    align-items: end;
    justify-content: space-around;
    padding: 12px 16px 50px 16px;
    margin-bottom: 16px;
    position: relative;
    overflow: visible;
    box-sizing: border-box;
}

.analytics-chart-bars {
    display: flex;
    align-items: end;
    justify-content: space-around;
    height: calc(100% - 8px);
    width: 100%;
    margin-top: 4px;
}

.analytics-chart-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
}

.analytics-chart-line.active {
    display: block;
}

.analytics-chart-bar {
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px 3px 0 0;
    width: 20px;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.analytics-chart-bar:hover {
    background: linear-gradient(180deg, #5a67d8 0%, #6b46c1 100%);
    transform: scaleY(1.05);
}

.analytics-chart-bar-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #718096;
    font-weight: 500;
    white-space: nowrap;
}

.analytics-line-chart-svg {
    width: 100%;
    height: 100%;
    min-height: 120px;
}

.analytics-line-path {
    fill: none;
    stroke: #667eea;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.analytics-line-area {
    fill: url(#analyticsGradient);
    opacity: 0.3;
}

.analytics-line-point {
    fill: #667eea;
    stroke: white;
    stroke-width: 2;
    cursor: pointer;
    transition: all 0.2s ease;
}

.analytics-line-point:hover {
    fill: #5a67d8;
    stroke-width: 3;
}

.analytics-line-labels {
    position: absolute;
    bottom: -25px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    overflow: hidden;
}

.analytics-line-label {
    font-size: 10px;
    color: #718096;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}

/* Responsive label spacing for dense data */
.analytics-line-labels.last_30_days .analytics-line-label {
    display: none;
}

.analytics-line-labels.last_30_days .analytics-line-label:nth-child(5n) {
    display: block;
}

.analytics-line-labels.last_52_weeks .analytics-line-label {
    display: none;
}

.analytics-line-labels.last_52_weeks .analytics-line-label:nth-child(4n) {
    display: block;
}

/* Journey Cards Section - RESPONSIVE GRID */
.journey-cards-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.journey-header {
    margin-bottom: 16px;
}

.journey-title {
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.journey-subtitle {
    color: #718096;
    font-size: 13px;
    margin: 0;
}

/* RESPONSIVE Journey Cards Grid */
.cards-grid-detailed {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* Desktop: 6 cards per row minimum */
    gap: 8px;
}

.card-detailed {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    min-height: 90px;
    display: flex;
    flex-direction: column;
}

.card-detailed:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.card-detailed.selected {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 12px 8px rgba(100, 100, 100, 0.8) !important;
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.table-number-large {
    font-size: 15px;
    font-weight: 700;
    color: #2d3748;
}

.stage-icon-large {
    font-size: 14px;
}

.progress-details {
    text-align: center;
    margin-top: auto;
}

.percentage-large {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 3px;
}

.stage-name-large {
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.trend-indicator {
    font-size: 9px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

/* Stage-specific styling */
.card-detailed.getting-started {
    border-color: #ce7e49;  /* Changed from #ea580c to brown-red */
    background: linear-gradient(135deg, #fef2f2 0%, rgba(185, 28, 28, 0.1) 100%);  /* Changed to brown-red fade */
}

.card-detailed.getting-started .percentage-large { 
    color: #923636;  /* Keep existing red */
}

.card-detailed.getting-started .stage-name-large { 
    color: #823232;  /* Darker brown-red */
}

.card-detailed.getting-started .progress-fill { 
    background: linear-gradient(90deg, #8b2121c8, #842525c2);  /* Brown-red to red gradient */
}

.card-detailed.getting-started .trend-indicator { 
    color: #952222;  /* Keep existing red */
}

.card-detailed.developing {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #dbeafe 0%, rgba(96, 165, 250, 0.1) 100%);
}
.card-detailed.developing .percentage-large { color: #2563eb; }
.card-detailed.developing .stage-name-large { color: #1e40af; }
.card-detailed.developing .progress-fill { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.card-detailed.developing .trend-indicator { color: #2563eb; }

.card-detailed.confident {
    border-color: #22c55e;
    background: linear-gradient(135deg, #dcfce7 0%, rgba(74, 222, 128, 0.1) 100%);
}
.card-detailed.confident .percentage-large { color: #16a34a; }
.card-detailed.confident .stage-name-large { color: #166534; }
.card-detailed.confident .progress-fill { background: linear-gradient(90deg, #22c55e, #16a34a); }
.card-detailed.confident .trend-indicator { color: #16a34a; }

.card-detailed.mastery {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #fef3cd 0%, rgba(252, 211, 77, 0.1) 100%);
}
.card-detailed.mastery .percentage-large { color: #d97706; }
.card-detailed.mastery .stage-name-large { color: #92400e; }
.card-detailed.mastery .progress-fill { background: linear-gradient(90deg, #f59e0b, #d97706); }
.card-detailed.mastery .trend-indicator { color: #d97706; }

.card-detailed.not-started {
    border-color: #e2e8f0;
    background: #f8fafc;
    opacity: 0.7;
}
.card-detailed.not-started .percentage-large { color: #9ca3af; }
.card-detailed.not-started .stage-name-large { color: #6b7280; }
.card-detailed.not-started .progress-fill { background: #e5e7eb; }
.card-detailed.not-started .trend-indicator { color: #9ca3af; }

/* Recent Activity Section */
.analytics-recent-activity {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    margin-top: 16px;
}

.analytics-recent-header {
    margin-bottom: 12px;
}

.analytics-recent-title {
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.5;
}

.analytics-recent-content {
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px;
}

.analytics-no-activity {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #718096;
    font-size: 14px;
    padding: 20px;
}

.analytics-activity-day {
    background: white;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
}

.analytics-activity-day:last-child {
    margin-bottom: 0;
}

.analytics-activity-day:hover {
    border-color: #667eea;
    transform: translateY(-1px);
}

.analytics-activity-date {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.analytics-activity-streak {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.analytics-activity-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: #4a5568;
}

.analytics-activity-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #edf2f7;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.analytics-activity-stat i {
    width: 12px;
    height: 12px;
}

.analytics-activity-stat i[data-lucide="clock"] {
    color: #14b8a6;
}

.analytics-activity-stat i[data-lucide="target"] {
    color: #22c55e;
}

.analytics-activity-stat i[data-lucide="trophy"] {
    color: #fbbf24;
}

.analytics-activity-stat i[data-lucide="hash"] {
    color: #8b5cf6;
}

/* Journey milestone highlights */
.journey-milestone {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    border: 1px solid #22c55e;
    color: #166534;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    animation: celebrationGlow 2s ease-in-out;
}

/* Animations */
@keyframes celebrationGlow {
    0%, 100% { box-shadow: 0 0 0 rgba(34, 197, 94, 0.3); }
    50% { box-shadow: 0 0 8px rgba(34, 197, 94, 0.6); }
}

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

.analytics-stat-card {
    animation: analyticseFadeInUp 0.3s ease forwards;
}

/* RESPONSIVE BREAKPOINTS */

/* Tablet (Max 1024px) - Minimum 4 cards per row */
@media (max-width: 1024px) {
    .cards-grid-detailed {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .card-detailed {
        min-height: 85px;
        padding: 6px;
    }

    .table-number-large {
        font-size: 14px;
    }

    .percentage-large {
        font-size: 16px;
    }

    .stage-name-large {
        font-size: 9px;
    }
}

/* Mobile (Max 768px) - Minimum 3 cards per row */
@media (max-width: 768px) {
    .analytics-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .analytics-stat-card {
        padding: 8px;
    }

    .analytics-stat-value {
        font-size: 16px;
    }

    .analytics-stat-label {
        font-size: 10px;
    }

    .analytics-stat-trend {
        font-size: 9px;
    }

    .cards-grid-detailed {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .card-detailed {
        min-height: 80px;
        padding: 6px;
    }

    .table-number-large {
        font-size: 13px;
    }

    .percentage-large {
        font-size: 15px;
    }

    .stage-name-large {
        font-size: 8px;
    }

    .analytics-chart-content {
        height: 150px;
        padding: 15px;
    }

    .analytics-recent-activity {
        padding: 12px;
        margin-top: 12px;
    }
    
    .analytics-activity-stats {
        gap: 6px;
    }
    
    .analytics-activity-stat {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .analytics-activity-date {
        font-size: 13px;
    }

    .analytics-line-labels.last_30_days .analytics-line-label:nth-child(5n) {
        display: none;
    }
    
    .analytics-line-labels.last_30_days .analytics-line-label:nth-child(7n) {
        display: block;
    }
    
    .analytics-line-labels.last_52_weeks .analytics-line-label:nth-child(4n) {
        display: none;
    }
    
    .analytics-line-labels.last_52_weeks .analytics-line-label:nth-child(8n) {
        display: block;
    }
}

/* Small Mobile (Max 480px) - Still 3 cards minimum but more compact */
@media (max-width: 480px) {
    .analytics-dashboard {
        padding: 12px;
    }

    .analytics-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .analytics-stat-card {
        padding: 6px;
    }

    .analytics-stat-value {
        font-size: 14px;
    }

    .analytics-stat-label {
        font-size: 9px;
    }

    .analytics-stat-trend {
        font-size: 8px;
    }

    /* Keep 3 cards per row even on small mobile */
    .cards-grid-detailed {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    .card-detailed {
        min-height: 70px;
        padding: 4px;
    }

    .table-number-large {
        font-size: 12px;
    }

    .percentage-large {
        font-size: 14px;
    }

    .stage-name-large {
        font-size: 7px;
    }

    .analytics-chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .analytics-time-period-options {
        align-self: flex-end;
        gap: 3px;
    }

    .analytics-time-period-btn {
        font-size: 9px;
        padding: 3px 6px;
    }

    .analytics-line-label {
        font-size: 8px;
    }

    .analytics-line-labels {
        padding: 0 10px;
    }

    .analytics-line-labels.last_30_days .analytics-line-label:nth-child(7n) {
        display: none;
    }
    
    .analytics-line-labels.last_30_days .analytics-line-label:nth-child(10n) {
        display: block;
    }
    
    .analytics-line-labels.last_52_weeks .analytics-line-label:nth-child(8n) {
        display: none;
    }
    
    .analytics-line-labels.last_52_weeks .analytics-line-label:nth-child(12n) {
        display: block;
    }
}

/* Update indicator */
.update-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #3b82f6;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 100;
    display: none;
}

.update-indicator.visible {
    display: block;
}