/**
 * SEO Tools Enhancements CSS
 * Additional styles for improved UX, animations, and visual feedback
 */

/* ============================================
   Accessibility Enhancements
   ============================================ */

/* Skip Link */
.skip-link {
    position: fixed;
    top: -40px;
    right: 0;
    background: var(--primary, #6366f1);
    color: white;
    padding: 12px 24px;
    text-decoration: none;
    border-radius: 0 0 8px 8px;
    z-index: 10000;
    font-weight: 600;
    transition: top 0.3s ease;
    display: block;
    visibility: visible;
    opacity: 1;
}

.skip-link:focus,
.skip-link:active,
.skip-link:hover {
    top: 0;
    outline: 3px solid var(--accent, #10b981);
    outline-offset: 2px;
}

/* Enhanced Focus Indicators */
*:focus {
    outline: 2px solid var(--accent, #10b981);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

*:focus-visible {
    outline: 3px solid var(--accent, #10b981);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Button Focus States */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--accent, #10b981);
    outline-offset: 3px;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

/* Keyboard Navigation Indicators */
.keyboard-nav-active *:focus-visible {
    outline-width: 4px;
    outline-offset: 4px;
}

/* Screen Reader Only Content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ARIA Live Regions */
[aria-live] {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

[aria-live="polite"],
[aria-live="assertive"] {
    position: static;
    left: auto;
    width: auto;
    height: auto;
    overflow: visible;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    *:focus-visible {
        outline: 4px solid;
        outline-offset: 4px;
    }
    
    button,
    a,
    input,
    select,
    textarea {
        border-width: 2px;
    }
}

/* 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;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   Error Handler Styles
   ============================================ */

.error-container {
    position: relative;
    margin-bottom: 20px;
    z-index: 1000;
}

.error-alert {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 16px 20px;
    border-radius: 12px;
    border: 2px solid;
    background: var(--card-bg, #ffffff);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    animation: slideInDown 0.3s ease-out;
    transition: all 0.3s ease;
}

.error-alert.error-show {
    opacity: 1;
    transform: translateY(0);
}

.error-alert.error-hide {
    opacity: 0;
    transform: translateY(-10px);
}

.error-alert.error-error {
    border-color: rgba(239, 68, 68, 0.3);
    background: linear-gradient(135deg, var(--card-bg, #ffffff), rgba(239, 68, 68, 0.05));
}

.error-alert.error-warning {
    border-color: rgba(245, 158, 11, 0.3);
    background: linear-gradient(135deg, var(--card-bg, #ffffff), rgba(245, 158, 11, 0.05));
}

.error-alert.error-info {
    border-color: rgba(59, 130, 246, 0.3);
    background: linear-gradient(135deg, var(--card-bg, #ffffff), rgba(59, 130, 246, 0.05));
}

.error-alert.error-success {
    border-color: rgba(34, 197, 94, 0.3);
    background: linear-gradient(135deg, var(--card-bg, #ffffff), rgba(34, 197, 94, 0.05));
}

.error-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.error-alert.error-error .error-icon {
    color: #ef4444;
}

.error-alert.error-warning .error-icon {
    color: #f59e0b;
}

.error-alert.error-info .error-icon {
    color: #3b82f6;
}

.error-alert.error-success .error-icon {
    color: #22c55e;
}

.error-content {
    flex: 1;
    min-width: 0;
}

.error-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-main, #1f2937);
}

.error-message {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted, #6b7280);
}

.error-retry-btn,
.error-dismiss-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    background: transparent;
}

.error-retry-btn {
    color: var(--accent, #6366f1);
    border: 1px solid var(--accent, #6366f1);
}

.error-retry-btn:hover {
    background: var(--accent, #6366f1);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.error-dismiss-btn {
    color: var(--text-muted, #6b7280);
    padding: 4px 8px;
}

.error-dismiss-btn:hover {
    color: var(--text-main, #1f2937);
    background: rgba(0, 0, 0, 0.05);
}

/* ============================================
   Loading States Enhancements
   ============================================ */

.loading-skeleton {
    background: linear-gradient(90deg, 
        var(--bg-dark, #f3f4f6) 0%, 
        rgba(255, 255, 255, 0.5) 50%, 
        var(--bg-dark, #f3f4f6) 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--accent, #6366f1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Progress Bar Enhancements
   ============================================ */

.progress-bar-enhanced {
    position: relative;
    width: 100%;
    height: 12px;
    background: var(--bg-dark, #f3f4f6);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669, #047857, #10b981);
    background-size: 200% 100%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-radius: 8px;
    animation: progress-shimmer 2s linear infinite;
}

@keyframes progress-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progress-glow 2s linear infinite;
}

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

/* ============================================
   Animations
   ============================================ */

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-in-up {
    animation: slideInUp 0.3s ease-out;
}

/* ============================================
   Micro-interactions
   ============================================ */

.interactive-element {
    transition: all 0.2s ease;
}

.interactive-element:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.interactive-element:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Empty States
   ============================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted, #6b7280);
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--text-muted, #9ca3af);
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main, #1f2937);
    margin-bottom: 10px;
}

.empty-state-description {
    font-size: 1rem;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto 30px;
}

/* ============================================
   Responsive Improvements
   ============================================ */

@media (max-width: 768px) {
    .error-alert {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }

    .error-retry-btn,
    .error-dismiss-btn {
        width: 100%;
        justify-content: center;
    }

    .empty-state {
        padding: 40px 15px;
    }

    .empty-state-icon {
        font-size: 3rem;
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */

[data-theme="dark"] .error-alert {
    background: var(--card-bg, #1f2937);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .loading-skeleton {
    background: linear-gradient(90deg, 
        rgba(31, 41, 55, 0.8) 0%, 
        rgba(55, 65, 81, 0.5) 50%, 
        rgba(31, 41, 55, 0.8) 100%);
    background-size: 200% 100%;
}

[data-theme="dark"] .progress-bar-enhanced {
    background: rgba(31, 41, 55, 0.8);
}

/* ============================================
   Validation Styles
   ============================================ */

.validation-input-wrapper {
    position: relative;
    width: 100%;
}

.validation-error {
    border-color: #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.05) !important;
}

.validation-success {
    border-color: #22c55e !important;
    background-color: rgba(34, 197, 94, 0.05) !important;
}

.validation-error-message {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: slideInDown 0.3s ease-out;
}

.validation-success-message {
    color: #22c55e;
    font-size: 0.85rem;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.validation-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    pointer-events: none;
    z-index: 10;
}

[dir="rtl"] .validation-icon {
    right: auto;
    left: 12px;
}

.validation-icon-error {
    color: #ef4444;
}

.validation-icon-success {
    color: #22c55e;
}

/* Input focus states */
.validation-error:focus {
    outline: 2px solid rgba(239, 68, 68, 0.5);
    outline-offset: 2px;
}

.validation-success:focus {
    outline: 2px solid rgba(34, 197, 94, 0.5);
    outline-offset: 2px;
}

/* ============================================
   Accessibility Improvements
   ============================================ */

/* Note: Skip link, focus indicators, sr-only, and aria-live styles are already defined above in Accessibility Enhancements section (lines 11-104) */

/* ============================================
   Performance Improvements
   ============================================ */

/* Lazy loading images */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[data-src].loaded,
img[loading="lazy"].loaded {
    opacity: 1;
}

/* Debounce visual feedback */
.debounced-input {
    transition: border-color 0.3s ease;
}

/* Content visibility for performance */
.content-hidden,
.off-screen {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

/* ============================================
   Export Buttons Styles
   ============================================ */

.export-btn {
    transition: all 0.2s ease;
}

.export-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.export-btn:active {
    transform: translateY(0);
}

.export-btn:focus-visible {
    outline: 3px solid var(--accent, #6366f1);
    outline-offset: 2px;
}

/* ============================================
   Historical Comparison Styles
   ============================================ */

.historical-comparison {
    animation: fadeIn 0.3s ease-out;
}

.comparison-summary .summary-card {
    transition: transform 0.2s ease;
}

.comparison-summary .summary-card:hover {
    transform: scale(1.05);
}

/* ============================================
   Recommendations Styles
   ============================================ */

.recommendations-container {
    animation: slideInUp 0.3s ease-out;
}

.recommendation-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.recommendation-card a {
    transition: all 0.2s ease;
}

.recommendation-card a:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: translateX(-2px);
}

/* ============================================
   UI/UX Enhancements
   ============================================ */

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Micro-interactions */
.btn-primary,
.btn-secondary,
.export-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary::before,
.btn-secondary::before,
.export-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:active::before,
.btn-secondary:active::before,
.export-btn:active::before {
    width: 300px;
    height: 300px;
}

/* Color Coding */
.status-good {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
}

.status-warning {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.status-error {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.status-info {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

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

.tooltip .tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark, #1f2937);
    color: var(--text-main, #ffffff);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    white-space: nowrap;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tooltip .tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--bg-dark, #1f2937);
}

.tooltip:hover .tooltip-text,
.tooltip:focus .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-bottom: 20px;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 10px;
}

.empty-state-description {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 30px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state-action {
    display: inline-block;
    padding: 12px 24px;
    background: var(--primary, #6366f1);
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.empty-state-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 246, 0.4);
}

/* Interactive Features */
.filter-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-dark, #f9fafb);
    border-radius: 12px;
    border: 2px solid var(--border, #e5e7eb);
}

.filter-item {
    padding: 8px 16px;
    background: var(--card-bg, #ffffff);
    border: 2px solid var(--border, #e5e7eb);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.filter-item:hover {
    border-color: var(--accent, #10b981);
    transform: translateY(-2px);
}

.filter-item.active {
    background: var(--accent, #10b981);
    color: white;
    border-color: var(--accent, #10b981);
}

.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 12px 45px 12px 16px;
    border-radius: 10px;
    border: 2px solid var(--border, #e5e7eb);
    background: var(--card-bg, #ffffff);
    color: var(--text-main);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.search-box input:focus {
    border-color: var(--accent, #10b981);
    outline: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.search-box-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.pagination-button {
    padding: 10px 16px;
    background: var(--card-bg, #ffffff);
    border: 2px solid var(--border, #e5e7eb);
    border-radius: 8px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

.pagination-button:hover:not(:disabled) {
    border-color: var(--accent, #10b981);
    transform: translateY(-2px);
}

.pagination-button.active {
    background: var(--accent, #10b981);
    color: white;
    border-color: var(--accent, #10b981);
}

.pagination-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, 
        var(--bg-dark, #f0f0f0) 25%, 
        var(--bg-secondary, #e0e0e0) 50%, 
        var(--bg-dark, #f0f0f0) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-title {
    height: 1.5rem;
    width: 60%;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

/* Smooth Transitions */
* {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Hover Effects */
.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Note: Focus states for interactive elements are already defined above in Accessibility Enhancements section (lines 48-56) */

/* Responsive Enhancements */
@media (max-width: 768px) {
    .filter-container {
        flex-direction: column;
    }
    
    .filter-item {
        width: 100%;
    }
    
    .pagination {
        gap: 4px;
    }
    
    .pagination-button {
        padding: 8px 12px;
        font-size: 0.875rem;
    }
}

