/* Submit Form - Friendly & Engaging Design */

/* ============================================
   STEP INDICATOR
   ============================================ */
.step-indicator {
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    padding: 6px 16px;
    background: var(--primary-bg);
    border-radius: 20px;
    display: inline-block;
    width: auto;
    margin-left: auto;
    margin-right: auto;
}

#course-evaluation-title {
    margin-top: 0 !important;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* Center the step indicator */
#submit-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#submit-container > * {
    width: 100%;
}

#submit-container > .step-indicator {
    width: auto;
}

/* Zero-scroll: fixed header elements */
.step-indicator,
#course-evaluation-title,
.subtitle {
    flex-shrink: 0;
}

/* Hide subtitle on later steps for small screens to reclaim space */
@media (max-height: 700px) {
    .hide-subtitle .subtitle {
        display: none;
    }

    .hide-subtitle #course-evaluation-title {
        font-size: 1.3rem !important;
        margin-bottom: 8px !important;
    }
}

/* Zero-scroll: step sections fill remaining space */
#email-section,
#course-selection,
#grade-forms,
#success-message {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Step transition animation */
.step-fade-in {
    animation: stepFadeIn 0.35s ease-out;
}

@keyframes stepFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   EMAIL SECTION - First impression matters!
   ============================================ */
.email-lookup-field {
    background: linear-gradient(135deg, var(--primary-bg) 0%, #FFF3E0 100%);
    padding: 40px 32px;
    border-radius: var(--radius-lg);
    border: none;
    text-align: center;
}

.email-lookup-field h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 1.25rem;
}

.intro-text {
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.6;
    font-size: 0.95rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

#email-lookup-form {
    max-width: 380px;
    margin: 0 auto;
}

.email-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-normal);
    box-sizing: border-box;
    text-align: center;
    background: white;
}

.email-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg), var(--shadow-md);
}

.email-input:valid:not(:placeholder-shown) {
    border-color: var(--success);
}

.email-input:invalid:not(:placeholder-shown):not(:focus) {
    border-color: var(--error);
}

/* ============================================
   COURSE SELECTION - Make it feel easy
   ============================================ */
