/* ===========================================
   Component Styles for Interactive Elements
   =========================================== */

/* ===========================================
   Code Display
   =========================================== */

.code-display {
    background: var(--gray-800);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin: var(--space-md) 0;
}

.code-header {
    background: var(--gray-700);
    padding: var(--space-sm) var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-filename {
    color: var(--gray-300);
    font-size: 0.875rem;
    font-family: var(--font-mono);
}

.code-content {
    padding: var(--space-md);
    margin: 0;
    overflow-x: auto;
}

.code-content code {
    background: none;
    padding: 0;
}

/* Line numbers */
.code-with-lines {
    display: table;
    width: 100%;
}

.code-line {
    display: table-row;
}

.code-line:hover {
    background: rgba(255, 255, 255, 0.05);
}

.line-number {
    display: table-cell;
    text-align: right;
    padding-right: var(--space-md);
    color: var(--gray-500);
    user-select: none;
    width: 3ch;
}

.line-content {
    display: table-cell;
    white-space: pre;
}

/* Syntax highlighting (basic) */
.syntax-keyword { color: #ff79c6; }
.syntax-string { color: #f1fa8c; }
.syntax-number { color: #bd93f9; }
.syntax-comment { color: #6272a4; }
.syntax-function { color: #50fa7b; }
.syntax-variable { color: #f8f8f2; }

/* ===========================================
   Parsons Problem Component
   =========================================== */

.parsons-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    margin: var(--space-lg) 0;
}

.parsons-header {
    margin-bottom: var(--space-lg);
}

.parsons-instructions {
    background: var(--primary-light);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.parsons-expected-output {
    background: var(--gray-100);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.parsons-expected-output h4 {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: var(--space-sm);
}

.parsons-workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

@media (max-width: 768px) {
    .parsons-workspace {
        grid-template-columns: 1fr;
    }
}

.parsons-source,
.parsons-solution {
    min-height: 200px;
}

.parsons-source h4,
.parsons-solution h4 {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.parsons-blocks {
    background: var(--gray-100);
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-md);
    min-height: 180px;
    padding: var(--space-sm);
}

.parsons-solution .parsons-blocks {
    background: var(--success-light);
    border-color: var(--success);
}

.parsons-block {
    background: white;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    margin: var(--space-sm);
    cursor: grab;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    user-select: none;
}

.parsons-block:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.parsons-block.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.parsons-block.over {
    border-color: var(--primary);
    border-style: dashed;
}

/* Indentation for 2D Parsons */
.parsons-block[data-indent="1"] {
    margin-left: calc(var(--space-sm) + 2rem);
}

.parsons-block[data-indent="2"] {
    margin-left: calc(var(--space-sm) + 4rem);
}

/* Distractor blocks - no visual difference (students shouldn't know which are distractors) */
.parsons-block.distractor {
    /* Same styling as regular blocks */
}

/* Feedback */
.parsons-feedback {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-top: var(--space-md);
    display: none;
}

.parsons-feedback.show {
    display: block;
}

.parsons-feedback.correct {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}

.parsons-feedback.incorrect {
    background: var(--error-light);
    color: var(--error);
    border: 1px solid var(--error);
}

.parsons-controls {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* ===========================================
   Code Tracing Component
   =========================================== */

.tracing-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    margin: var(--space-lg) 0;
}

.tracing-code {
    margin-bottom: var(--space-lg);
}

.tracing-code .code-line.active {
    background: rgba(37, 99, 235, 0.2);
}

.tracing-code .code-line.executed {
    background: rgba(22, 163, 74, 0.1);
}

.trace-table-container {
    overflow-x: auto;
    margin: var(--space-lg) 0;
}

.trace-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.trace-table th,
.trace-table td {
    border: 1px solid var(--gray-300);
    padding: var(--space-sm) var(--space-md);
    text-align: center;
}

.trace-table th {
    background: var(--gray-100);
    font-weight: 600;
}

.trace-table td {
    background: white;
}

.trace-table td.output-cell {
    background: var(--warning-light);
}

.trace-table tr.current-step {
    background: var(--primary-light);
}

.trace-table tr.completed-step td {
    background: var(--success-light);
}

.trace-table input {
    width: 100%;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: var(--space-xs);
    font-family: var(--font-mono);
    text-align: center;
}

.trace-table input:focus {
    border-color: var(--primary);
    outline: none;
}

.trace-table input.correct {
    border-color: var(--success);
    background: var(--success-light);
}

.trace-table input.incorrect {
    border-color: var(--error);
    background: var(--error-light);
}

.tracing-controls {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    flex-wrap: wrap;
}

.step-indicator {
    color: var(--gray-600);
    font-size: 0.9rem;
}

/* ===========================================
   Prediction Quiz Component
   =========================================== */

.prediction-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    margin: var(--space-lg) 0;
}

.prediction-question {
    margin-bottom: var(--space-lg);
}

.prediction-question h3 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.prediction-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.prediction-option {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--gray-50);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.prediction-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.prediction-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.prediction-option.correct {
    border-color: var(--success);
    background: var(--success-light);
}

.prediction-option.incorrect {
    border-color: var(--error);
    background: var(--error-light);
}

.prediction-option input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
}

.prediction-option label {
    flex: 1;
    cursor: pointer;
    font-family: var(--font-mono);
}

.prediction-explanation {
    margin-top: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    display: none;
}

.prediction-explanation.show {
    display: block;
}

.prediction-explanation.correct {
    background: var(--success-light);
    border: 1px solid var(--success);
}

.prediction-explanation.incorrect {
    background: var(--error-light);
    border: 1px solid var(--error);
}

/* ===========================================
   Worked Example Component
   =========================================== */

.worked-example-container {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    margin: var(--space-lg) 0;
}

.worked-example-problem {
    background: var(--primary-light);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}

.subgoal {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    overflow: hidden;
}

.subgoal-header {
    background: var(--gray-100);
    padding: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
}

.subgoal-number {
    background: var(--primary);
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.subgoal-label {
    font-weight: 600;
    color: var(--gray-800);
}

.subgoal-content {
    padding: var(--space-md);
    display: none;
}

.subgoal.active .subgoal-content {
    display: block;
}

.subgoal-code {
    background: var(--gray-800);
    color: #f8f8f2;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    margin-bottom: var(--space-md);
}

.subgoal-explanation {
    background: var(--gray-50);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
}

.worked-example-complete {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--gray-200);
}

.worked-example-complete h4 {
    margin-bottom: var(--space-md);
}

/* ===========================================
   Activity Card (for topic pages)
   =========================================== */

.activity-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.activity-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    transition: all var(--transition-fast);
}

.activity-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.activity-card-icon {
    font-size: 1.5rem;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: var(--radius-md);
}

.activity-card-content {
    flex: 1;
}

.activity-card-content h4 {
    margin: 0 0 var(--space-xs);
    color: var(--gray-900);
}

.activity-card-content p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.activity-card-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.status-badge {
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.not-started {
    background: var(--gray-100);
    color: var(--gray-600);
}

.status-badge.in-progress {
    background: var(--warning-light);
    color: var(--warning);
}

.status-badge.completed {
    background: var(--success-light);
    color: var(--success);
}

/* Difficulty indicator */
.difficulty-badge {
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.difficulty-badge.foundation {
    background: #dbeafe;
    color: #1e40af;
}

.difficulty-badge.core {
    background: #dcfce7;
    color: #166534;
}

.difficulty-badge.extension {
    background: #f3e8ff;
    color: #7c3aed;
}

/* ===========================================
   Hints System
   =========================================== */

.hints-container {
    margin-top: var(--space-md);
}

.hint-button {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid var(--warning);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    transition: all var(--transition-fast);
}

.hint-button:hover {
    background: var(--warning);
    color: white;
}

.hint-content {
    background: var(--warning-light);
    border: 1px solid var(--warning);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-sm);
    display: none;
}

.hint-content.show {
    display: block;
}

.hints-remaining {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-left: var(--space-sm);
}

/* ===========================================
   Breadcrumb Navigation
   =========================================== */

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) 0;
    font-size: 0.875rem;
}

.breadcrumb a {
    color: var(--gray-600);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb-separator {
    color: var(--gray-400);
}

.breadcrumb-current {
    color: var(--gray-800);
    font-weight: 500;
}

/* ===========================================
   Topic Page Header
   =========================================== */

.topic-header {
    background: linear-gradient(135deg, var(--primary-light) 0%, white 100%);
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-xl);
}

.topic-header h1 {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.topic-header-icon {
    font-size: 2.5rem;
}

.topic-objectives {
    background: white;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-top: var(--space-md);
}

.topic-objectives h3 {
    font-size: 1rem;
    margin-bottom: var(--space-sm);
}

.topic-objectives ul {
    margin: 0;
    padding-left: var(--space-lg);
}

.topic-objectives li {
    margin-bottom: var(--space-xs);
}

/* ===========================================
   Certificate System
   =========================================== */

.certificate-available {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    margin-top: var(--space-lg);
    border: 2px solid #22c55e;
}

.cert-badge {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.cert-icon {
    font-size: 2rem;
}

.cert-text {
    font-weight: bold;
    color: #16a34a;
    font-size: 1.1rem;
}

.btn-success {
    background: #22c55e;
    color: white;
    border: none;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-success:hover {
    background: #16a34a;
    transform: translateY(-2px);
}

/* Certificate Modal */
.certificate-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-md);
}

.certificate-modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 500px;
    width: 100%;
    position: relative;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-400);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--gray-600);
}

.modal-section h2 {
    margin-top: 0;
    color: var(--primary);
}

.student-form {
    margin-top: var(--space-lg);
}

.student-form .form-group {
    margin-bottom: var(--space-md);
}

.student-form label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    color: var(--gray-700);
}

.student-form input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.student-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.certificate-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    flex-wrap: wrap;
}

