/* Import Tailwind */
@tailwind base;
@tailwind components;
@tailwind utilities;

/* Custom Animations */
@keyframes blob {
    0% {
        transform: translate(0px, 0px) scale(1);
    }
    33% {
        transform: translate(30px, -50px) scale(1.1);
    }
    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
    100% {
        transform: translate(0px, 0px) scale(1);
    }
}

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

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes successPulse {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes checkmark {
    0% {
        stroke-dashoffset: 50;
        opacity: 0;
    }
    100% {
        stroke-dashoffset: 0;
        opacity: 1;
    }
}

/* Animation Classes */
.animate-blob {
    animation: blob 7s infinite;
}

.animation-delay-2000 {
    animation-delay: 2s;
}

.animation-delay-4000 {
    animation-delay: 4s;
}

.animate-fadeIn {
    animation: fadeIn 0.5s ease-out;
}

.animate-fadeInScale {
    animation: fadeInScale 0.6s ease-out;
}

.animate-successPulse {
    animation: successPulse 0.8s ease-out;
}

.animate-checkmark {
    stroke-dasharray: 50;
    animation: checkmark 0.8s ease-out 0.5s forwards;
}

/* Warning toast animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -20px);
    }
}

/* Confetti Animation */
.confetti-container {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #f0f0f0;
    animation: confetti-fall 3s linear infinite;
}

.confetti:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
    background-color: #f87171;
}

.confetti:nth-child(2) {
    left: 30%;
    animation-delay: 0.5s;
    background-color: #60a5fa;
}

.confetti:nth-child(3) {
    left: 50%;
    animation-delay: 1s;
    background-color: #34d399;
}

.confetti:nth-child(4) {
    left: 70%;
    animation-delay: 1.5s;
    background-color: #fbbf24;
}

.confetti:nth-child(5) {
    left: 90%;
    animation-delay: 2s;
    background-color: #a78bfa;
}

@keyframes confetti-fall {
    to {
        transform: translateY(350px) rotate(360deg);
        opacity: 0;
    }
}

/* Custom Utility Classes */
.shadow-3xl {
    box-shadow: 0 35px 60px -15px rgba(0, 0, 0, 0.3);
}

/* Question Indicator Styles */
.question-indicator {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
    cursor: pointer;
}

.question-indicator.unanswered {
    background-color: #f3f4f6;
    color: #6b7280;
    border: 2px solid transparent;
}

.question-indicator.answered {
    background-color: #dbeafe;
    color: #1d4ed8;
    border: 2px solid #60a5fa;
}

.question-indicator.current {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Radio Button Styles */
.custom-radio {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    transition: all 0.2s;
    position: relative;
    cursor: pointer;
}

.custom-radio:checked {
    border-color: #6366f1;
    background-color: #6366f1;
}

.custom-radio:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background-color: white;
    border-radius: 50%;
}

.custom-radio:hover {
    border-color: #6366f1;
}

/* Option Labels */
.option-label {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background-color: #f9fafb;
    border: 2px solid transparent;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.option-label:hover {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
}

.option-label.selected {
    background-color: #eef2ff;
    border-color: #6366f1;
}

/* Timer Warning States */
.timer-warning {
    background-color: #fef3c7 !important;
    border-color: #fbbf24 !important;
    color: #92400e !important;
}

.timer-danger {
    background-color: #fee2e2 !important;
    border-color: #f87171 !important;
    color: #991b1b !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 1;
    }
}

/* Modal Animations */
.modal-enter {
    opacity: 0;
    transform: scale(0.95);
}

.modal-enter-active {
    opacity: 1;
    transform: scale(1);
    transition: all 0.3s ease-out;
}

