/* CSS Stylesheet for Computing Science Grade 6 Interactive Drag-and-Drop Worksheet */

:root {
    --primary-color: #3b82f6;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    
    --q1-color: #2563eb;
    --q1-bg: #f0f6ff;
    --q2-color: #7c3aed;
    --q2-bg: #f5f3ff;
    --q3-color: #0d9488;
    --q3-bg: #f0fdfa;

    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-text: #1e293b;
    --light-text: #64748b;
    --border-color: #e2e8f0;
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Prompt', 'Sarabun', sans-serif;
    background: var(--bg-gradient);
    color: var(--dark-text);
    min-height: 100vh;
    padding-bottom: 40px;
}

/* Action Toolbar (Bottom Floating Bar) */
.action-bar {
    position: sticky;
    bottom: 15px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    padding: 14px 24px;
    margin-top: 25px;
}

.action-bar-container {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand i {
    font-size: 1.4rem;
    color: var(--primary-color);
}

.btn-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn {
    font-family: 'Prompt', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
}

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

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
}

.btn-submit { background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff; }
.submit-status { max-width: 1100px; margin: 0 auto 10px; text-align: center; font-weight: 600; min-height: 24px; }
.submit-status.success { color: #047857; }
.submit-status.error { color: #b91c1c; }
.submit-status.sending { color: #5b21b6; }
.info-group select { width: 100%; padding: 11px 12px; border: 2px solid #cbd5e1; border-radius: 10px; background: #fff; font-family: 'Prompt', sans-serif; font-size: .95rem; }

/* Worksheet Layout */
.worksheet-wrapper {
    max-width: 1100px;
    margin: 30px auto 0;
    padding: 0 15px;
}

.worksheet-card {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    padding: 40px;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

/* Header Section */
.worksheet-header {
    text-align: center;
    margin-bottom: 35px;
    position: relative;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 12px;
}

.worksheet-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark-text);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.worksheet-subtitle {
    font-size: 1.05rem;
    color: var(--light-text);
    margin-bottom: 25px;
}

/* Student Info Box (3 Members Support) */
.student-info-box {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 25px;
    text-align: left;
}

.student-info-header {
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1.5px dashed #cbd5e1;
}

.member-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.member-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.member-badge {
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    margin-right: 4px;
}

.member-name {
    flex: 2;
    min-width: 280px;
}

.info-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 250px;
}

.info-group.info-short {
    flex: 0 1 180px;
    min-width: 140px;
}

.info-group label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--dark-text);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-group input {
    width: 100%;
    font-family: 'Prompt', sans-serif;
    font-size: 1rem;
    padding: 8px 14px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: var(--dark-text);
    transition: border-color 0.2s ease;
}

.info-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Instructions Box */
.instructions-box {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: #eff6ff;
    border-left: 4px solid var(--primary-color);
    padding: 16px 20px;
    border-radius: 12px;
    text-align: left;
    font-size: 0.95rem;
    color: #1e3a8a;
    line-height: 1.6;
}

.instruction-icon {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-top: 2px;
}

/* Score Banner */
.score-banner {
    margin-top: 25px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 2px solid #34d399;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    animation: fadeIn 0.4s ease-out;
}

.score-banner.hidden {
    display: none;
}

.score-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #10b981;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

.score-details h3 {
    font-size: 1.25rem;
    color: #065f46;
    margin-bottom: 4px;
}

.score-details p {
    font-size: 1.1rem;
    font-weight: 600;
    color: #047857;
}

.score-feedback {
    font-size: 0.95rem;
    color: #065f46;
    margin-top: 4px;
}

/* Question Section Styles */
.question-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 35px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.question-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: #ffffff;
}

.q1-theme {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

.q2-theme {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
}

.q3-theme {
    background: linear-gradient(135deg, #0d9488, #0f766e);
}

.q-number {
    background: rgba(255, 255, 255, 0.25);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 4px 14px;
    border-radius: 20px;
    letter-spacing: 0.5px;
}

.question-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.question-body {
    padding: 24px;
}

.scenario-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 18px;
    font-size: 0.98rem;
    line-height: 1.6;
    margin-bottom: 24px;
    color: #334155;
}

.scenario-box i {
    color: var(--primary-color);
}

/* Drag Workspace Grid */
.drag-workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

@media (max-width: 850px) {
    .action-bar-container { flex-direction: column; align-items: stretch; gap: 10px; }
    .brand { justify-content: center; }
    .btn-group { justify-content: center; }
    .btn { flex: 1 1 145px; justify-content: center; }
    .drag-workspace {
        grid-template-columns: 1fr;
    }
}

/* Program Drop Area (Left) */
.program-container, .pool-container {
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 14px;
    padding: 18px;
}

.program-title, .pool-title {
    font-weight: 700;
    font-size: 1rem;
    color: #334155;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 2px dashed #cbd5e1;
}

.drop-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drop-slot-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.drop-slot {
    flex: 1;
    min-height: 48px;
    background: #ffffff;
    border: 2px dashed #94a3b8;
    border-radius: 10px;
    display: flex;
    align-items: center;
    padding: 6px 12px;
    transition: all 0.2s ease;
    position: relative;
}

.drop-slot.drag-over {
    border-color: var(--primary-color);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.slot-placeholder {
    color: #94a3b8;
    font-size: 0.88rem;
    font-style: italic;
    pointer-events: none;
}

/* Loop & Condition Special Visual Boxes */
.loop-container {
    border: 2px dashed #a855f7;
    background: #faf5ff;
    border-radius: 12px;
    padding: 12px;
    margin: 4px 0;
}

.loop-header-slot {
    border-color: #c084fc;
    background: #ffffff;
}

.loop-body {
    margin-left: 20px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left: 3px solid #c084fc;
    padding-left: 12px;
}

.loop-indent-label, .indent-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #7e22ce;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.condition-container {
    border: 2px dashed #14b8a6;
    background: #f0fdfa;
    border-radius: 12px;
    padding: 12px;
    margin: 4px 0;
}

.condition-header-slot, .condition-else-slot {
    border-color: #2dd4bf;
}

.condition-true-body, .condition-false-body {
    margin-left: 20px;
    margin-top: 8px;
    margin-bottom: 8px;
    padding-left: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.condition-true-body {
    border-left: 3px solid #10b981;
}

.condition-false-body {
    border-left: 3px solid #f43f5e;
}

.condition-true-body .indent-label {
    color: #047857;
}

.condition-false-body .indent-label {
    color: #be123c;
}

/* Command Cards (Draggable Items) */
.items-pool {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
}

.cmd-card {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1e293b;
    cursor: grab;
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    width: 100%;
}

.cmd-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
}

.cmd-card:active {
    cursor: grabbing;
}

.cmd-card.selected {
    border-color: var(--primary-color);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.cmd-card.dragging {
    opacity: 0.5;
}

.cmd-card .drag-handle {
    color: #94a3b8;
    font-size: 0.85rem;
}

.drop-slot .cmd-card {
    border-style: solid;
    margin: 0;
    box-shadow: none;
}

/* Validation Feedback Styles */
.drop-slot.correct {
    border-color: #10b981;
    background: #ecfdf5;
}

.drop-slot.correct .cmd-card {
    border-color: #10b981;
    background: #d1fae5;
    color: #065f46;
}

.drop-slot.incorrect {
    border-color: #ef4444;
    background: #fef2f2;
}

.drop-slot.incorrect .cmd-card {
    border-color: #ef4444;
    background: #fee2e2;
    color: #991b1b;
}

.feedback-tag {
    position: absolute;
    right: 10px;
    font-size: 1.1rem;
}

.drop-slot.correct .feedback-tag::after {
    content: "✓";
    color: #10b981;
    font-weight: bold;
}

.drop-slot.incorrect .feedback-tag::after {
    content: "✕";
    color: #ef4444;
    font-weight: bold;
}

/* Footer Section */
.worksheet-footer {
    margin-top: 30px;
}

.footer-line {
    height: 2px;
    background: #e2e8f0;
    margin-bottom: 12px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #94a3b8;
}

/* Print & PDF Export Specific Styles */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: #ffffff;
        padding: 0;
    }

    .worksheet-wrapper {
        margin: 0;
        padding: 0;
        max-width: 100%;
    }

    .worksheet-card {
        box-shadow: none;
        border: none;
        padding: 15px;
    }

    .info-group input {
        border: none;
        border-bottom: 1px solid #000;
        border-radius: 0;
        padding: 2px 5px;
    }

    .question-card {
        break-inside: avoid;
        margin-bottom: 20px;
    }

    .drag-workspace {
        grid-template-columns: 1fr;
    }

    .pool-container {
        display: none !important;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dynamic PDF Generation Optimizations */
body.pdf-export-active {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
}

body.pdf-export-active .worksheet-wrapper {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.pdf-export-active .worksheet-card {
    box-shadow: none !important;
    border: none !important;
    padding: 10px 15px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

body.pdf-export-active .action-bar {
    display: none !important;
}

body.pdf-export-active .question-card {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-bottom: 22px !important;
}

body.pdf-export-active .student-info-box {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    padding: 12px 16px !important;
}

body.pdf-export-active .info-group input {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
    font-weight: 600 !important;
}

body.pdf-export-active .cmd-card {
    font-size: 0.9rem !important;
    padding: 8px 10px !important;
}

body.pdf-export-active .drop-slot {
    min-height: 42px !important;
}
