/* ============================================================================
   Application Form Custom Styles
   Enhanced UI for ULAB Online Admission Module
   ============================================================================ */

/* ====================
   Form Validation States
   ==================== */

/* Error state for required fields (matching PHP .needsfilled class) */
.needsfilled,
.mud-input-error,
.mud-select-error {
    border-color: var(--mud-palette-error) !important;
    animation: shake 0.3s ease-in-out, pulseError 2s ease-in-out infinite;
}

    .needsfilled .mud-input-slot,
    .needsfilled .mud-select-input {
        border-color: var(--mud-palette-error) !important;
        box-shadow: 0 0 0 2px rgba(var(--mud-palette-error-rgb), 0.2);
    }

        .needsfilled:focus-within,
        .needsfilled .mud-input-slot:focus-within {
            box-shadow: 0 0 0 3px rgba(var(--mud-palette-error-rgb), 0.3);
        }

/* Valid/Complete state */
.field-valid,
.field-complete {
    border-color: var(--mud-palette-success) !important;
}

    .field-valid .mud-input-slot,
    .field-complete .mud-input-slot {
        border-left: 3px solid var(--mud-palette-success);
    }

/* Touched but incomplete */
.field-touched {
    border-color: var(--mud-palette-warning) !important;
}

/* ====================
   Animations
   ==================== */

/* Shake animation for validation errors */
@@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }

    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-4px);
    }

    20%, 40%, 60%, 80% {
        transform: translateX(4px);
    }
}

/* Pulse animation for error fields */
@@keyframes pulseError {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(var(--mud-palette-error-rgb), 0.4);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(var(--mud-palette-error-rgb), 0);
    }
}

/* Fade in animation */
@@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide down animation */
@@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        max-height: 1000px;
        transform: translateY(0);
    }
}

/* Slide up animation */
@@keyframes slideUp {
    from {
        opacity: 1;
        max-height: 1000px;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        max-height: 0;
        transform: translateY(-20px);
    }
}

/* Bounce in animation for success states */
@@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

/* Gentle pulse for loading states */
@@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* ====================
   Form Layout & Structure
   ==================== */

/* Tab content transitions */
.mud-tabs-panels {
    animation: fadeIn 0.4s ease-in-out;
}

.tab-pane {
    animation: fadeIn 0.3s ease-in-out;
}

/* Form card styling */
.form-card {
    border-radius: 12px;
    transition: all 0.3s ease;
}

    .form-card:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        transform: translateY(-2px);
    }

/* Section headers */
.form-section-header {
    border-left: 4px solid var(--mud-palette-primary);
    padding-left: 12px;
    margin-bottom: 16px;
}

/* ====================
   Progress Indicators
   ==================== */

/* Tab completion badges */
.tab-badge-complete {
    background-color: var(--mud-palette-success);
    color: white;
    animation: bounceIn 0.5s ease-in-out;
}

.tab-badge-incomplete {
    background-color: var(--mud-palette-grey-400);
    color: var(--mud-palette-text-secondary);
}

.tab-badge-error {
    background-color: var(--mud-palette-error);
    color: white;
    animation: pulseError 2s ease-in-out infinite;
}

/* Progress bar enhancements */
.progress-bar-animated .mud-progress-linear {
    animation: pulse 2s ease-in-out infinite;
}