/* Loading Spinner */
.loading-spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Question Styles */
.question-text {
    font-size: 1.25rem;
    line-height: 1.75rem;
    color: #1f2937;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.question-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.question-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background-color: #e0e7ff;
    color: #4338ca;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.question-number {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Smooth Transitions */
.slide-enter {
    transform: translateX(100%);
    opacity: 0;
}

.slide-enter-active {
    transform: translateX(0);
    opacity: 1;
    transition: all 0.3s ease-out;
}

.slide-exit {
    transform: translateX(0);
    opacity: 1;
}

.slide-exit-active {
    transform: translateX(-100%);
    opacity: 0;
    transition: all 0.3s ease-out;
}

/* Focus Styles */
input:focus,
button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive Design Improvements */
@media (max-width: 640px) {
    .question-indicator {
        width: 36px;
        height: 36px;
        font-size: 0.75rem;
    }
    
    .question-text {
        font-size: 1.125rem;
    }
    
    .option-label {
        padding: 0.875rem 1rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .no-print {
        display: none !important;
    }
}

/* Accessibility Improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}

/* Ripple Effect */
button {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.6);
    transform: scale(0);
    animation: ripple-animation 0.6s ease-out;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Tooltips */
.tooltip {
    position: absolute;
    background-color: #1f2937;
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s;
    pointer-events: none;
}

.tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -4px;
    border-width: 4px;
    border-style: solid;
    border-color: #1f2937 transparent transparent transparent;
}

/* Additional Loading States */
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Success/Error Message Animations */
.message-enter {
    opacity: 0;
    transform: translateY(-10px);
}

.message-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease-out;
}

/* Improved Focus States for Accessibility */
*:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Smooth Hover Transitions */
a, button, input, .option-label {
    transition: all 0.2s ease-out;
}

/* Improved Question Indicator Styles */
.question-indicator {
    min-width: 32px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.75rem;
    transition: all 0.2s;
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}

.question-indicator.unanswered {
    background-color: #f9fafb;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.question-indicator.unanswered:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    transform: scale(1.05);
}

.question-indicator.answered {
    background-color: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.question-indicator.answered:hover {
    background-color: #bfdbfe;
    transform: scale(1.05);
}

.question-indicator.current {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    border: none;
}

/* Custom scrollbar for question indicators */
.scrollbar-thin {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.scrollbar-thin::-webkit-scrollbar {
    height: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Alternative: Grid layout for many questions */
@media (min-width: 768px) {
    #question-indicators {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
        gap: 0.375rem;
        max-width: 100%;
        overflow-x: visible;
    }
    
    .question-indicator {
        min-width: unset;
        width: 100%;
    }
}

/* Mobile optimization */
@media (max-width: 767px) {
    .question-indicator {
        min-width: 28px;
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    
    #question-indicators {
        padding-bottom: 0.5rem;
    }
}

/* Sidebar Navigation Styles */
.sidebar-scroll {
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Question Navigator Buttons */
.question-nav-btn {
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
}

.question-nav-btn.unanswered {
    background-color: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

.question-nav-btn.unanswered:hover {
    background-color: #e5e7eb;
    transform: scale(1.05);
}

.question-nav-btn.answered {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.question-nav-btn.answered:hover {
    background-color: #bbf7d0;
    transform: scale(1.05);
}

.question-nav-btn.current {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    border: none;
}

.question-nav-btn.marked {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    /* Hide right sidebar on smaller screens */
    aside.hidden.lg\:block {
        display: none !important;
    }
    
    /* Make left sidebar collapsible on mobile */
    @media (max-width: 768px) {
        aside:first-of-type {
            position: fixed;
            left: -256px;
            transition: left 0.3s ease;
            z-index: 30;
            height: 100vh;
        }
        
        aside:first-of-type.active {
            left: 0;
        }
        
        /* Add hamburger menu button for mobile */
        .mobile-menu-btn {
            display: block;
            position: fixed;
            bottom: 20px;
            left: 20px;
            z-index: 40;
            background: #6366f1;
            color: white;
            width: 56px;
            height: 56px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        }
    }
}

/* Add to your style.css */
.question-nav-btn.marked {
    position: relative;
}

.question-nav-btn.marked::after {
    content: '★';
    position: absolute;
    top: -4px;
    right: -4px;
    color: #fbbf24;
    font-size: 12px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.question-nav-btn.answered.marked {
    background-color: #fef3c7;
    border-color: #fde68a;
}

.question-nav-btn.unanswered.marked {
    background-color: #fef3c7;
    border-color: #fde68a;
    color: #92400e;
}