/* Custom styles for Vocabulary App */

/* Custom animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0,0,0);
    }
    40%, 43% {
        transform: translate3d(0,-15px,0);
    }
    70% {
        transform: translate3d(0,-7px,0);
    }
    90% {
        transform: translate3d(0,-2px,0);
    }
}

/* Apply animations */
.animate-slideIn {
    animation: slideIn 0.5s ease-out;
}

.animate-pulse-custom {
    animation: pulse 2s infinite;
}

.animate-bounce-custom {
    animation: bounce 1s;
}

/* Custom gradients */
.gradient-blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.gradient-green {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.gradient-purple {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Card hover effects */
.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Button effects */
.btn-glow {
    position: relative;
    overflow: hidden;
}

.btn-glow::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;
}

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

/* Progress bar animation */
.progress-bar {
    background-size: 20px 20px;
    background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
    animation: progress-animation 1s linear infinite;
}

@keyframes progress-animation {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 20px 0;
    }
}

/* Success and error states */
.success-glow {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
    border-color: rgb(34, 197, 94);
}

.error-glow {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
    border-color: rgb(239, 68, 68);
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .text-responsive {
        font-size: clamp(1rem, 4vw, 1.5rem);
    }
    
    .card-mobile {
        margin-bottom: 1rem;
        padding: 1rem;
    }
}

/* Touch feedback for mobile */
@media (hover: none) and (pointer: coarse) {
    .touch-feedback:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .dark-mode {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
        color: #f8fafc;
    }
    
    .dark-mode .bg-white {
        background-color: #334155;
        color: #f8fafc;
    }
    
    .dark-mode .text-gray-800 {
        color: #f8fafc;
    }
    
    .dark-mode .text-gray-600 {
        color: #cbd5e1;
    }
}

/* Enhanced Dark Mode Styles */
.dark {
    color-scheme: dark;
}

/* Dark mode transitions */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Dark mode specific components */
.dark .enhanced-tooltip {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(229, 231, 235, 0.95));
    color: #1f2937;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.dark .enhanced-tooltip .border-b-gray-800 {
    border-bottom-color: #e5e7eb;
}

/* Dark mode card hover effects */
.dark .card-hover:hover {
    background-color: #374151;
}

/* Dark mode button styles */
.dark .bg-gradient-to-r.from-indigo-500.to-purple-600 {
    background: linear-gradient(to right, #6366f1, #8b5cf6);
}

.dark .bg-gradient-to-r.from-indigo-500.to-purple-600:hover {
    background: linear-gradient(to right, #4f46e5, #7c3aed);
}

/* Dark mode input styling */
.dark input[type="text"] {
    background-color: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

.dark input[type="text"]:focus {
    border-color: #6366f1;
    background-color: #1f2937;
}

.dark input[type="text"]::placeholder {
    color: #9ca3af;
}

/* Dark mode success/error states */
.dark .bg-green-100 {
    background-color: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
}

.dark .bg-red-100 {
    background-color: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

.dark .text-green-800 {
    color: #22c55e;
}

.dark .text-red-800 {
    color: #ef4444;
}

/* Dark mode theme switcher */
.theme-switcher {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .theme-switcher {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Theme transition animation */
.theme-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar {
    width: 8px;
}

.dark ::-webkit-scrollbar-track {
    background: #374151;
}

.dark ::-webkit-scrollbar-thumb {
    background: #6b7280;
    border-radius: 4px;
}

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

/* Dark mode selection */
.dark ::selection {
    background-color: rgba(99, 102, 241, 0.3);
    color: #f9fafb;
}

/* Dark mode focus rings */
.dark .focus-visible:focus {
    outline-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5);
}

/* Custom dark mode gradients */
.dark-gradient-bg {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
}

.dark-card-bg {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    border: 1px solid #4b5563;
}

/* Dark mode animations */
@keyframes darkModeSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
        background-color: #1f2937;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        background-color: #374151;
    }
}

.dark .animate-slideIn {
    animation: darkModeSlideIn 0.5s ease-out;
}

/* System theme preference detection */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1f2937;
        --bg-secondary: #374151;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --border-color: #4b5563;
    }
}

@media (prefers-color-scheme: light) {
    :root {
        --bg-primary: #ffffff;
        --bg-secondary: #f9fafb;
        --text-primary: #1f2937;
        --text-secondary: #6b7280;
        --border-color: #d1d5db;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dark {
        --text-primary: #ffffff;
        --text-secondary: #e5e7eb;
        --border-color: #ffffff;
    }
    
    .dark .bg-gray-800 {
        background-color: #000000;
        border: 2px solid #ffffff;
    }
}

/* 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;
    }
}

.reduce-motion *, 
.reduce-motion *::before, 
.reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* Theme transition styles */
.theme-transitioning * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease !important;
}

