/* styles.css - Foglio di stile principale COMPLETO */

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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #667eea, #764ba2);
    --card-shadow: 0 8px 32px rgba(0,0,0,0.1);
    --card-shadow-hover: 0 20px 40px rgba(0,0,0,0.15);
    --border-color: rgba(0,0,0,0.05);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --bg-white: white;
    --bg-glass: rgba(255, 255, 255, 0.95);
    --bg-glass-light: rgba(255, 255, 255, 0.2);
    --bg-glass-dark: rgba(255, 255, 255, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Header Styles */
.header {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    padding: 20px 0;
    box-shadow: var(--card-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--secondary-gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* Search Styles */
.search-container {
    position: relative;
    max-width: 400px;
    width: 100%;
}

.search-bar {
    width: 100%;
    padding: 12px 20px 12px 50px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 16px;
    background: var(--bg-white);
    transition: all 0.3s ease;
}

.search-bar:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Main Content */
.main {
    padding: 40px 0;
}

/* Stats Section */
.stats {
    text-align: center;
    margin-bottom: 40px;
}

.stats-text {
    color: rgba(255,255,255,0.9);
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.stats-highlight {
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Filter Buttons */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--bg-glass-dark);
    background: var(--bg-glass-light);
    color: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.filter-btn:hover, 
.filter-btn.active {
    background: rgba(255,255,255,0.9);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.9);
}

/* Advanced Filters */
.advanced-filters-toggle {
    text-align: center;
    margin: 24px 0 16px;
}

.toggle-btn {
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.25);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(10px);
}

.toggle-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.toggle-btn.active {
    background: rgba(255,255,255,0.95);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.95);
}

.toggle-icon {
    transition: transform 0.3s ease;
    font-size: 12px;
}

.toggle-btn.active .toggle-icon {
    transform: rotate(180deg);
}

.advanced-filters-panel {
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 28px;
    margin: 16px 0 32px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    transform: translateY(-10px);
    opacity: 0;
    animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.filter-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-select {
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    background: white;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.filter-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 2px solid #f3f4f6;
}

.btn-clear {
    padding: 10px 20px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-clear:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.3);
}

.results-info {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 8px 16px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    margin-top: 30px;
    contain: layout;
}

/* Tool Cards */
.tool-card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    contain: layout style paint;
    will-change: transform;
}

.tool-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-shadow-hover);
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    transition: left 0.5s ease;
}

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

.tool-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    position: relative;
}

.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
}

.tool-icon img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.tool-header-text {
    flex: 1;
}

.tool-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.tool-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    margin-top: 2px;
}

.stars {
    line-height: 1;
    letter-spacing: 1px;
}

.rating-text {
    color: var(--text-secondary);
    font-weight: 600;
}

.tool-bookmark {
    position: absolute;
    top: -4px;
    right: -4px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 2;
}

.tool-bookmark:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.bookmark-icon {
    font-size: 18px;
    color: #d1d5db;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.bookmark-icon.active {
    color: #f59e0b;
    transform: scale(1.1);
}

.tool-description {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.tool-tags {
    margin-bottom: 14px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag-small {
    padding: 3px 8px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    color: #64748b;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

.tag-small:hover {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    transform: translateY(-1px);
}

/* Tool Meta Tags */
.tool-meta {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tag {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag-free { 
    background: #d1fae5; 
    color: #047857; 
}

.tag-freemium { 
    background: #dbeafe; 
    color: 1d4ed8; 
}

.tag-paid { 
    background: #fee2e2; 
    color: #dc2626; 
}

.tag-category { 
    background: #f3e8ff; 
    color: #7c3aed; 
}

.tag-rating { 
    background: #fef3c7; 
    color: #d97706; 
}

/* Tool Actions */
.tool-actions {
    display: flex;
    gap: 8px;
}

.btn-primary {
    flex: 1;
    padding: 12px 20px;
    background: var(--secondary-gradient);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    will-change: transform;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
    color: white;
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

.btn-secondary {
    padding: 12px 14px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    color: var(--text-secondary);
    font-size: 16px;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
    border-color: #cbd5e1;
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255,255,255,0.8);
}

.no-results h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

/* Footer */
.footer {
    background: rgba(0,0,0,0.8);
    color: white;
    text-align: center;
    padding: 40px 0;
    margin-top: 60px;
}

.footer p {
    margin: 0;
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
    color: rgba(255,255,255,0.8);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

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

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

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

/* Focus styles for accessibility */
.filter-btn:focus,
.btn-primary:focus,
.search-bar:focus,
.filter-select:focus,
.toggle-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.tool-card:focus-within {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: rgba(102, 126, 234, 0.2);
    color: inherit;
}

::-moz-selection {
    background: rgba(102, 126, 234, 0.2);
    color: inherit;
}

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

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

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

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a67d8, #6b46c1);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .advanced-filters-panel {
        margin: 16px;
        padding: 20px;
    }
    
    .filter-section {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .tool-card {
        padding: 20px;
    }
    
    .stats-highlight {
        font-size: 2rem;
    }
    
    .filters {
        justify-content: flex-start;
        overflow-x: auto;
        padding: 0 20px;
    }
    
    .filter-btn {
        white-space: nowrap;
    }

    .filter-section {
        grid-template-columns: 1fr;
    }
    
    .filter-actions {
        flex-direction: column;
        gap: 16px;
    }
    
    .results-info {
        order: -1;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .tool-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .tool-meta {
        justify-content: center;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .stats-highlight {
        font-size: 1.8rem;
    }

    .tool-bookmark {
        top: -8px;
        right: -8px;
        padding: 8px;
    }
    
    .bookmark-icon {
        font-size: 16px;
    }
    
    .advanced-filters-panel {
        margin: 8px;
        padding: 16px;
        border-radius: 16px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tool-card {
        border: 2px solid #000;
    }
    
    .btn-primary {
        border: 2px solid #000;
    }
    
    .filter-btn {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .tool-card:hover {
        transform: none;
    }
    
    .btn-primary:hover {
        transform: none;
    }
    
    .loading-skeleton {
        animation: none;
        background: #f0f0f0;
    }
}

/* Print styles */
@media print {
    .header,
    .filters,
    .advanced-filters-toggle,
    .advanced-filters-panel,
    .footer {
        display: none;
    }
    
    .tool-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .tool-actions,
    .tool-bookmark {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
}