/**
 * CodeFit Exam System Styles
 * Professional, Developer-tool aesthetic
 */

/* ========== Exam Container ========== */
.cf-exam-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ========== Exam Selection ========== */
.cf-exam-selection {
    text-align: center;
    padding: 3rem;
}

.cf-exam-selection h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.cf-exam-subtitle {
    color: var(--cf-text-secondary);
    margin-bottom: 3rem;
}

/* Challenge Type Selection */
.cf-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.cf-type-option {
    cursor: pointer;
}

.cf-type-option input {
    position: absolute;
    opacity: 0;
}

.cf-type-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    background: var(--cf-bg-card);
    border: 2px solid var(--cf-border);
    border-radius: var(--cf-radius-lg);
    transition: all 0.3s ease;
}

.cf-type-option input:checked + .cf-type-box {
    border-color: var(--cf-accent-primary);
    background: rgba(99, 102, 241, 0.1);
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.2);
}

.cf-type-box:hover {
    border-color: var(--cf-accent-secondary);
    transform: translateY(-2px);
}

.cf-type-icon {
    font-size: 3rem;
}

.cf-type-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--cf-text-primary);
}

.cf-type-desc {
    font-size: 0.85rem;
    color: var(--cf-text-muted);
    text-align: center;
}

/* Difficulty Selection */
.cf-difficulty-select {
    margin-bottom: 3rem;
}

.cf-difficulty-select h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--cf-text-secondary);
}

.cf-difficulty-options {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.cf-difficulty-option {
    cursor: pointer;
}

.cf-difficulty-option input {
    position: absolute;
    opacity: 0;
}

.cf-difficulty-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 2rem;
    background: var(--cf-bg-card);
    border: 2px solid var(--cf-border);
    border-radius: var(--cf-radius);
    transition: all 0.3s ease;
    min-width: 140px;
}

.cf-difficulty-option input:checked + .cf-difficulty-box.easy {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.cf-difficulty-option input:checked + .cf-difficulty-box.medium {
    border-color: #facc15;
    background: rgba(250, 204, 21, 0.1);
}

.cf-difficulty-option input:checked + .cf-difficulty-box.hard {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.cf-difficulty-icon {
    font-size: 1.5rem;
}

.cf-difficulty-name {
    font-weight: 700;
    color: var(--cf-text-primary);
}

.cf-difficulty-desc {
    font-size: 0.75rem;
    color: var(--cf-text-muted);
}

/* ========== Exam Interface ========== */
.cf-exam-interface {
    background: var(--cf-bg-card);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius-lg);
    overflow: hidden;
}

.cf-exam-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: var(--cf-bg-secondary);
    border-bottom: 1px solid var(--cf-border);
}

.cf-exam-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.cf-exam-meta {
    display: flex;
    gap: 1rem;
}

.cf-exam-type,
.cf-exam-difficulty {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    background: var(--cf-bg-tertiary);
    color: var(--cf-text-secondary);
}

.cf-exam-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--cf-text-primary);
    padding: 0.75rem 1.5rem;
    background: var(--cf-bg-primary);
    border-radius: var(--cf-radius);
    border: 2px solid var(--cf-border);
}

.cf-exam-timer.warning {
    color: #facc15;
    border-color: #facc15;
}

.cf-exam-timer.danger {
    color: #ef4444;
    border-color: #ef4444;
    animation: pulse-danger 1s infinite;
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.cf-exam-content {
    padding: 2rem;
}

.cf-exam-problem {
    margin-bottom: 2rem;
}

.cf-problem-description {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--cf-text-primary);
    margin-bottom: 1.5rem;
}

.cf-problem-instructions {
    padding: 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--cf-accent-primary);
    border-radius: 0 var(--cf-radius) var(--cf-radius) 0;
    color: var(--cf-text-secondary);
}

/* Code Section */
.cf-exam-code {
    margin-bottom: 2rem;
    border-radius: var(--cf-radius);
    overflow: hidden;
    border: 1px solid var(--cf-border);
}

.cf-code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--cf-bg-tertiary);
    border-bottom: 1px solid var(--cf-border);
}

.cf-code-language {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--cf-text-muted);
}

.cf-code-block {
    margin: 0;
    padding: 1.5rem;
    background: #0d1117;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 400px;
}

.cf-code-block code {
    color: #c9d1d9;
}

/* Answer Section */
.cf-exam-answer h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--cf-text-secondary);
}

.cf-answer-textarea {
    width: 100%;
    min-height: 200px;
    padding: 1.5rem;
    background: var(--cf-bg-secondary);
    border: 2px solid var(--cf-border);
    border-radius: var(--cf-radius);
    color: var(--cf-text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.3s;
}

.cf-answer-textarea:focus {
    outline: none;
    border-color: var(--cf-accent-primary);
}

.cf-answer-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
}

/* ========== Result Display ========== */
.cf-exam-result {
    text-align: center;
    padding: 3rem;
}

