/* timeline.css */

.timeline-container {
    padding: 20px 0;
    max-width: 1000px;
    margin: 0 auto;
}

.timeline-test-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-left: 4px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.timeline-test-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.timeline-test-card.score-high {
    border-left-color: #28a745;
}

.timeline-test-card.score-medium {
    border-left-color: #ffc107;
}

.timeline-test-card.score-low {
    border-left-color: #dc3545;
}

/* Card Header - Icon, Title, and Score Badge */
.test-card-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    justify-content: space-between;
}

.test-card-info {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    flex: 1;
}

.test-card-icon {
    width: 60px;
    height: 60px;
    background: #f0f7ff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #2878EB;
    overflow: hidden;
    /* Ensure images stay within bounds */
}

/* Subject Gradients */
.test-card-icon.glossa {
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.05) 0%, rgba(40, 167, 69, 0.15) 100%);
}

.test-card-icon.math {
    background: linear-gradient(135deg, rgba(40, 120, 235, 0.05) 0%, rgba(40, 120, 235, 0.15) 100%);
}

.test-card-icon.combo {
    background: linear-gradient(135deg, rgba(111, 66, 193, 0.05) 0%, rgba(111, 66, 193, 0.15) 100%);
}

.subject-icon {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
}

.test-card-icon--combo {
    flex-wrap: wrap;
    padding: 2px;
}

.test-card-icon--combo .subject-icon {
    max-width: 45%;
    max-height: 45%;
}

.test-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.test-details h4 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.test-meta {
    font-size: 0.875rem;
    color: #6c757d;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 4px;
}

.test-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.test-meta i {
    color: #9ca3af;
    font-size: 0.85rem;
}

/* Score Badge - Now in header */
.test-card-score {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.score-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: #1a1a1a;
}

.timeline-test-card.score-high .score-value {
    color: #28a745;
}

.timeline-test-card.score-medium .score-value {
    color: #ffc107;
}

.timeline-test-card.score-low .score-value {
    color: #dc3545;
}

.score-percentage {
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 500;
}

/* Badges Section */
.test-card-badges {
    display: none;
    /* Hidden by default in desktop, shown in mobile */
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.badge-performance {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-performance.high {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-performance.medium {
    background: #fff8e1;
    color: #f57f17;
}

.badge-performance.low {
    background: #ffebee;
    color: #c62828;
}

/* Performance badge in title (desktop only) */
.badge-performance-inline {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-performance-inline.high {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-performance-inline.medium {
    background: #fff8e1;
    color: #f57f17;
}

.badge-performance-inline.low {
    background: #ffebee;
    color: #c62828;
}

/* Action Buttons Section */
.test-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 4px;
}

.btn-action-sm {
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Subtle shadow for depth */
}

.btn-review {
    border-color: var(--green);
    color: var(--green);
}

.btn-review:hover {
    background: var(--green);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(40, 120, 235, 0.3);
}

.btn-retry {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-retry:hover {
    background: var(--primary);
    /* Dark gray on hover */
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Retry Incorrect Button */
.btn-retry-incorrect {
    padding: 8px 20px;
    border-radius: 50px;
    border: 1px solid #FF9800;
    /* Use stronger orange for border */
    background: #fff;
    /* White background */
    color: #E65100;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.btn-retry-incorrect:hover {
    background: #FF9800;
    color: white;
    border-color: #FF9800;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.btn-retry-incorrect i {
    font-size: 0.95rem;
}

/* Badge for incorrect count */
.badge-retry-count {
    background: rgba(255, 255, 255, 0.9);
    color: #E65100;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 800;
    margin-left: 2px;
}

.btn-retry-incorrect:hover .badge-retry-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Empty State */
.timeline-empty {
    text-align: center;
    padding: 100px 20px;
    color: #6c757d;
}

.timeline-empty i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

/* Localized Loading Overlay */
.app-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 15px;
}

#testHistoryTimeline {
    position: relative;
    min-height: 400px;
}

/* Responsiveness */
@media (max-width: 768px) {
    .timeline-test-card {
        padding: 20px;
        gap: 14px;
        position: relative;
    }

    .test-card-header {
        /* Block layout - no positioning context so absolute children use card as reference */
        display: block;
    }

    .test-card-info {
        gap: 12px;
        width: 100%;
    }

    /* Hide icon in mobile */
    .test-card-icon {
        display: none;
    }

    /* Hide inline performance badge in mobile */
    .badge-performance-inline {
        display: none;
    }

    /* Hide badges section completely in mobile */
    .test-card-badges {
        display: none;
    }

    /* Floating score badge in mobile - positioned relative to CARD, not header */
    .test-card-score {
        position: absolute !important;
        top: 16px !important;
        right: 16px !important;
        width: auto;
        height: auto;
        margin: 0;
        flex-direction: column;
        align-items: center;
        gap: 0;
        background: #fff;
        padding: 10px 14px;
        border-radius: 12px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
        z-index: 10;
    }

    .score-value {
        font-size: 1.5rem;
        line-height: 1;
        font-weight: 700;
    }

    .test-details {
        width: 100%;
    }

    .test-details h4 {
        font-size: 1.05rem;
        line-height: 1.4;
        padding-right: 70px;
        /* Space for floating badge - only on title */
    }

    /* Make metadata a grid in mobile */
    .test-meta {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 12px;
    }

    .test-card-actions {
        width: 100%;
    }

    .btn-action-sm {
        flex: 1;
        min-width: 0;
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .test-card-actions {
        flex-direction: column;
    }

    .btn-action-sm {
        width: 100%;
    }
}

/* Load More Button */
.btn-load-more {
    background: transparent;
    border: 2px solid #2878EB;
    color: #2878EB;
    padding: 10px 30px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.btn-load-more:hover {
    background: #2878EB;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 120, 235, 0.25);
}

.btn-load-more:active {
    transform: translateY(0);
}

.btn-load-more:disabled {
    border-color: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    background: #f8fafc;
    transform: none;
    box-shadow: none;
}