* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

html.dark h1 {
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.5), 
                 0 0 20px rgba(59, 130, 246, 0.3),
                 0 0 30px rgba(59, 130, 246, 0.1);
    transition: text-shadow 0.5s ease;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

html.dark ::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

html.dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

html.dark ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

:focus {
    outline: none;
}

button {
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.4);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

main section.bg-white {
    transition: box-shadow 0.3s ease;
}

main section.bg-white:hover {
    transform: none !important;
}

#historyBtn:hover, #swapLanguagesBtn:hover, #offlineModeBtn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

html.dark #historyBtn:hover, 
html.dark #swapLanguagesBtn:hover, 
html.dark #offlineModeBtn:hover {
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

@media (hover: hover) {
    button.tooltip:hover::before {
        opacity: 1;
        transform: translateX(-50%) translateY(-5px);
    }
    
    button.tooltip::before {
        opacity: 0;
        transform: translateX(-50%) translateY(0);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    20% {
        transform: scale(25, 25);
        opacity: 0.3;
    }
    100% {
        opacity: 0;
        transform: scale(40, 40);
    }
}

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

main {
    animation: fadeIn 0.5s ease-out;
}

.loading::after {
    content: '';
    animation: loadingDots 1.5s infinite;
}

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

.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    z-index: 10;
}

html.dark .tooltip:hover::before {
    background-color: rgba(255, 255, 255, 0.8);
    color: black;
}

.tooltip:hover::after {
    content: '';
    position: absolute;
    bottom: calc(100% - 5px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
    z-index: 10;
}

html.dark .tooltip:hover::after {
    border-color: rgba(255, 255, 255, 0.8) transparent transparent transparent;
}

@keyframes slashMove {
    0% { transform: translateX(0) rotate(0); opacity: 1; }
    50% { transform: translateX(5px) rotate(10deg); opacity: 0.5; }
    100% { transform: translateX(0) rotate(0); opacity: 1; }
}

.offline-slash-animate {
    animation: slashMove 0.6s ease forwards;
}

@media (max-width: 768px) {
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    button {
        padding: 0.5rem 1rem;
    }
    
    .tooltip:hover::before {
        bottom: auto;
        top: 100%;
        margin-top: 5px;
    }
    
    .tooltip:hover::after {
        bottom: auto;
        top: calc(100% - 5px);
        border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
    }
    
    html.dark .tooltip:hover::after {
        border-color: transparent transparent rgba(255, 255, 255, 0.8) transparent;
    }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(5deg); }
}

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

#sourceText, .target-text-container {
    transition: opacity 0.3s ease-in-out;
}

.target-text-container p {
    transition: opacity 0.3s ease-in-out;
}

@keyframes fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    z-index: 9999;
    border-radius: 50%;
    pointer-events: none;
}