.progress-bar-animated .mud-progress-linear-bar {
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====================
   Photo Upload Component
   ==================== */

.photo-upload-container {
    position: relative;
    overflow: hidden;
}

.photo-preview-frame {
    border: 2px dashed var(--mud-palette-divider);
    border-radius: 12px;
    padding: 12px;
    background: var(--mud-palette-background-grey);
    transition: all 0.3s ease;
}

    .photo-preview-frame:hover {
        border-color: var(--mud-palette-primary);
        border-style: solid;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .photo-preview-frame.has-photo {
        border-color: var(--mud-palette-success);
        border-style: solid;
    }

.photo-preview-image {
    border-radius: 8px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

    .photo-preview-image:hover {
        transform: scale(1.02);
    }

.photo-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* ====================
   Exam Entry Cards
   ==================== */

.exam-card {
    border-radius: 8px;
    border-left: 4px solid var(--mud-palette-divider);
    transition: all 0.3s ease;
    animation: fadeIn 0.4s ease-in-out;
}

    .exam-card:hover {
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
        transform: translateX(4px);
    }

.exam-card-required {
    border-left-color: var(--mud-palette-primary);
    background: linear-gradient(to right, rgba(var(--mud-palette-primary-rgb), 0.02), transparent);
}

.exam-card-complete {
    border-left-color: var(--mud-palette-success);
}

.exam-card-error {
    border-left-color: var(--mud-palette-error);
    background: rgba(var(--mud-palette-error-rgb), 0.02);
    animation: shake 0.3s ease-in-out;
}

.exam-card-header {
    border-bottom: 1px solid var(--mud-palette-divider);
    padding-bottom: 8px;
    margin-bottom: 16px;
}

/* ====================
   Auto-Save Indicator
   ==================== */

.autosave-indicator {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 1200;
    padding: 8px 16px;
    background: var(--mud-palette-background);
    border-radius: 24px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease-out;
}

    .autosave-indicator.saving {
        border: 2px solid var(--mud-palette-primary);
    }

    .autosave-indicator.saved {
        border: 2px solid var(--mud-palette-success);
        animation: bounceIn 0.5s ease-in-out;
    }

    .autosave-indicator.error {
        border: 2px solid var(--mud-palette-error);
        animation: shake 0.3s ease-in-out;
    }

/* ====================
   Validation Summary Panel
   ==================== */

.validation-summary-panel {
    border-left: 4px solid var(--mud-palette-error);
    animation: slideDown 0.4s ease-out;
}

    .validation-summary-panel .mud-expand-panel {
        background: linear-gradient(to right, rgba(var(--mud-palette-error-rgb), 0.03), transparent);
    }

.validation-error-item {
    padding: 4px 0;
    border-left: 2px solid var(--mud-palette-error);
    padding-left: 12px;
    margin-bottom: 4px;
}

.validation-warning-item {
    padding: 4px 0;
    border-left: 2px solid var(--mud-palette-warning);
    padding-left: 12px;
    margin-bottom: 4px;
}

/* ====================
   Responsive Design
   ==================== */

/* Mobile adjustments */
@@media (max-width: 960px) {
    .form-card {
        border-radius: 8px;
    }

    .exam-card {
        margin-bottom: 12px;
    }

    .autosave-indicator {
        top: auto;
        bottom: 80px;
        right: 16px;
        font-size: 0.85rem;
    }
    /* Larger touch targets */
    .mud-button {
        min-height: 48px;
    }

    .mud-input,
    .mud-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    /* Stack form elements vertically on small screens */
    .mud-grid-item {
        padding: 8px !important;
    }
}

@@media (max-width: 600px) {
    .photo-preview-frame {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .tab-badge {
        font-size: 0.7rem;
        padding: 2px 6px;
    }
    /* Hide less critical elements on very small screens */
    .form-helper-text {
        font-size: 0.75rem;
    }
}

/* Landscape mobile */
@@media (max-width: 960px) and (orientation: landscape) {
    .autosave-indicator {
        top: 12px;
        right: 12px;
        font-size: 0.8rem;
        padding: 6px 12px;
    }
}

/* ====================
   Accessibility Enhancements
   ==================== */

/* High contrast mode support */
@@media (prefers-contrast: high) {
    .needsfilled {
        border-width: 3px !important;
    }

    .exam-card {
        border-left-width: 6px;
    }
}

/* Reduced motion support */
@@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
.mud-button:focus-visible,
.mud-input:focus-visible,
.mud-select:focus-visible {
    outline: 3px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* ====================
   Print Styles
   ==================== */

@@media print {
    .autosave-indicator,
    .mud-appbar,
    .form-navigation-buttons,
    .photo-upload-button {
        display: none !important;
    }

    .form-card,
    .exam-card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--theme-text-primary);
    }

    .needsfilled {
        border: 2px solid var(--theme-text-primary) !important;
    }
}

/* ====================
   Loading States
   ==================== */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5); /* keep neutral overlay */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-in-out;
}

.loading-spinner {
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-loading {
    background: linear-gradient( 90deg, var(--mud-palette-background-grey) 0%, var(--mud-palette-background) 50%, var(--mud-palette-background-grey) 100% );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* ====================
   Utility Classes
   ==================== */

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

.slide-down {
    animation: slideDown 0.3s ease-out;
}

.bounce-in {
    animation: bounceIn 0.5s ease-in-out;
}

.shake {
    animation: shake 0.3s ease-in-out;
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Smooth transitions */
.smooth-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Shadow elevations */
.elevation-hover:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* Text truncation */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ====================
   Dark Mode Support
   ==================== */

@@media (prefers-color-scheme: dark) {
    .photo-preview-frame {
        background: rgba(255, 255, 255, 0.05);
    }

    .form-card:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .needsfilled {
        box-shadow: 0 0 0 2px rgba(var(--mud-palette-error-rgb), 0.4);
    }
}

/* =============================================================================
   Application form page shell (header, stepper, tabs, main + sidebar column)
   ============================================================================= */

.application-form-container .app-form-page-grid {
    align-items: flex-start;
}

.app-form-page-main {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 990px;
}

.app-form-page-sidebar {
    flex: 1 1 280px;
    min-width: 0;
    max-width: 420px;
}

.app-form-page-header {
    background: var(--theme-app-form-header-bg);
    border-radius: 0;
    padding: 10px 20px;
    margin-bottom: 0;
}

    .app-form-page-header .app-form-page-header-title {
        color: var(--theme-app-form-header-title-color) !important;
        font-weight: 600 !important;
        font-size: 1.5rem !important;
        line-height: 1.2 !important;
    }

    .app-form-page-header .app-form-page-header-icon {
        color: var(--theme-app-form-header-icon-color) !important;
    }

.app-form-header-submit.mud-button-outlined {
    background-color: var(--theme-app-form-header-submit-bg) !important;
    color: var(--theme-app-form-header-submit-text) !important;
    border: 1px solid var(--theme-app-form-header-submit-border) !important;
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.03em;
    min-height: 44px;
}

    .app-form-header-submit.mud-button-outlined:hover {
        background-color: color-mix(in srgb, var(--theme-app-form-header-submit-bg) 92%, var(--theme-app-form-header-submit-text)) !important;
    }

.app-form-stepper {
    position: relative;
    background: var(--theme-app-form-stepper-bg);
    border: 1px solid var(--theme-app-form-stepper-border);
    border-radius: 10px;
    padding: 10px 24px 16px;
    margin-bottom: 16px;
}

.app-form-stepper-track {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 30%;
    height: 2px;
    background: var(--theme-app-form-stepper-line);
    pointer-events: none;
}

.app-form-stepper-items {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: nowrap;
}

.app-form-stepper-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: none;
    border: none;
    padding: 4px 4px 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
    max-width: 140px;
}

    .app-form-stepper-item:focus-visible {
        outline: 2px solid var(--theme-info, var(--theme-primary));
        outline-offset: 2px;
        border-radius: 8px;
    }

.app-form-stepper-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.14);
}

.app-form-stepper-dot--active {
    background: var(--theme-app-form-stepper-active-dot);
    border: none;
}

.app-form-stepper-dot--inactive {
    background: var(--theme-surface);
    border: 1px solid var(--theme-app-form-stepper-inactive-dot-border);
}

.app-form-stepper-label {
    font-size: 1rem;
    line-height: 1.25;
    text-align: center;
    color: var(--theme-app-form-stepper-label-inactive);
    font-weight: 500;
}

.app-form-stepper-item--active .app-form-stepper-label {
    color: var(--theme-app-form-stepper-label-active);
    font-weight: 700;
}

.app-form-mud-tabs.mud-tabs-rounded {
    border-radius: 0;
}

.app-form-mud-tabs .mud-tabs-toolbar {
    background: var(--theme-app-form-tab-toolbar-bg) !important;
}

.app-form-mud-tabs .mud-tab {
    text-transform: none !important;
    font-weight: 500 !important;
    color: var(--theme-app-form-tab-inactive-fg) !important;
    background: var(--theme-app-form-tab-inactive-bg) !important;
    border-radius: 0 !important;
    min-height: 48px !important;
}

    .app-form-mud-tabs .mud-tab.mud-tab-active {
        background: var(--theme-app-form-tab-active-bg) !important;
        color: var(--theme-app-form-tab-active-fg) !important;
    }

    .app-form-mud-tabs .mud-tab .mud-icon-root {
        color: inherit !important;
    }

.app-form-mud-tabs .mud-tabs-panels {
    background: var(--theme-surface);
}

.app-form-footer-bar {
    border-radius: 8px;
}

.app-form-resource-sidebar {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
    width: 100%;
}

    .app-form-resource-sidebar .resource-section-card-item {
        width: 100%;
        max-width: 380px;
    }

        .app-form-resource-sidebar .resource-section-card-item .resource-card {
            height: 350px;
            position: relative;
            border-radius: 0;
            overflow: hidden;
            width: 100%;
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }

    .app-form-resource-sidebar .resource-card-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--theme-card-overlay);
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        padding: 32px 24px;
        color: var(--theme-surface);
        text-align: center;
    }

    .app-form-resource-sidebar .resource-card-heading .mud-typography {
        font-size: 24px !important;
        font-weight: 600 !important;
    }

    .app-form-resource-sidebar .resource-card-message .mud-typography {
        font-size: 16px !important;
        font-weight: 400 !important;
    }

    .app-form-resource-sidebar .need-assistance-contact {
        background-color: var(--theme-need-assistance-bg) !important;
        padding: 10px 20px;
        border-radius: 8px;
        width: 100%;
        max-width: 359px;
        height: 52px;
        display: flex;
        align-items: center;
    }

        .app-form-resource-sidebar .need-assistance-contact .mud-icon,
        .app-form-resource-sidebar .need-assistance-contact .mud-typography {
            color: var(--theme-need-assistance-text) !important;
        }

    .app-form-resource-sidebar .resource-card-button {
        background-color: var(--theme-accent) !important;
        color: var(--theme-resource-card-button-color) !important;
        font-weight: 600 !important;
        font-size: 18px !important;
        text-transform: none !important;
        margin-top: 16px;
        height: 48px !important;
        width: 220px !important;
        padding: 10px 20px !important;
    }

        .app-form-resource-sidebar .resource-card-button:hover {
            background-color: var(--theme-accent-hover) !important;
        }

