/* ============================================
   ANALYTICS & HISTORY PAGE STYLES
   ============================================ */

/* ---------- OVERLAY ---------- */
.analytics-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
    background: var(--bg-primary);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
    will-change: transform, opacity;
}

.analytics-overlay.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

/* Ambient background */


/* Content wrapper */
.analytics-overlay-content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        var(--bg-primary) 30%,
        var(--bg-primary) 100%
    );
}

/* ---------- TOP BAR ---------- */
.analytics-top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: calc(var(--safe-top) + 8px) 16px 8px 16px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.analytics-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    position: relative;
    z-index: 3;
    pointer-events: auto;
}

.analytics-back-btn:hover {
    background-color: var(--bg-hover);
}

.analytics-back-btn:active {
    background-color: var(--bg-active);
}

.analytics-back-btn .material-icons-round {
    font-size: 2rem;    color: var(--text-primary);
    pointer-events: none;
}

.analytics-top-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* ---------- SCROLLABLE CONTENT ---------- */
.analytics-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 32px 24px;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

/* ---------- METRICS SECTION ---------- */
.metrics-section {
    margin-bottom: 32px;
}

.metrics-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--divider-color);
    border-radius: 12px;
    transition: all var(--transition-fast);
}

.metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.metric-icon .material-icons-round {
    font-size: 1.75rem;    color: var(--text-primary);
}

.metric-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-label {
    font-size: 1rem;
    color: var(--text-tertiary);
}

/* ---------- HISTORY SECTION ---------- */
.history-section {
    margin-bottom: 24px;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.history-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.history-count {
    font-size: 0.95rem;
    color: var(--text-tertiary);
}

.history-table {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 16px;
}

/* History item */
.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--divider-color);
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    font-family: 'Poppins', sans-serif;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    background: var(--bg-surface-light);
}

.history-item:active {
    background: var(--bg-hover);
}

.history-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}

.history-item-icon .material-icons-round {
    font-size: 1.75rem;    color: #ffffff;
    pointer-events: none;
}

.history-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    pointer-events: none;
}

.history-item-subject {
    font-size: 0.86rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.history-item-date {
    font-size: 0.84rem;
    color: var(--text-tertiary);
    pointer-events: none;
}

/* Score badge */
.history-item-score {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
    pointer-events: none;
}

.history-item-score.excellent {
    background: rgba(76, 175, 80, 0.15);
    color: #4caf50;
}

.history-item-score.good {
    background: rgba(33, 150, 243, 0.15);
    color: #2196f3;
}

.history-item-score.average {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
}

.history-item-score.poor {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
}

/* Load more button */
.load-more-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    transition: all var(--transition-fast);
    margin: 0 auto;
}

.load-more-btn:hover {
    background: var(--bg-hover);
}

.load-more-btn .material-icons-round {
    font-size: 1.75rem;    pointer-events: none;
}

/* ---------- LOADING STATE ---------- */
.analytics-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px;
    color: var(--text-secondary);
}

.analytics-loading .material-icons-round {
    font-size: 3.5rem;    color: var(--accent-color);
    animation: pulse 1.5s ease infinite;
}

/* ---------- DESKTOP LAYOUT ---------- */
@media (min-width: 711px) {
    .analytics-scroll {
        margin: 0 auto;
        width: 100%;
        padding: 0 48px 32px 48px;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .history-item {
        padding: 14px 8px;
        border-radius: 6px;
    }
    
    .history-item:hover {
        padding-left: 12px;
    }
}

/* Tablet */
@media (min-width: 711px) and (max-width: 1024px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---------- MOBILE RESPONSIVE ---------- */
@media (max-width: 710px) {
    .analytics-scroll {
        padding: 0 .5rem 24px .5rem;
    }
    
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .metric-card {
        padding: 12px;
        gap: 8px;
    }
    
    .metric-icon {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }
    
    .metric-value {
        font-size: 1.25rem;
    }
    
    .metric-label {
        font-size: .9rem;
    }
    
    .history-item {
        padding: 10px 2px;
        gap: 8px;
    }
    
    .history-item-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
    
    .history-item-title {
        font-size: 0.95rem;
    }
    
    .history-item-score {
        min-width: 40px;
        padding: 3px 8px;
        font-size: 0.85rem;
    }
}