.course-selection-card {
    background: linear-gradient(135deg, var(--success-light) 0%, #F1F8E9 100%);
    border: none;
    border-radius: var(--radius-lg);
    padding: 20px;
    animation: celebrateIn 0.5s ease-out;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

@keyframes celebrateIn {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.course-selection-card h3 {
    color: var(--success);
    margin-bottom: 8px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
}

.selection-instruction {
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: center;
    font-weight: 500;
    flex-shrink: 0;
}

.courses-container {
    margin-bottom: 12px;
    border: none;
    border-radius: var(--radius-md);
    background: white;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    box-shadow: var(--shadow-sm);
}

/* Custom scrollbar */
.courses-container::-webkit-scrollbar {
    width: 8px;
}

.courses-container::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: 4px;
}

.courses-container::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

.courses-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.course-summary {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border: none;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin: 16px;
    margin-bottom: 8px;
}

.summary-text {
    margin: 0;
    color: #1565C0;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Course Cards */
.course-card {
    border-bottom: 1px solid var(--border-light);
    padding: 14px 16px;
    transition: all var(--transition-normal);
    cursor: pointer;
    position: relative;
}

.course-card:last-child {
    border-bottom: none;
}

.course-card:hover {
    background: var(--primary-bg);
}

.course-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    transition: background var(--transition-fast);
    border-radius: 0 4px 4px 0;
}

.course-card:has(.course-checkbox:checked)::before {
    background: var(--primary);
}

.course-card:has(.course-checkbox:checked) {
    background: var(--primary-bg);
}

.course-header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.course-checkbox {
    width: 22px;
    height: 22px;
    margin-right: 14px;
    cursor: pointer;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.course-title {
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    margin: 0;
    line-height: 1.4;
}

.course-details {
    margin-left: 36px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
}

.course-info p {
    margin: 4px 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.course-info p strong {
    color: var(--text-primary);
    font-weight: 500;
}

.exam-preview {
    font-size: 0.875rem;
}

.selection-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 12px;
    flex-shrink: 0;
}

.confirm-btn {
    background: linear-gradient(135deg, var(--success) 0%, #388E3C 100%);
    color: white;
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 14px rgba(76, 175, 80, 0.4);
}

.confirm-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.confirm-btn:disabled {
    background: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

/* ============================================
   GRADE FORMS - Keep it simple & rewarding
   ============================================ */
.grade-forms-header {
    text-align: center;
    margin-bottom: 24px;
    padding: 24px;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border-radius: var(--radius-lg);
    border: none;
}

.course-grade-form {
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.course-grade-form:has(.exam-fields:not(.collapsed)) {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.course-form-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 18px 24px;
    transition: padding var(--transition-slow);
    cursor: pointer;
}

.course-form-header:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #A67C00 100%);
}

.course-form-header.collapsed {
    padding: 14px 24px;
}

.course-form-header h3 {
    margin: 0 0 4px 0;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    transition: margin var(--transition-slow);
}

.course-form-header.collapsed h3 {
    margin-bottom: 0;
}

.course-info-header {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.course-period {
    margin: 0;
    transition: opacity var(--transition-slow);
    opacity: 1;
    font-size: 0.875rem;
    color: rgba(255,255,255,0.85);
}

.course-period.hide-delay {
    opacity: 0;
}

/* Collapse Arrow */
.collapse-arrow {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: white;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.collapse-arrow:hover {
    background: rgba(255,255,255,0.3);
}

.collapse-arrow.collapsed {
    transform: rotate(-90deg);
}

.collapse-arrow.expanded {
    transform: rotate(0deg);
}

.arrow-icon {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

/* Exam Fields */
.exam-fields {
    padding: 20px 24px;
    max-height: 1000px;
    overflow: hidden;
    transition: max-height var(--transition-slow), padding var(--transition-slow);
    background: #FAFAFA;
}

.exam-fields.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.exam-item {
    margin: 12px 0;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: white;
    transition: all var(--transition-normal);
}

.exam-item:hover {
    border-color: var(--primary-light);
}

.exam-item:has(.grade-select:not([value=""]):not(:invalid)) {
    border-color: var(--success);
    background: var(--success-light);
}

.exam-code {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.exam-name {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text-secondary);
    font-style: normal;
}

.exam-name-inner {
    flex: 1;
    min-width: 0;
}

.exam-name-inner p {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.exam-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.exam-selects {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Grade Selects - Styled dropdowns */
.grade-select,
.prev-grade-select {
    width: 130px;
    padding: 12px 36px 12px 14px;
    background-color: white;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: all var(--transition-normal);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("../static/arrow_icon_black.svg");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
    box-shadow: none;
}

.grade-select:hover,
.prev-grade-select:hover {
    border-color: var(--primary-light);
}

.grade-select:focus,
.prev-grade-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.grade-select.error,
.prev-grade-select.error {
    border-color: var(--error) !important;
    box-shadow: 0 0 0 3px var(--error-light);
    animation: shake 0.4s ease-in-out;
}

/* Grade Pill Buttons */
.grade-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.grade-pill {
    min-width: 40px;
    height: 40px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grade-pill:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.grade-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(230, 168, 0, 0.3);
}

/* Error state for pill groups (via hidden select sibling) */
.grade-select.error + .grade-pills,
.prev-grade-select.error + .grade-pills {
    animation: shake 0.4s ease-in-out;
}

.grade-select.error + .grade-pills .grade-pill:not(.active),
.prev-grade-select.error + .grade-pills .grade-pill:not(.active) {
    border-color: var(--error);
}

/* Buttons */
.grade-forms-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid var(--border-light);
    flex-shrink: 0;
}

/* Grade forms scrollable area */
#grade-forms-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

#submit-all-grades {
    margin-top: 0;
    padding: 16px 40px;
    font-size: 1.1rem;
}

/* ============================================
   SUCCESS MESSAGE - Celebrate!
   ============================================ */
.success-message {
    display: none;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, var(--success-light) 0%, #C8E6C9 100%);
    color: #2E7D32;
    padding: 24px 28px;
    border-radius: var(--radius-lg);
    border: none;
    text-align: center;
    line-height: 1.6;
    animation: celebrateIn 0.6s ease-out;
    min-height: 0;
    overflow: hidden;
}

#success-message-text {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.success-emoji {
    font-size: 2.5rem;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.success-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.success-subtitle {
    margin-bottom: 16px;
    flex-shrink: 0;
}

.success-course-list {
    text-align: left;
    background: rgba(255,255,255,0.5);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    width: 100%;
    max-width: 400px;
}

.success-course-item {
    padding: 3px 0;
    font-size: 0.95rem;
}

.success-failed-list {
    background: #FFF3E0;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    color: #E65100;
    width: 100%;
    max-width: 400px;
}

.success-raffle-note {
    font-size: 0.9rem;
    color: #558B2F;
    flex-shrink: 0;
    margin-top: 12px;
}

.close-btn {
    background: linear-gradient(135deg, var(--success) 0%, #388E3C 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 12px;
    flex-shrink: 0;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 14px rgba(76, 175, 80, 0.4);
}

/* Compact success on short viewports */
@media (max-height: 700px) {
    .success-message {
        padding: 16px 20px;
    }

    .success-emoji {
        font-size: 1.8rem;
        margin-bottom: 6px;
    }

    .success-title {
        font-size: 1.05rem;
        margin-bottom: 2px;
    }

    .success-subtitle {
        margin-bottom: 10px;
        font-size: 0.85rem;
    }

    .success-course-list {
        padding: 8px 12px;
    }

    .success-course-item {
        padding: 2px 0;
        font-size: 0.85rem;
    }

    .success-raffle-note {
        font-size: 0.8rem;
        margin-top: 8px;
    }

    .close-btn {
        padding: 10px 24px;
        margin-top: 8px;
        font-size: 0.9rem;
    }
}

.close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

/* ============================================
   PROGRESS BAR - Visual feedback
   ============================================ */
#progress-bar-container {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 660px;
    z-index: 100;
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

#progress-bar-bg {
    flex: 1;
    height: 10px;
    background: var(--border-light);
    border-radius: 5px;
    overflow: hidden;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-light) 0%, var(--primary) 50%, var(--success) 100%);
    border-radius: 5px;
    transition: width 0.5s ease-out;
}

/* Select All */
.select-all-courses-div {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: white;
    border-bottom: 2px solid var(--border-light);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    cursor: pointer;
    transition: background var(--transition-fast);
    user-select: none;
    flex-shrink: 0;
}

.select-all-courses-div:hover {
    background: var(--primary-bg);
}

#select-all-courses {
    width: 22px;
    height: 22px;
    cursor: pointer;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.select-all-courses-div .select-all-label {
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    flex: 1;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .email-lookup-field {
        padding: 32px 24px;
    }

    .course-selection-card {
        padding: 16px;
    }

    .course-details {
        flex-direction: column;
        margin-left: 36px;
        gap: 4px;
    }

    .selection-buttons,
    .grade-forms-buttons {
        flex-direction: column;
    }

    .confirm-btn,
    .back-btn {
        width: 100%;
    }

    .course-form-header {
        padding: 16px 20px !important;
    }

    .exam-fields {
        padding: 16px;
    }

    #progress-bar-container {
        bottom: 8px;
        width: calc(100% - 24px);
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    .course-header {
        align-items: flex-start;
    }

    .course-checkbox {
        margin-top: 2px;
    }

    .course-details {
        margin-left: 0;
        margin-top: 12px;
    }

    .collapse-arrow {
        width: 36px;
        height: 36px;
    }
}

/* ============================================
   ANIMATIONS & MICRO-INTERACTIONS
   ============================================ */
@keyframes checkmark {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.course-card:has(.course-checkbox:checked) .course-title::after {
    content: ' ';
    animation: checkmark 0.3s ease-out;
}

/* Smooth transitions for all interactive elements */
button, input, select, .course-card {
    -webkit-tap-highlight-color: transparent;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================
   CONFIRMATION DIALOG
   ============================================ */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 20px;
}

.confirm-overlay.visible {
    opacity: 1;
}

.confirm-dialog {
    background: white;
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    width: 100%;
    box-shadow: var(--shadow-lg);
    line-height: 1.5;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.confirm-dialog > strong {
    display: block;
    margin-bottom: 16px;
    font-size: 1rem;
}

.confirm-courses {
    margin-bottom: 16px;
}

.confirm-course {
    background: var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 10px;
}

.confirm-course:last-child {
    margin-bottom: 0;
}

.confirm-course-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.confirm-grades {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.confirm-grade-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 2px 0;
}

.confirm-exam {
    color: var(--text-secondary);
}

.confirm-grade {
    font-weight: 600;
    color: var(--text-primary);
    background: white;
    padding: 2px 10px;
    border-radius: 4px;
    min-width: 28px;
    text-align: center;
}

.confirm-warning {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 20px 0;
    text-align: center;
}

.confirm-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-buttons .submit-btn {
    margin-top: 0;
}

@media (max-width: 480px) {
    .confirm-buttons {
        flex-direction: column;
    }

    .confirm-buttons .back-btn,
    .confirm-buttons .submit-btn {
        width: 100%;
    }
}

/* ============================================
   SHORT VIEWPORT (landscape phones, etc.)
   ============================================ */
@media (max-height: 600px) {
    .email-lookup-field {
        padding: 20px 16px;
    }

    .intro-text {
        margin-bottom: 16px;
        font-size: 0.85rem;
    }

    .course-selection-card {
        padding: 12px;
    }

    .selection-instruction {
        margin-bottom: 8px;
        font-size: 0.85rem;
    }

    .course-form-header {
        padding: 12px 16px !important;
    }

    .grade-forms-header {
        padding: 16px;
        margin-bottom: 16px;
    }

    .step-indicator {
        padding: 4px 12px;
        font-size: 0.7rem;
    }

    #progress-bar-container {
        padding: 8px 12px;
    }
}
