/**
 * Character Counter - Custom Styles
 * Advanced styling with animations and responsive design
 */

/* Enhanced input styles */
.character-counter-textarea {
    transition: all 0.3s ease;
    resize: vertical;
    min-height: 256px;
    font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
    line-height: 1.6;
}

.character-counter-textarea:focus {
    transform: scale(1.005);
    box-shadow: 0 20px 40px rgba(59, 130, 246, 0.15);
}

/* Real-time counter styling */
.realtime-counter {
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.9);
}

.realtime-counter.warning {
    background: rgba(251, 191, 36, 0.9);
    color: #92400e;
}

.realtime-counter.danger {
    background: rgba(239, 68, 68, 0.9);
    color: #991b1b;
}

/* 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.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.quick-action-btn:hover::before {
    width: 200px;
    height: 200px;
}

.quick-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.quick-action-btn:active {
    transform: translateY(0);
}

/* Loading spinner animation */
.loading-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Tab navigation styles */
.tab-button {
    transition: all 0.3s ease;
    position: relative;
}

.tab-button:not(.active) {
    color: #6b7280;
}

.tab-button:not(.active):hover {
    color: #374151;
    background: rgba(59, 130, 246, 0.1);
}

.tab-button.active {
    background: #2563eb;
    color: white;
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* Statistics cards animations */
.stat-card {
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
}

/* Quick stats banner */
.quick-stats-banner {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    position: relative;
    overflow: hidden;
}

.quick-stats-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 shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* 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.2), transparent);
    transition: left 0.6s;
}

.export-btn:hover::before {
    left: 100%;
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* Character frequency visualization */
.char-frequency-item {
    transition: all 0.3s ease;
    cursor: pointer;
}

.char-frequency-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.char-display {
    font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
    font-weight: bold;
    font-size: 14px;
}

/* Progress bars for character frequency */
.frequency-bar {
    height: 6px;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: 3px;
    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: progress-shimmer 2s infinite;
}

@keyframes progress-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Responsive character grid */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

@media (max-width: 640px) {
    .char-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 6px;
    }
}

/* Statistics display enhancements */
.stat-item {
    transition: all 0.3s ease;
    border-radius: 8px;
    padding: 12px;
}

.stat-item:hover {
    background: rgba(59, 130, 246, 0.05);
    transform: translateX(4px);
}

.stat-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Typing speed visualization */
.typing-speed-card {
    position: relative;
    overflow: hidden;
}

.typing-speed-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #10b981, #059669);
    border-radius: 0 0 4px 4px;
}

/* Text analysis insights */
.insight-card {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.insight-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Common words visualization */
.word-tag {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.word-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;
}

.word-tag:hover::before {
    left: 100%;
}

.word-tag:hover {
    transform: scale(1.05);
}

/* Loading state overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 50;
}

/* Toast notification enhancements */
.toast-notification {
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.toast-notification.show {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.toast-notification.hide {
    transform: translateY(100%) scale(0.9);
    opacity: 0;
}

/* Analysis options panel */
.options-panel {
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.option-group {
    border-left: 3px solid transparent;
    transition: border-color 0.3s ease;
    padding-left: 12px;
}

.option-group:hover {
    border-left-color: #3b82f6;
}

/* Custom checkbox styling */
.custom-checkbox {
    appearance: none;
    width: 16px;
    height: 16px;
    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: 10px;
    font-weight: bold;
}

.custom-checkbox:hover {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Responsive design enhancements */
@media (max-width: 768px) {
    .character-counter-textarea {
        min-height: 200px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .character-counter-textarea:focus {
        transform: none;
    }

    .stat-card:hover {
        transform: none;
    }

    .quick-action-btn {
        padding: 8px 12px;
        font-size: 14px;
    }

    .tab-button {
        padding: 8px 12px;
        font-size: 14px;
    }
}

@media (max-width: 640px) {
    .quick-stats-banner .grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .stat-item:hover {
        transform: none;
    }

    .export-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Print styles */
@media print {
    .quick-action-btn,
    .export-btn,
    .tab-button,
    .loading-overlay {
        display: none;
    }

    .character-counter-textarea {
        border: 1px solid #000;
        background: white;
    }

    .stat-card {
        border: 1px solid #000;
        margin-bottom: 16px;
        break-inside: avoid;
    }

    .quick-stats-banner {
        background: #f3f4f6 !important;
        color: #000 !important;
        border: 1px solid #000;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .character-counter-textarea {
        background-color: #1f2937;
        color: #f9fafb;
        border-color: #374151;
    }

    .stat-card {
        background-color: #1f2937;
        border-color: #374151;
    }

    .options-panel {
        background-color: #1f2937;
    }

    .insight-card {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
        border-color: #374151;
    }
}

/* 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;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .character-counter-textarea,
    .stat-card,
    .export-btn,
    .tab-button {
        border: 2px solid;
    }

    .quick-stats-banner {
        background: #000 !important;
        color: #fff !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .character-counter-textarea:focus {
        transform: none;
    }

    .stat-card:hover,
    .quick-action-btn:hover,
    .export-btn:hover {
        transform: none;
    }
}

/* Enhanced button gradients */
.gradient-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.gradient-btn:hover {
    background: linear-gradient(135deg, #6366f1 0%, #3b82f6 100%);
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(59, 130, 246, 0.4);
}

.gradient-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.4);
}

/* 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;
}

/* Fade in animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* Slide in animations */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out;
}

/* Scale in animations */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}
