/**
 * Word Frequency Counter - Custom Styles
 * Advanced styling with animations and responsive design
 */

/* Loading animation for the analyze button */
.analyze-btn-loading {
    position: relative;
    pointer-events: none;
}

.analyze-btn-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Enhanced input styles */
.word-freq-textarea {
    transition: all 0.3s ease;
    resize: vertical;
    min-height: 200px;
}

.word-freq-textarea:focus {
    transform: scale(1.01);
    box-shadow: 0 10px 25px rgba(59, 130, 246, 0.15);
}

/* Character counter styling */
.char-counter {
    transition: color 0.3s ease;
}

.char-counter.warning {
    color: #f59e0b !important;
}

.char-counter.danger {
    color: #ef4444 !important;
}

/* Quick action buttons */
.quick-action-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.quick-action-btn::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.quick-action-btn:hover::before {
    width: 300px;
    height: 300px;
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

/* Options panel animations */
.options-panel {
    transition: all 0.3s ease;
}

.options-panel.collapsed {
    max-height: 60px;
    overflow: hidden;
}

.options-panel.expanded {
    max-height: 1000px;
}

/* Form input enhancements */
.form-input-enhanced {
    transition: all 0.3s ease;
}

.form-input-enhanced:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

/* Checkbox and radio custom styles */
.custom-checkbox {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    background: white;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.custom-checkbox:checked {
    background: #3b82f6;
    border-color: #3b82f6;
}

.custom-checkbox:checked::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Statistics cards animations */
.stat-card {
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}

/* Results table enhancements */
.results-table {
    border-collapse: separate;
    border-spacing: 0;
}

.results-table th {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.results-table tr:hover {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.05), rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.05));
    transform: scale(1.01);
}

.results-table td {
    transition: all 0.3s ease;
}

/* Progress bars in table */
.frequency-bar {
    height: 20px;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: 10px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.frequency-bar::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Word cloud enhancements */
.word-cloud-container {
    perspective: 1000px;
}

.word-cloud-item {
    transition: all 0.3s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.word-cloud-item:hover {
    transform: scale(1.2) rotateX(10deg);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
    position: relative;
}

/* Export buttons */
.export-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.export-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s;
}

.export-btn:hover::before {
    left: 100%;
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

/* View mode toggle */
.view-mode-toggle {
    background: linear-gradient(45deg, #f3f4f6, #e5e7eb);
    border-radius: 8px;
    padding: 4px;
    display: flex;
    gap: 2px;
}

.view-mode-option {
    flex: 1;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    background: transparent;
    transition: all 0.3s ease;
    font-weight: 500;
}

.view-mode-option.active {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    color: #3b82f6;
}

/* Search box enhancements */
.search-box {
    position: relative;
}

.search-box::before {
    content: "🔍";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.6;
    z-index: 1;
}

.search-input {
    padding-left: 40px;
    transition: all 0.3s ease;
}

.search-input:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Loading state */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 50;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Toast notification enhancements */
.toast-notification {
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    backdrop-filter: blur(10px);
}

.toast-notification.show {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.toast-notification.hide {
    transform: translateY(100%) scale(0.9);
    opacity: 0;
}

/* Filter tags */
.filter-tag {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.filter-tag::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.filter-tag:hover::before {
    left: 100%;
}

/* Responsive enhancements */
@media (max-width: 768px) {
    .word-freq-textarea {
        min-height: 150px;
    }

    .stat-card {
        margin-bottom: 1rem;
    }

    .results-table {
        font-size: 14px;
    }

    .word-cloud-item {
        font-size: 0.8em !important;
        margin: 2px;
    }

    .quick-action-btn {
        padding: 8px 12px;
        font-size: 14px;
    }
}

@media (max-width: 640px) {
    .word-freq-textarea:focus {
        transform: none;
    }

    .stat-card:hover {
        transform: none;
    }

    .results-table tr:hover {
        transform: none;
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    .word-freq-textarea {
        background-color: #1f2937;
        color: #f9fafb;
        border-color: #374151;
    }

    .stat-card {
        background-color: #1f2937;
        border-color: #374151;
    }

    .results-table th {
        background-color: #1f2937;
        color: #f9fafb;
    }

    .word-cloud-container {
        background-color: #1f2937;
    }
}

/* Print styles */
@media print {
    .quick-action-btn,
    .export-btn,
    .view-mode-toggle,
    .search-box {
        display: none;
    }

    .word-freq-textarea {
        border: 1px solid #000;
        background: white;
    }

    .results-table {
        border-collapse: collapse;
    }

    .results-table th,
    .results-table td {
        border: 1px solid #000;
        padding: 8px;
    }
}

/* Accessibility improvements */
.focus-visible:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Scroll animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* Success state animations */
@keyframes successPulse {
    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);
    }
}

.success-pulse {
    animation: successPulse 2s;
}

/* Error state animations */
@keyframes errorShake {
    0%,
    100% {
        transform: translateX(0);
    }
    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }
    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.error-shake {
    animation: errorShake 0.6s;
}

/* Enhanced button gradients */
.gradient-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: all 0.3s ease;
}

.gradient-btn:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.gradient-btn:active {
    transform: translateY(0);
    box-shadow: 0 5px 10px rgba(102, 126, 234, 0.4);
}