/* Certificate Toast */
.certificate-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #22c55e;
    color: white;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    box-shadow: var(--shadow-lg);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    z-index: 1001;
}

.certificate-toast.show {
    transform: translateX(0);
}

.toast-icon {
    font-size: 1.5rem;
}

.toast-message {
    font-weight: 500;
}

/* Teacher Inspection Page */
.teacher-dashboard {
    max-width: 1000px;
    margin: 0 auto;
}

.student-info-card {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    padding: var(--space-xl);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-xl);
    border: 2px solid #3b82f6;
}

.student-info-card h2 {
    margin-top: 0;
    color: #1e40af;
}

.student-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.detail-item {
    background: white;
    padding: var(--space-md);
    border-radius: var(--radius-md);
}

.detail-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: var(--space-xs);
}

.detail-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--gray-800);
}

.certificates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
}

.certificate-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    border-left: 4px solid #22c55e;
    transition: transform 0.2s;
}

.certificate-card:hover {
    transform: translateY(-4px);
}

.certificate-card h4 {
    margin-top: 0;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.certificate-card .cert-date {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: var(--space-sm);
}

.certificate-card .cert-id {
    color: var(--gray-400);
    font-size: 0.75rem;
    font-family: var(--font-mono);
    margin-top: var(--space-xs);
}

.no-certificates {
    text-align: center;
    padding: var(--space-2xl);
    background: var(--gray-50);
    border-radius: var(--radius-lg);
}

.no-certificates-icon {
    font-size: 4rem;
    margin-bottom: var(--space-md);
}

.export-buttons {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
    flex-wrap: wrap;
}

.btn-outline {
    background: white;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-danger-outline {
    background: white;
    border: 2px solid #ef4444;
    color: #ef4444;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger-outline:hover {
    background: #ef4444;
    color: white;
}
