/* =============================================================================
   LD Quiz Retake — Progress Dashboard
   ============================================================================= */

/* ─── Reset / Base ─────────────────────────────────────────────────────────── */

.ldrq-progress-dashboard,
.ldrq-progress-dashboard * {
    box-sizing: border-box;
}

.ldrq-progress-dashboard {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 15px;
    color: #1e293b;
    line-height: 1.5;
}

.ldrq-login-notice {
    color: #64748b;
    font-style: italic;
}

/* ─── States (loading / error / empty) ─────────────────────────────────────── */

.ldrq-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 56px 24px;
    border-radius: 14px;
    text-align: center;
    background: #f8fafc;
    border: 2px dashed #e2e8f0;
    color: #64748b;
}

.ldrq-error-state {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.ldrq-empty-state h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #334155;
}

.ldrq-empty-state p {
    margin: 0;
}

.ldrq-empty-icon {
    font-size: 52px;
    line-height: 1;
}

/* Loading placeholder rendered by PHP before React hydrates */
.ldrq-loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 56px 24px;
    gap: 14px;
    color: #64748b;
}

.ldrq-loading-placeholder p {
    margin: 0;
}

/* Spinner */
.ldrq-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: ldrq-spin 0.75s linear infinite;
}

@keyframes ldrq-spin {
    to { transform: rotate( 360deg ); }
}

/* ─── Dashboard layout ──────────────────────────────────────────────────────── */

.ldrq-dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.ldrq-dashboard-header {
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 14px;
}

.ldrq-dashboard-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

/* ─── Stats bar ─────────────────────────────────────────────────────────────── */

.ldrq-stats-bar {
    display: grid;
    grid-template-columns: repeat( auto-fit, minmax( 160px, 1fr ) );
    gap: 16px;
}

.ldrq-stat-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 22px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.06 );
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ldrq-stat-card:hover {
    box-shadow: 0 6px 18px rgba( 0, 0, 0, 0.1 );
    transform: translateY( -2px );
}

.ldrq-stat-icon {
    font-size: 30px;
    line-height: 1;
}

.ldrq-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1e293b;
}

.ldrq-stat-label {
    font-size: 0.75rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.ldrq-stat-pos .ldrq-stat-value { color: #10b981; }
.ldrq-stat-neg .ldrq-stat-value { color: #ef4444; }

/* ─── Generic section card ──────────────────────────────────────────────────── */

.ldrq-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.06 );
}

.ldrq-section-title {
    margin: 0 0 20px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
}

/* ─── Overall chart ─────────────────────────────────────────────────────────── */

.ldrq-overall-section .ldrq-chart-container {
    position: relative;
    height: 320px;
}

/* ─── Quiz summary table ────────────────────────────────────────────────────── */

.ldrq-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.ldrq-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 700px;
}

.ldrq-table thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    user-select: none;
}

.ldrq-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

/* Clickable quiz row */
.ldrq-quiz-row {
    cursor: pointer;
    transition: background 0.15s ease;
}

.ldrq-quiz-row:hover {
    background: #f8fafc;
}

.ldrq-row-expanded {
    background: #eef2ff !important;
}

.ldrq-quiz-name {
    font-weight: 600;
    color: #1e293b;
    max-width: 260px;
}

.ldrq-td-center {
    text-align: center;
}

/* Score colours */
.ldrq-pos {
    color: #10b981;
    font-weight: 600;
}

.ldrq-neg {
    color: #ef4444;
    font-weight: 600;
}

.ldrq-neutral {
    color: #94a3b8;
}

/* Trend cell */
.ldrq-trend-cell {
    font-size: 1.1rem;
    font-weight: 700;
}

.ldrq-trend-up   { color: #10b981; }
.ldrq-trend-down { color: #ef4444; }
.ldrq-trend-same { color: #94a3b8; }

/* Expand / collapse button */
.ldrq-expand-btn {
    background: transparent;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 5px 12px;
    cursor: pointer;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ldrq-expand-btn:hover {
    background: #6366f1;
    color: #ffffff;
    border-color: #6366f1;
}

/* ─── Badges ────────────────────────────────────────────────────────────────── */

.ldrq-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.ldrq-badge-green { background: #d1fae5; color: #065f46; }
.ldrq-badge-red   { background: #fee2e2; color: #991b1b; }
.ldrq-badge-blue  { background: #dbeafe; color: #1e40af; }

/* ─── Detail row ────────────────────────────────────────────────────────────── */

.ldrq-detail-row > td {
    background: #f8fafc;
    padding: 0 !important;
    border-bottom: 2px solid #e2e8f0;
}

.ldrq-quiz-detail {
    padding: 24px;
}

.ldrq-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media ( max-width: 800px ) {
    .ldrq-detail-grid {
        grid-template-columns: 1fr;
    }
}

.ldrq-panel-title {
    margin: 0 0 14px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Per-quiz chart */
.ldrq-detail-chart-container {
    position: relative;
    height: 230px;
}

/* Single-attempt notice */
.ldrq-tip-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: #fef9c3;
    border: 1px solid #fde68a;
    border-radius: 10px;
    color: #854d0e;
    font-size: 0.875rem;
}

/* Inner attempt-history table */
.ldrq-inner-table-wrap {
    overflow-y: auto;
    max-height: 290px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.ldrq-inner-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.ldrq-inner-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    white-space: nowrap;
}

.ldrq-inner-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #334155;
}

.ldrq-inner-table tbody tr:last-child td {
    border-bottom: none;
}

.ldrq-inner-table tbody tr:hover {
    background: #f8fafc;
}

/* ─── Score bar ─────────────────────────────────────────────────────────────── */

.ldrq-score-bar-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ldrq-score-bar-track {
    flex: 1;
    background: #e2e8f0;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    min-width: 80px;
}

.ldrq-score-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.ldrq-score-bar-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
    min-width: 46px;
    text-align: right;
    flex-shrink: 0;
}

/* ─── Responsive tweaks ─────────────────────────────────────────────────────── */

@media ( max-width: 600px ) {
    .ldrq-stats-bar {
        grid-template-columns: 1fr 1fr;
    }

    .ldrq-dashboard-title {
        font-size: 1.2rem;
    }

    .ldrq-section {
        padding: 16px;
    }
}