/* Modern Test Interface Styles */
/* Provides responsive, accessible, and theme-aware styling for the test taking experience */

/* Test Interface Base Styles */
.test-interface {
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
}

/* Enhanced Test Header with better visual hierarchy */
.test-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-hover) 100%);
    color: white;
    padding: 2.5rem 0;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    border-radius: 0 0 20px 20px;
}

.test-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"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.test-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    position: relative;
    z-index: 1;
}

.test-info {
    flex: 1;
}

.test-title {
    font-size: 2.75rem;
    font-weight: 800;
    margin: 0 0 1.25rem 0;
    text-shadow: 0 3px 6px rgba(0,0,0,0.15);
    letter-spacing: -0.02em;
}

.test-intro {
    font-size: 1.2rem;
    opacity: 0.95;
    max-width: 700px;
    line-height: 1.7;
    font-weight: 400;
}

.test-actions {
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
}

/* Enhanced Test Progress Section */
.test-progress-section {
    background: var(--bg-secondary);
    padding: 2rem 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.progress-overview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.progress-stats {
    display: flex;
    gap: 2.5rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    min-width: 100px;
}

.stat-number {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-bar-container {
    flex: 1;
    max-width: 400px;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--growth-green) 100%);
    border-radius: 6px;
    transition: width 0.5s ease-in-out;
    width: 0%;
}

/* Test Content */
.test-content {
    padding: 3rem 0;
}

.test-welcome {
    max-width: 800px;
    margin: 0 auto;
}

.welcome-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 3rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 1px solid var(--border-color);
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--growth-green) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
    color: white;
    font-size: 2rem;
}

.welcome-card h2 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.welcome-card p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0 0 2rem 0;
    line-height: 1.6;
}

.test-instructions {
    text-align: left;
    margin: 2rem 0;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
}

.test-instructions h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.test-instructions ul {
    margin: 0;
    padding-left: 1.5rem;
}

.test-instructions li {
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

.test-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Enhanced Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content p {
    font-size: 1.2rem;
    font-weight: 500;
    margin: 0;
    opacity: 0.9;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Enhanced Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-dialog {
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-xl);
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-content {
    border: none;
    border-radius: 16px;
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-hover) 100%);
    color: white;
    padding: 1.5rem 2rem;
    border-bottom: none;
    position: relative;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    opacity: 0.8;
    position: relative;
    overflow: hidden;
}

.close::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.close:hover::before {
    opacity: 1;
}

.modal-body {
    padding: 2rem;
    background: var(--bg-primary);
}

.modal-footer {
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    align-items: center;
}

/* Enhanced Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-width: 120px;
    text-align: center;
    font-family: inherit;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-color-light);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-lg {
    padding: 1.125rem 2.25rem;
    font-size: 1.125rem;
    border-radius: 14px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-color-hover) 100%);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-color-hover) 0%, var(--primary-color) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-outline-secondary:hover:not(:disabled) {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .test-header-content {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    
    .test-title {
        font-size: 2rem;
    }
    
    .test-intro {
        font-size: 1rem;
    }
    
    .test-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .progress-overview {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .progress-stats {
        justify-content: center;
    }
    
    .progress-bar-container {
        max-width: 100%;
    }
    
    .welcome-card {
        padding: 2rem 1.5rem;
        margin: 0 1rem;
    }
    
    .welcome-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .welcome-card h2 {
        font-size: 1.5rem;
    }
    
    .test-instructions {
        padding: 1.5rem;
        margin: 1.5rem 0;
    }
    
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
}

@media (max-width: 576px) {
    .test-header {
        padding: 1.5rem 0;
    }
    
    .test-title {
        font-size: 1.75rem;
    }
    
    .progress-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .stat-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .welcome-card {
        padding: 1.5rem 1rem;
    }
    
    .test-actions {
        gap: 0.75rem;
    }
}

/* Dark Theme Support */
.dark-theme .test-interface {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.dark-theme .welcome-card {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

.dark-theme .test-instructions {
    background: var(--bg-secondary);
}

.dark-theme .modal-content {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.dark-theme .modal-header,
.dark-theme .modal-footer {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

/* Light Theme Support */
.light-theme .test-interface {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.light-theme .welcome-card {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

.light-theme .test-instructions {
    background: var(--bg-secondary);
}

.light-theme .modal-content {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.light-theme .modal-header,
.light-theme .modal-footer {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    .btn,
    .progress-fill,
    .modal-dialog {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
    }
}

@media (prefers-contrast: high) {
    .test-header {
        background: var(--primary-color);
    }
    
    .progress-fill {
        background: var(--primary-color);
    }
    
    .btn-primary {
        background: var(--primary-color);
        border: 2px solid var(--primary-color);
    }
}

/* Focus Management */
.btn:focus-visible,
.close:focus-visible {
    outline: 2px solid var(--focus-indigo);
    outline-offset: 2px;
}

/* PHASE 3.2: Enhanced Test Status Management Styles */

/* Test Progress Display */
.test-progress {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
    transition: all 0.3s ease;
}

.test-progress.expanded {
    background: var(--bg-primary);
    box-shadow: var(--shadow-lg);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.progress-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.progress-percentage {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9rem;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-details {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* Current Stage Information */
.current-stage {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.current-stage h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.current-stage p {
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

.stage-time-limit {
    color: var(--warning-color);
    font-weight: 500;
}

.stage-redo-info {
    color: var(--info-color);
    font-weight: 500;
}

/* Enhanced Welcome Messages */
.welcome-message {
    font-style: italic;
    color: var(--text-secondary);
    margin: 0.5rem 0;
}

/* Custom Instructions */
.custom-instructions {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin: 1rem 0;
    line-height: 1.6;
}

.custom-instructions p {
    margin: 0.5rem 0;
}

/* Progress Loading States */
.progress-loading {
    text-align: center;
    padding: 2rem;
}

.progress-loading .loading-spinner {
    margin: 0 auto 1rem;
}

.progress-error {
    text-align: center;
    padding: 2rem;
    color: var(--error-color);
}

.progress-error button {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.3s ease;
}

.progress-error button:hover {
    background: var(--error-dark);
}

/* Enhanced Test Actions */
.test-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    transition: all 0.3s ease;
}

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

/* Error Display Enhancements */
.error-container {
    max-width: 600px;
    margin: 3rem auto;
    text-align: center;
}

.error-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    box-shadow: var(--shadow-lg);
}

.error-icon {
    font-size: 4rem;
    color: var(--error-color);
    margin-bottom: 1.5rem;
}

.error-content h1 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.error-content p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* Responsive Design for Progress Elements */
@media (max-width: 768px) {
    .progress-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .test-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .error-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .current-stage,
    .test-progress {
        padding: 1rem;
        margin: 1rem 0;
    }
}

/* Dark Theme Support for New Elements */
.dark-theme .test-progress {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.dark-theme .current-stage {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.dark-theme .custom-instructions {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.dark-theme .btn-outline {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

/* Light Theme Support for New Elements */
.light-theme .test-progress {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.light-theme .current-stage {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.light-theme .custom-instructions {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: var(--radius-sm);
    z-index: 10001;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 6px;
}
