/* Design tokens are defined in css/tokens.css */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* A11y helpers */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
    border-radius: 6px;
}

/* Dark Scrollbar Styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #333333, #404040);
    border-radius: 6px;
    border: 2px solid #1a1a1a;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, #404040, #505050);
}

::-webkit-scrollbar-thumb:active {
    background: linear-gradient(45deg, #505050, #606060);
}

::-webkit-scrollbar-corner {
    background: #1a1a1a;
}

/* Firefox scrollbar styling */
* {
    scrollbar-width: thin;
    scrollbar-color: #333333 #1a1a1a;
}

body {
    background: var(--dark-bg);
    color: var(--dark-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition-normal), color var(--transition-normal);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.site-logo {
    max-height: 90px;
    width: auto;
}

/* Logo theme switching */
.logo-light {
    display: none;
}

.logo-dark {
    display: inline-block;
}

.light-theme .logo-light {
    display: inline-block;
}

.light-theme .logo-dark {
    display: none;
}

.lang-btn, .theme-btn, .share-btn {
    background: var(--dark-card-bg);
    border: 1px solid var(--dark-card-border);
    border-radius: var(--radius-sm);
    color: var(--dark-text);
    padding: 10px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-normal), transform var(--transition-fast);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 38px;
}

.theme-btn svg {
    transition: all var(--transition-normal);
}

.theme-btn:hover svg {
    transform: rotate(180deg) scale(1.1);
}

.lang-btn::before, .theme-btn::before, .share-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: var(--secondary-gradient);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width var(--transition-normal), height var(--transition-normal);
    z-index: -1;
}

.lang-btn:hover, .theme-btn:hover, .share-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-md);
}

.lang-btn:hover::before, .theme-btn:hover::before, .share-btn:hover::before {
    width: 100%;
    height: 100%;
}

.lang-btn:active, .theme-btn:active, .share-btn:active {
    transform: translateY(-1px) scale(1.02);
}

/* Light theme styles */
body.light-theme {
    background: var(--light-bg);
    color: var(--light-text);
}

.light-theme .container {
    color: #1a202c;
}

.light-theme h1 {
    background: var(--text-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.light-theme .subtitle {
    color: #64748b;
}

.light-theme .search-input {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #1a202c;
}

.light-theme .search-input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.2);
}

.light-theme .category {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.light-theme .category:hover {
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.light-theme .category-title {
    color: #1a202c;
}

.light-theme .tool-card {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.light-theme .tool-card:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.2);
}

.light-theme .tool-name {
    color: #1a202c;
}

.light-theme .lang-btn, .light-theme .theme-btn, .light-theme .share-btn {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #1a202c;
}

.light-theme .lang-btn:hover, .light-theme .theme-btn:hover, .light-theme .share-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
}

/* Share button specific */
.share-btn svg { transition: transform var(--transition-normal); }
.share-btn:hover svg { transform: scale(1.15) rotate(10deg); }
.share-btn:focus-visible { outline: 2px solid #f59e0b; outline-offset: 2px; }

.light-theme footer {
    border-top: 1px solid var(--light-card-border);
    color: #64748b;
}

/* Light Theme Scrollbar Styling */
.light-theme ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.light-theme ::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
}

.light-theme ::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #cbd5e1, #94a3b8);
    border-radius: 6px;
    border: 2px solid #f1f5f9;
}

.light-theme ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(45deg, #94a3b8, #64748b);
}

.light-theme ::-webkit-scrollbar-thumb:active {
    background: linear-gradient(45deg, #64748b, #475569);
}

.light-theme ::-webkit-scrollbar-corner {
    background: #f1f5f9;
}

/* Firefox scrollbar styling for light theme */
.light-theme * {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    background: var(--text-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    transition: transform var(--transition-fast);
}

h1:hover {
    transform: scale(1.02);
}

.subtitle {
    font-size: 1.2rem;
    color: #a0a0a0;
    margin-bottom: 30px;
}

.search-container {
    max-width: 600px;
    margin: 0 auto 40px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 15px 20px;
    padding-right: 44px; /* space for clear button */
    background: var(--dark-card-bg);
    border: 1px solid var(--dark-card-border);
    border-radius: var(--radius-xl);
    color: var(--dark-text);
    font-size: 1rem;
    outline: none;
    transition: all var(--transition-normal), transform var(--transition-fast);
}

/* Clear (X) button */
.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--dark-card-bg);
    border: 1px solid var(--dark-card-border);
    border-radius: var(--radius-pill);
    color: var(--dark-text);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal), transform var(--transition-fast), background var(--transition-normal), border-color var(--transition-normal);
}

.search-input:not(:placeholder-shown) ~ .search-clear {
    opacity: 1;
    pointer-events: auto;
}

.search-clear:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: var(--shadow-sm);
}

.search-clear:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

.light-theme .search-clear {
    background: rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.1);
    color: #1a202c;
}

.search-input:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.search-input:focus {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-lg);
}

