:root {
    --background-color: #111827; /* bg-gray-900 */
    --card-background: #1f2937;   /* bg-gray-800 */
    --border-color: #374151;      /* border-gray-700 */
    --text-primary: #f3f4f6;       /* text-gray-100 */
    --text-secondary: #9ca3af;    /* text-gray-400 */
    --accent-color: #2dd4bf;      /* teal-400 */
    --accent-hover: #5eead4;      /* teal-300 */
    --nav-background: rgba(31, 41, 55, 0.95); /* bg-gray-800/95 */
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--background-color);
    font-family: 'Poppins', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    padding: 0;
    scroll-behavior: smooth;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
}

/* Accessibility improvements */
.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;
}

.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: 0.5rem 1rem;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Navigation Styles */
.nav-link {
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
    font-weight: 500;
    position: relative;
}

.nav-link:hover,
.nav-link:focus {
    color: var(--text-primary);
    background-color: rgba(75, 85, 99, 0.5);
    outline: none;
}

.nav-link.active {
    color: var(--accent-color);
    background-color: rgba(45, 212, 191, 0.1);
}

.mobile-nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

.mobile-nav-link:hover,
.mobile-nav-link:focus {
    color: var(--text-primary);
    background-color: rgba(75, 85, 99, 0.5);
    outline: none;
}

/* Language Switcher */
.language-dropdown {
    backdrop-filter: blur(8px);
    z-index: 50;
}

.language-option,
.mobile-language-option {
    color: var(--text-secondary);
    transition: all 0.2s ease-in-out;
    border: none;
    background: none;
    font-family: inherit;
    font-size: inherit;
}

.language-option:hover,
.language-option:focus,
.mobile-language-option:hover,
.mobile-language-option:focus {
    color: var(--text-primary);
    outline: none;
}

.language-option.active,
.mobile-language-option.active {
    color: var(--accent-color);
    font-weight: 600;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    transition: all 0.2s ease-in-out;
}

.mobile-menu-btn:hover,
.mobile-menu-btn:focus {
    outline: none;
    background-color: rgba(75, 85, 99, 0.5);
    border-radius: 0.375rem;
    padding: 0.5rem;
}

/* Filter Buttons */
.filter-btn {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    white-space: nowrap;
}

.filter-btn:hover,
.filter-btn:focus {
    background-color: #374151;
    color: var(--text-primary);
    outline: none;
    transform: translateY(-1px);
}

.filter-btn.active {
    background-color: var(--accent-color);
    color: var(--background-color);
    border-color: var(--accent-color);
    font-weight: 600;
    box-shadow: 0 0 15px rgba(45, 212, 191, 0.3);
}

/* Tool Cards */
.tool-card {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-hover));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.tool-card:hover::before {
    transform: scaleX(1);
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2), 0 0 20px rgba(45, 212, 191, 0.1);
}

.tool-card h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.tool-card p {
    color: var(--text-secondary);
    flex-grow: 1;
    line-height: 1.6;
}

.card-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

.visit-btn, .copy-btn {
    flex-grow: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.875rem;
    min-height: 44px; /* Accessibility: minimum touch target */
}

.visit-btn {
    background-color: var(--accent-color);
    color: var(--background-color);
    border: 1px solid var(--accent-color);
}

.visit-btn:hover,
.visit-btn:focus {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    outline: none;
    transform: translateY(-1px);
}

.copy-btn {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.copy-btn:hover,
.copy-btn:focus {
    background-color: var(--border-color);
    color: var(--text-primary);
    outline: none;
    transform: translateY(-1px);
}

.copy-btn:disabled {
    background-color: var(--accent-color);
    color: var(--background-color);
    border-color: var(--accent-color);
    cursor: not-allowed;
    transform: none;
}

.visit-btn .lucide, .copy-btn .lucide {
    margin-left: 0.5rem;
}

/* Loading Animation */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--text-secondary);
    border-bottom-color: var(--accent-color);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Smooth Scrolling and Focus Management */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --background-color: #000000;
        --card-background: #1a1a1a;
        --border-color: #ffffff;
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --accent-color: #00ffff;
        --accent-hover: #66ffff;
    }
}

/* Print styles */
@media print {
    .nav, .mobile-menu, .language-dropdown {
        display: none !important;
    }
    
    .tool-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .sticky {
        top: 60px; /* Account for mobile nav height */
    }
    
    #category-filters {
        gap: 0.5rem;
        padding: 0 0.5rem;
    }
    
    .filter-btn {
        font-size: 0.8125rem;
        padding: 0.4rem 0.8rem;
    }
}

@media (max-width: 640px) {
    header h1 {
        font-size: 2.25rem;
        line-height: 2.5rem;
    }
    
    header p {
        font-size: 1rem;
        padding: 0 1rem;
    }
    
    .tool-card {
        padding: 1.25rem;
    }
    
    .card-actions {
        gap: 0.5rem;
    }
    
    .visit-btn, .copy-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 375px) {
    header h1 {
        font-size: 1.875rem;
        line-height: 2.25rem;
    }

    .sticky {
        padding-top: 1rem;
        padding-bottom: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .tool-card {
        padding: 1rem;
    }

    .card-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .visit-btn, .copy-btn {
        width: 100%;
    }
    
    #category-filters {
        gap: 0.25rem;
    }
    
    .filter-btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
}

/* Large screens optimization */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
    
    #tools-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (min-width: 1920px) {
    #tools-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

/* Focus indicators for better accessibility */
button:focus,
input:focus,
a:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
