* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    animation: containerEntrance 0.5s ease-out;
}

@keyframes containerEntrance {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path fill="rgba(255,255,255,0.1)" d="M0,0 L100,0 L100,100 Z"/></svg>');
    background-size: cover;
    animation: headerSlide 20s linear infinite;
}

@keyframes headerSlide {
    0% { background-position: 0 0; }
    100% { background-position: 100px 100px; }
}

.header h1 {
    font-size: 2em;
    margin-bottom: 10px;
    position: relative;
    animation: textGlow 2s ease-in-out infinite alternate;
}

@keyframes textGlow {
    from { text-shadow: 0 0 10px rgba(255,255,255,0.5); }
    to { text-shadow: 0 0 20px rgba(255,255,255,0.8), 0 0 30px rgba(255,255,255,0.6); }
}

.header p {
    opacity: 0.9;
    font-size: 1.1em;
    position: relative;
}

.content {
    padding: 40px;
    animation: contentFadeIn 0.8s ease-out 0.3s both;
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    display: none;
    animation: sectionFadeIn 0.5s ease-out;
}

@keyframes sectionFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section.active {
    display: block;
}

/* Login Section */
.login-box {
    max-width: 500px;
    margin: 0 auto;
    padding: 30px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    animation: loginBoxEntrance 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes loginBoxEntrance {
    0% {
        opacity: 0;
        transform: scale(0.5) rotate(-5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

.form-group {
    margin-bottom: 25px;
    animation: formGroupEntrance 0.5s ease-out;
    animation-fill-mode: both;
}

.form-group:nth-child(1) { animation-delay: 0.1s; }
.form-group:nth-child(2) { animation-delay: 0.2s; }

@keyframes formGroupEntrance {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

input[type="text"] {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s;
    background: #f8f9fa;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn:active {
    transform: translateY(-1px);
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.btn:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(20, 20);
        opacity: 0;
    }
}

.error-message {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: none;
    animation: shake 0.5s ease-in-out;
}

.error-message.show {
    display: block;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Test Selection */
.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.test-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    min-height: 180px;
    animation: cardEntrance 0.6s ease-out;
    animation-fill-mode: both;
    transform-style: preserve-3d;
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.9) rotateX(10deg);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0);
    }
}

.test-card:hover {
    transform: translateY(-10px) rotateX(5deg);
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
}

.test-card h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.test-card p {
    color: #666;
    font-size: 0.95em;
    margin-bottom: 15px;
    min-height: 40px;
}

.test-card .badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 10px;
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.test-status {
    position: absolute;
    top: 15px;
    right: 15px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: 600;
    display: none;
    animation: checkmarkPop 0.5s ease-out;
}

@keyframes checkmarkPop {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.test-status.completed {
    display: block;
}

.test-completed {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #28a745;
    animation: completedGlow 2s infinite alternate;
}

@keyframes completedGlow {
    from { box-shadow: 0 5px 15px rgba(40, 167, 69, 0.2); }
    to { box-shadow: 0 5px 25px rgba(40, 167, 69, 0.4); }
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #667eea;
    font-size: 1.1em;
    position: relative;
}

.loading-spinner::before {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Student Info Bar */
.student-info {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    animation: infoBarSlide 0.5s ease-out;
}

@keyframes infoBarSlide {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.student-info div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.student-info strong {
    color: #667eea;
}

/* Test Section */
.test-header {
    margin-bottom: 30px;
    animation: headerFadeIn 0.5s ease-out;
}

@keyframes headerFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.test-header h2 {
    color: #333;
    margin-bottom: 10px;
}

.progress-bar {
    background: #e0e0e0;
    height: 10px;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 20px;
    position: relative;
}

.progress-fill {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent 30%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 70%
    );
    animation: progressShine 2s infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.question-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    border-left: 5px solid #667eea;
    animation: questionSlideIn 0.5s ease-out;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

@keyframes questionSlideIn {
    from { 
        opacity: 0; 
        transform: translateX(30px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateX(0) scale(1); 
    }
}

.question-number {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.question-text {
    font-size: 1.1em;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.6;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-label {
    display: flex;
    align-items: center;
    padding: 15px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    animation: optionFadeIn 0.3s ease-out;
}

.option-label:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateX(5px);
}

.option-label input[type="radio"] {
    margin-right: 15px;
    cursor: pointer;
    width: 20px;
    height: 20px;
}

.option-label input[type="radio"]:checked + span {
    font-weight: bold;
    color: #667eea;
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.button-group .btn {
    flex: 1;
    min-width: 200px;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #5a6268 0%, #343a40 100%);
}

/* Result Section */
.result-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 30px;
    animation: resultCelebrate 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    overflow: hidden;
}

@keyframes resultCelebrate {
    0% { 
        transform: scale(0.5) rotate(-10deg); 
        opacity: 0; 
    }
    50% { 
        transform: scale(1.1) rotate(5deg); 
    }
    100% { 
        transform: scale(1) rotate(0deg); 
        opacity: 1; 
    }
}

.result-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: resultShine 3s infinite linear;
}

@keyframes resultShine {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.result-card h2 {
    font-size: 2em;
    margin-bottom: 20px;
    position: relative;
}

.score-display {
    font-size: 4em;
    font-weight: bold;
    margin: 20px 0;
    animation: scorePopIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) 0.3s both;
    text-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

@keyframes scorePopIn {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.result-details {
    background: white;
    padding: 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    animation: detailsSlideIn 0.5s ease-out 0.2s both;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

@keyframes detailsSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid #e0e0e0;
    animation: rowFadeIn 0.3s ease-out;
    animation-fill-mode: both;
}

.result-row:nth-child(1) { animation-delay: 0.3s; }
.result-row:nth-child(2) { animation-delay: 0.4s; }
.result-row:nth-child(3) { animation-delay: 0.5s; }
.result-row:nth-child(4) { animation-delay: 0.6s; }
.result-row:nth-child(5) { animation-delay: 0.7s; }
.result-row:nth-child(6) { animation-delay: 0.8s; }

@keyframes rowFadeIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.result-row:last-child {
    border-bottom: none;
}

.result-label {
    font-weight: 600;
    color: #666;
}

.result-value {
    color: #333;
    font-weight: 600;
}

.btn-download {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    margin: 20px 0;
    animation: downloadPulse 2s infinite;
    position: relative;
    overflow: hidden;
}

.btn-download:hover {
    animation: none;
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(40, 167, 69, 0.3);
}

@keyframes downloadPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 5px 15px rgba(40, 167, 69, 0.2); }
    50% { transform: scale(1.05); box-shadow: 0 10px 25px rgba(40, 167, 69, 0.4); }
}

.btn-download::after {
    content: '📥';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    animation: downloadBounce 1s infinite;
}

@keyframes downloadBounce {
    0%, 100% { transform: translateY(-50%); }
    50% { transform: translateY(-55%); }
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loader {
    width: 60px;
    height: 60px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Confetti Animation */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    z-index: 1000;
    animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .content {
        padding: 20px;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .test-grid {
        grid-template-columns: 1fr;
    }

    .score-display {
        font-size: 3em;
    }

    .student-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .button-group {
        flex-direction: column;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .content {
        padding: 15px;
    }
    
    .header {
        padding: 20px;
    }
    
    .test-card {
        padding: 20px;
    }
    
    .result-card {
        padding: 25px;
    }
    
    .result-details {
        padding: 20px;
    }
    
    .score-display {
        font-size: 2.5em;
    }
}

/* Stagger animations for test cards */
.test-card:nth-child(1) { animation-delay: 0.1s; }
.test-card:nth-child(2) { animation-delay: 0.2s; }
.test-card:nth-child(3) { animation-delay: 0.3s; }
.test-card:nth-child(4) { animation-delay: 0.4s; }
.test-card:nth-child(5) { animation-delay: 0.5s; }
.test-card:nth-child(6) { animation-delay: 0.6s; }

/* Floating animation for header elements */
.header h1, .header p {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Add these new styles to your existing style.css */

/* Logout Button */
.btn-logout {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-logout:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.3);
}

.btn-logout:active {
    transform: translateY(0);
}

/* Back to Home Link */
.back-to-home {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    transition: all 0.3s;
}

.back-to-home:hover {
    background: #f0f4ff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.1);
}

/* Enhanced Student Info Bar */
.student-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    animation: infoBarSlide 0.5s ease-out;
}

.student-info div {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.student-info strong {
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 6px;
}

.student-info span {
    color: #333;
    font-weight: 500;
}

/* Session timeout message */
.session-timeout {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
    color: #333;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    z-index: 10000;
    animation: slideInRight 0.5s ease-out, slideOutRight 0.5s ease-out 4.5s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Auto logout warning */
.auto-logout-warning {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    z-index: 10000;
    animation: pulseWarning 1s infinite alternate;
    display: flex;
    align-items: center;
    gap: 10px;
}

@keyframes pulseWarning {
    from { box-shadow: 0 5px 20px rgba(220, 53, 69, 0.3); }
    to { box-shadow: 0 5px 30px rgba(220, 53, 69, 0.5); }
}

/* Login form enhancements */
.login-box {
    position: relative;
}

.login-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.login-footer p {
    color: #666;
    font-size: 0.9em;
}

/* Clear session button */
.clear-session {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 0.8em;
    text-decoration: underline;
    padding: 5px;
    margin-top: 10px;
}

.clear-session:hover {
    color: #dc3545;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .student-info {
        grid-template-columns: 1fr;
    }
    
    .btn-logout {
        width: 100%;
        justify-content: center;
    }
    
    .session-timeout,
    .auto-logout-warning {
        left: 20px;
        right: 20px;
        max-width: calc(100% - 40px);
    }
}

@media (max-width: 480px) {
    .student-info {
        padding: 15px;
    }
    
    .student-info div {
        justify-content: space-between;
    }
}