/* High contrast mode */
.high-contrast {
    filter: contrast(1.5);
}

.high-contrast .bg-white {
    background-color: #ffffff !important;
    color: #000000 !important;
}

.high-contrast .dark .bg-gray-800 {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff;
}

/* Reduced transparency */
.reduce-transparency [class*="bg-opacity"] {
    opacity: 1 !important;
}

.reduce-transparency .backdrop-blur,
.reduce-transparency .backdrop-filter {
    backdrop-filter: none !important;
}

/* System theme preference detection */
@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        color-scheme: dark;
    }
}

@media (prefers-color-scheme: light) {
    :root:not(.dark) {
        color-scheme: light;
    }
}

/* Enhanced focus indicators for accessibility */
.focus-visible:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.dark .focus-visible:focus {
    outline-color: #60a5fa;
}

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
}

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

/* Color contrast improvements */
.dark .text-gray-400 {
    color: #d1d5db;
}

.dark .text-gray-500 {
    color: #9ca3af;
}

.dark .text-gray-600 {
    color: #6b7280;
}

/* Print styles */
@media print {
    .dark {
        background: white !important;
        color: black !important;
    }
    
    .dark * {
        background: white !important;
        color: black !important;
        border-color: black !important;
    }
    
    .no-print {
        display: none !important;
    }
}

/* Loading states */
.loading-dots::after {
    content: '';
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

/* Accessible focus states */
.focus-visible:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Improved TTS button */
.tts-button {
    transition: all 0.2s ease;
}

.tts-button:hover {
    transform: scale(1.1);
    color: #4f46e5;
}

.tts-button:active {
    transform: scale(0.95);
}

/* Translation tooltip styling */
.translation-tooltip {
    position: relative;
    display: inline-block;
}

.translation-tooltip:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    animation: fadeInTooltip 0.3s ease forwards;
}

.translation-tooltip:hover::after {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid rgba(0, 0, 0, 0.9);
    z-index: 1000;
    opacity: 0;
    animation: fadeInTooltip 0.3s ease forwards;
}

@keyframes fadeInTooltip {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Clickable word styling */
.clickable-word {
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
}

.clickable-word:hover {
    color: #4f46e5;
    text-shadow: 0 0 8px rgba(79, 70, 229, 0.3);
}

.clickable-word:active {
    transform: scale(0.98);
}

/* Tooltip animation improvements */
.tooltip-enter {
    animation: tooltipSlideIn 0.2s ease-out;
}

.tooltip-leave {
    animation: tooltipSlideOut 0.15s ease-in;
}

@keyframes tooltipSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@keyframes tooltipSlideOut {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px) scale(0.9);
    }
}

/* Enhanced tooltip with better visibility */
.enhanced-tooltip {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95), rgba(31, 41, 55, 0.95));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Responsive tooltip adjustments */
@media (max-width: 768px) {
    .enhanced-tooltip {
        font-size: 12px;
        padding: 6px 10px;
        max-width: 250px;
        word-wrap: break-word;
    }
}

/* Chapter progress indicator */
.chapter-progress {
    position: relative;
    overflow: hidden;
}

.chapter-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%);
    transform: translateX(-100%);
    animation: shine 2s ease-in-out infinite;
}

@keyframes shine {
    0% {
        transform: translateX(-100%);
    }
    50%, 100% {
        transform: translateX(100%);
    }
}

/* Responsive typography */
.title-responsive {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
}

.subtitle-responsive {
    font-size: clamp(0.875rem, 3vw, 1.125rem);
}

/* Enhanced input styling */
.input-enhanced {
    transition: all 0.3s ease;
}

.input-enhanced:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.15);
}

/* Statistics cards */
.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.8) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Achievement badges */
.achievement-badge {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    animation: bounce-custom 2s infinite;
}

@keyframes bounce-custom {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Score Animations */
@keyframes scoreGain {
    0% { transform: translateY(0) scale(1); opacity: 0; }
    50% { transform: translateY(-10px) scale(1.1); opacity: 1; }
    100% { transform: translateY(-20px) scale(1); opacity: 0; }
}

@keyframes scoreLoss {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

@keyframes pointsBadge {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.score-gain {
    animation: scoreGain 2s ease-out;
}

.score-loss {
    animation: scoreLoss 0.5s ease-in-out;
}

.points-badge {
    animation: pointsBadge 0.5s ease-out;
}

/* Score Progress Animation */
.score-progress {
    transition: all 0.5s ease-out;
}
