/**
 * Anagram Generator - Custom Styles
 * Advanced styling for the anagram generation tool with animations and responsive design
 */

/* Tool-specific styling */
.anagram-generator-container {
    min-height: calc(100vh - 200px);
}

/* Form styling */
.anagram-form {
    transition: all 0.3s ease;
}

.anagram-form:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Input enhancements */
#inputText {
    transition: all 0.3s ease;
    resize: vertical;
    min-height: 120px;
}

#inputText:focus {
    ring-color: rgba(147, 51, 234, 0.5);
    border-color: rgb(147, 51, 234);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

/* Character count styling */
#inputText + div {
    transition: all 0.2s ease;
}

#inputText:focus + div {
    color: rgb(147, 51, 234);
    transform: scale(1.05);
}

/* Button styling */
.btn-gradient {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-gradient: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-gradient:hover:before {
    left: 100%;
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(139, 92, 246, 0.4);
}

.btn-gradient:disabled {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Quick action buttons */
.quick-action-btn {
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.quick-action-btn:hover {
    transform: translateY(-1px);
    border-color: currentColor;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Real-time counters */
.counter-badge {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Counter value animations */
#letterCount,
#uniqueLetters,
#wordCount,
#possibleCombinations {
    transition: all 0.3s ease;
}

#letterCount.updated,
#uniqueLetters.updated,
#wordCount.updated,
#possibleCombinations.updated {
    animation: pulse 0.3s ease;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Options panel */
.options-panel {
    transition: all 0.3s ease;
}

#optionsIcon {
    transition: transform 0.3s ease;
}

/* Tab styling */
.tab-button {
    transition: all 0.3s ease;
    position: relative;
}

.tab-button:not(.active):hover {
    background-color: rgba(147, 51, 234, 0.1);
    color: rgb(147, 51, 234);
}

.tab-button.active::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #8b5cf6, #ec4899);
    border-radius: 2px;
}

/* Tab content animations */
.tab-content {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Results banner */
.results-banner {
    animation: slideInDown 0.5s ease;
    position: relative;
    overflow: hidden;
}

.results-banner::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Anagram items */
.anagram-item {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.anagram-item:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.2);
    z-index: 10;
}

.anagram-item:active {
    transform: translateY(0) scale(0.98);
}

/* Anagram item click effect */
.anagram-item::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.anagram-item:active::before {
    width: 200px;
    height: 200px;
}

/* Anagram group animations */
.anagram-group {
    animation: slideInLeft 0.6s ease;
}

.anagram-group:nth-child(2) {
    animation-delay: 0.1s;
}

.anagram-group:nth-child(3) {
    animation-delay: 0.2s;
}

.anagram-group:nth-child(4) {
    animation-delay: 0.3s;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Loading state */
.loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.loading-dots {
    display: inline-flex;
    gap: 0.25rem;
}

.loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    animation: loadingBounce 1.4s infinite both;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingBounce {
    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Export buttons */
.export-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.export-btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.export-btn:hover::before {
    width: 300px;
    height: 300px;
}

.export-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.export-btn:active {
    transform: translateY(-2px) scale(0.98);
}

/* Filter and search styling */
#filterLength,
#searchAnagrams {
    transition: all 0.2s ease;
}

#filterLength:focus,
#searchAnagrams:focus {
    ring-color: rgba(147, 51, 234, 0.5);
    border-color: rgb(147, 51, 234);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

/* Pagination styling */
nav[aria-label="Pagination"] button {
    transition: all 0.2s ease;
}

nav[aria-label="Pagination"] button:hover {
    background-color: rgba(147, 51, 234, 0.1);
    border-color: rgb(147, 51, 234);
    color: rgb(147, 51, 234);
}

/* Statistics cards */
.stats-card {
    transition: all 0.3s ease;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Analysis sections */
.analysis-section {
    animation: fadeInUp 0.6s ease;
}

.analysis-section:nth-child(2) {
    animation-delay: 0.1s;
}

.analysis-section:nth-child(3) {
    animation-delay: 0.2s;
}

.analysis-section:nth-child(4) {
    animation-delay: 0.3s;
}

/* Toast notifications */
.toast {
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    animation: slideInUp 0.5s ease;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Copy feedback effect */
.copy-feedback {
    animation: copyPulse 0.6s ease;
}

@keyframes copyPulse {
    0% {
        background-color: rgba(34, 197, 94, 0.1);
        transform: scale(1);
    }
    50% {
        background-color: rgba(34, 197, 94, 0.3);
        transform: scale(1.05);
    }
    100% {
        background-color: rgba(34, 197, 94, 0.1);
        transform: scale(1);
    }
}

/* Input validation states */
.input-valid {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
}

.input-warning {
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1) !important;
}

.input-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .anagram-item {
        margin-bottom: 0.5rem;
    }

    .tab-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .quick-action-btn {
        width: 100%;
        margin-bottom: 0.5rem;
        justify-content: center;
    }

    .export-btn {
        margin-bottom: 1rem;
    }

    #inputText {
        min-height: 100px;
    }

    .btn-gradient {
        width: 100%;
        margin-bottom: 1rem;
    }
}

@media (max-width: 640px) {
    .anagram-item {
        font-size: 0.875rem;
        padding: 0.5rem;
    }

    .tab-button {
        flex: 1;
        text-align: center;
        padding: 0.75rem 0.5rem;
    }

    .counter-badge {
        padding: 1rem;
    }

    .counter-badge > div:first-child {
        font-size: 1.5rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .anagram-form {
        background-color: rgba(31, 41, 55, 0.8);
        border-color: rgba(75, 85, 99, 0.5);
    }

    .anagram-item:hover {
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    }
}

/* Accessibility improvements */
.btn-gradient:focus,
.quick-action-btn:focus,
.tab-button:focus,
.export-btn:focus,
.anagram-item:focus {
    outline: 2px solid rgb(147, 51, 234);
    outline-offset: 2px;
}

/* Keyboard navigation */
.anagram-item:focus {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    color: white;
    transform: translateY(-2px) scale(1.02);
}

/* Print styles */
@media print {
    .quick-action-btn,
    .export-btn,
    .btn-gradient,
    .tab-button {
        display: none;
    }

    .tab-content {
        display: block !important;
    }

    .results-banner {
        background: none !important;
        color: black !important;
    }

    .anagram-item {
        break-inside: avoid;
        margin-bottom: 0.5rem;
        border: 1px solid #000;
        background: white !important;
        color: black !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn-gradient {
        background: #000;
        border: 2px solid #fff;
    }

    .anagram-item {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }

    .tab-button.active {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .loading-spinner,
    .loading-dot {
        animation: none;
    }

    .anagram-item:hover {
        transform: none;
    }
}

/* Custom scrollbar for results */
#anagramsList::-webkit-scrollbar {
    width: 8px;
}

#anagramsList::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

#anagramsList::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    border-radius: 4px;
}

#anagramsList::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #7c3aed, #db2777);
}

/* Gradient text effects */
.gradient-text {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Floating animation for header icon */
.header-icon {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%,
    100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Success highlight animation */
.success-highlight {
    animation: successGlow 1s ease;
}

@keyframes successGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}