.search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
}

.categories {
    /* Masonry-style layout using CSS columns for tight packing */
    column-count: 2;
    column-gap: 16px;
    margin-bottom: 20px;
}

.category {
    background: var(--dark-card-bg);
    border: 1px solid var(--dark-card-border);
    border-radius: var(--radius-md);
    padding: 16px;
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal), transform var(--transition-fast);
    display: flex;
    flex-direction: column;
    /* Masonry: avoid breaking across columns and keep spacing */
    break-inside: avoid;
    break-inside: avoid-column;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.category::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--secondary-gradient);
    transform: scaleX(0);
    transition: transform var(--transition-normal);
}

.category:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--dark-card-hover-border);
    background: var(--dark-card-hover-bg);
    box-shadow: var(--shadow-lg);
}

.category:hover::before {
    transform: scaleX(1);
}

.category-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #f0f0f0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.category-icon {
    width: 16px;
    height: 16px;
    background: linear-gradient(45deg, #6366f1, #8b5cf6);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
}

.tools-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tool-card {
    background: var(--dark-card-bg);
    border: 1px solid var(--dark-card-border);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    transition: all var(--transition-normal), transform var(--transition-fast);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    width: 100%;
    overflow: hidden;
}

.tool-card::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 var(--transition-normal);
}

.tool-card:hover {
    background: var(--dark-card-hover-bg);
    border-color: var(--dark-card-hover-border);
    transform: translateY(-3px) translateX(4px);
    box-shadow: var(--shadow-md);
}

.tool-card:hover::before {
    left: 100%;
}

.tool-card:active {
    transform: translateY(-1px) translateX(2px) scale(0.98);
}

.tool-icon-container {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-favicon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.tool-emoji-fallback {
    font-size: 1rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.tool-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #f0f0f0;
    flex: 1;
}

/* Pricing styles removed */

/* Ocultar elementos no necesarios en vista de iconos */
.tool-description,
.tool-tags {
    display: none;
}

/* Tooltip personalizado */
.tool-card[title] {
    position: relative;
}

.tool-card[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: 50%;
    transform: translate(-50%, calc(-100% - 8px));
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    z-index: 10000;
    pointer-events: none;
    max-width: 280px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tool-card[title]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Tooltip arrow */
.tool-card[title]:hover::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translate(-50%, calc(-100% - 2px));
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0, 0, 0, 0.95);
    z-index: 10001;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tool-card[title]:hover::before {
    opacity: 1;
    visibility: visible;
}

footer {
    text-align: center;
    margin-top: 60px;
    padding: 30px;
    border-top: 1px solid var(--dark-card-border);
    color: #888;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.footer-badges {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-link {
    margin-left: 1rem;
    text-decoration: none;
    color: inherit; /* mismo color que © */
    opacity: 1;
    transition: opacity var(--transition-normal), text-decoration-color var(--transition-normal);
}

.footer-link:link,
.footer-link:visited,
.footer-link:active,
.footer-link:focus,
.footer-link:focus-visible {
    color: inherit;
    text-decoration: none;
}

.footer-link:hover {
    opacity: 0.85;
    text-decoration: underline;
    text-decoration-color: currentColor;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--secondary-gradient);
    border-radius: var(--radius-xl);
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    cursor: default;
    position: relative;
    overflow: hidden;
}

.badge::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 var(--transition-slow);
}

.badge:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-md);
}

.badge:hover::before {
    left: 100%;
}

.badge svg {
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.open-source {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.open-source:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

/* Mobile First - Base styles above are mobile */

/* Small tablets and large phones */
@media (min-width: 480px) {
    .categories {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 12px;
    }
}

/* Tablets */
@media (min-width: 768px) {
    .container {
        padding: 20px;
    }
    
    .header-top {
        flex-direction: row;
        gap: 10px;
    }
    
    h1 {
        font-size: 2.5rem;
    }
    
    .categories {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 16px;
    }
    
    .category {
        padding: 16px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    h1 {
        font-size: 3rem;
    }
    
    .categories {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 20px;
    }
    
    .category {
        padding: 20px;
    }
    
    .search-container {
        max-width: 700px;
    }
}

/* Large desktop */
@media (min-width: 1440px) {
    .container {
        max-width: 1600px;
        padding: 24px;
    }
    .categories { column-count: 4; column-gap: 24px; }
    
    .search-container {
        max-width: 800px;
    }
}

/* Ultra-wide screens */
@media (min-width: 1920px) {
    .categories { column-count: 5; column-gap: 28px; }
}

/* Mobile-specific styles */
@media (max-width: 479px) {
    .container {
        padding: 15px;
    }
    
    .header-top {
        flex-direction: column;
        gap: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .categories { column-count: 1; column-gap: 12px; }
    
    .category {
        padding: 12px;
    }
    
    .tool-card {
        padding: 8px 10px;
        gap: 10px;
    }
    
    .tool-name {
        font-size: 0.85rem;
    }
    
    .search-input {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}