@media (max-width: 1279px) {
    .app-form-page-sidebar {
        max-width: none;
    }

    .app-form-stepper-track {
        display: none;
    }

    .app-form-stepper-items {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Uploaded documents card (Preview / My Profile view) */
.app-form-cv-heading-title {
    font-weight: 500 !important;
    letter-spacing: 0.015em;
}

.app-form-cv-file-panel {
    border: 1px solid var(--theme-divider);
    border-radius: 8px;
    background: var(--theme-surface);
    box-sizing: border-box;
    min-height: 64px;
    max-height: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    padding: 10px 11px;
    overflow: hidden;
}

    .app-form-cv-file-panel > * {
        width: 100%;
        min-width: 0;
    }

.app-form-cv-file-name,
.app-form-cv-file-size {
    color: color-mix(in srgb, var(--theme-body-text) 72%, transparent) !important;
}

.app-form-cv-file-name {
    font-weight: 600 !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-form-cv-file-info {
    min-width: 0;
    flex: 1 1 auto;
}

.app-form-cv-pdf-icon {
    font-size: 28px !important;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.app-form-cv-pdf-icon--excel {
    color: #217346 !important;
}

.app-form-cv-pdf-icon--word {
    color: #2b579a !important;
}

.app-form-cv-pdf-icon--pdf {
    color: var(--theme-error) !important;
}

.app-form-cv-action-btn {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    padding: 0 !important;
    border-radius: 5px !important;
}

.app-form-cv-figma-row {
    width: 100%;
}