.cf-result-header {
    margin-bottom: 3rem;
}

.cf-result-score-circle {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 2rem;
}

.cf-result-score-circle svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.cf-score-bg {
    fill: none;
    stroke: var(--cf-bg-tertiary);
    stroke-width: 8;
}

.cf-score-progress {
    fill: none;
    stroke: var(--cf-accent-primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 1.5s ease-out;
}

.cf-score-progress.passed {
    stroke: #22c55e;
}

.cf-score-progress.failed {
    stroke: #ef4444;
}

.cf-score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 800;
    color: var(--cf-text-primary);
}

.cf-result-title {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.cf-result-status {
    font-size: 1.1rem;
    color: var(--cf-text-secondary);
}

.cf-result-status.passed {
    color: #22c55e;
}

.cf-result-status.failed {
    color: #ef4444;
}

.cf-result-details {
    text-align: left;
    max-width: 600px;
    margin: 0 auto 2rem;
}

.cf-result-breakdown {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--cf-bg-secondary);
    border-radius: var(--cf-radius);
}

.cf-breakdown-item {
    text-align: center;
}

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

.cf-breakdown-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--cf-text-primary);
}

.cf-result-feedback {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--cf-bg-card);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius);
}

.cf-result-feedback h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--cf-text-secondary);
}

.cf-result-feedback p {
    line-height: 1.8;
    color: var(--cf-text-primary);
}

.cf-result-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.cf-result-strengths,
.cf-result-improvements {
    padding: 1.5rem;
    border-radius: var(--cf-radius);
}

.cf-result-strengths {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.cf-result-improvements {
    background: rgba(250, 204, 21, 0.1);
    border: 1px solid rgba(250, 204, 21, 0.3);
}

.cf-result-sections h4 {
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.cf-result-sections ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cf-result-sections li {
    padding: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--cf-text-secondary);
    border-bottom: 1px solid var(--cf-border);
}

.cf-result-sections li:last-child {
    border-bottom: none;
}

.cf-result-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* ========== Loading Overlay ========== */
.cf-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.cf-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--cf-bg-tertiary);
    border-top-color: var(--cf-accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.cf-loading-text {
    margin-top: 1.5rem;
    color: var(--cf-text-secondary);
    font-size: 1rem;
}

/* ========== Leaderboard ========== */
.cf-leaderboard {
    background: var(--cf-bg-card);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius-lg);
    overflow: hidden;
}

.cf-leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: var(--cf-bg-secondary);
    border-bottom: 1px solid var(--cf-border);
}

.cf-leaderboard-header h2 {
    font-size: 1.25rem;
    margin: 0;
}

.cf-leaderboard-table {
    padding: 1rem;
}

.cf-leaderboard-row {
    display: grid;
    grid-template-columns: 60px 1fr 100px 80px 100px;
    align-items: center;
    padding: 1rem;
    border-radius: var(--cf-radius);
    transition: background 0.2s;
}

.cf-leaderboard-row:hover:not(.cf-leaderboard-header-row) {
    background: var(--cf-bg-secondary);
}

.cf-leaderboard-header-row {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--cf-text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.cf-leaderboard-row.cf-top-1 {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 215, 0, 0.05) 100%);
}

.cf-leaderboard-row.cf-top-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.1) 0%, rgba(192, 192, 192, 0.05) 100%);
}

.cf-leaderboard-row.cf-top-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.1) 0%, rgba(205, 127, 50, 0.05) 100%);
}

.cf-lb-rank {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
}

.cf-lb-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cf-lb-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.cf-lb-name {
    font-weight: 600;
    color: var(--cf-text-primary);
}

.cf-lb-role {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 50px;
    margin-left: 0.5rem;
}

.cf-lb-role.developer {
    background: rgba(34, 211, 238, 0.2);
    color: #22d3ee;
}

.cf-lb-role.designer {
    background: rgba(244, 114, 182, 0.2);
    color: #f472b6;
}

.cf-lb-role.pm {
    background: rgba(250, 204, 21, 0.2);
    color: #facc15;
}

.cf-lb-challenges,
.cf-lb-avg,
.cf-lb-total {
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
}

.cf-lb-total {
    font-weight: 700;
    color: var(--cf-accent-primary);
}

.cf-leaderboard-empty {
    text-align: center;
    padding: 3rem;
    color: var(--cf-text-muted);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .cf-exam-container {
        padding: 1rem;
    }

    .cf-exam-header {
        flex-direction: column;
        gap: 1rem;
    }

    .cf-exam-content {
        padding: 1rem;
    }

    .cf-type-grid {
        grid-template-columns: 1fr;
    }

    .cf-difficulty-options {
        flex-direction: column;
        align-items: center;
    }

    .cf-result-sections {
        grid-template-columns: 1fr;
    }

    .cf-leaderboard-row {
        grid-template-columns: 50px 1fr 60px;
    }

    .cf-lb-avg,
    .cf-lb-challenges {
        display: none;
    }
}
