/**
 * AI Tools Homepage Cards CSS
 * Unified Visual Identity - Matching Archive Design
 */

/* ===========================================
   GRID LAYOUT
   =========================================== */
.ai-tools-grid,
.ai-tools-cards-grid {
    display: grid;
    grid-template-columns: repeat(var(--cards-cols, 3), 1fr);
    gap: 18px;
    margin-top: 32px;
}

/* ===========================================
   CARD DESIGN - Unified Identity
   =========================================== */
.tool-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 22px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
    cursor: pointer;
    z-index: 1;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    min-height: 320px;
}

.tool-card:hover {
    border-color: #cbd5e1;
    transform: translateY(-5px);
    box-shadow: 0 20px 40px -8px rgba(37, 99, 235, 0.12);
    color: inherit;
    z-index: 2;
}

/* ===========================================
   CARD TOP - Icon + Meta (horizontal)
   =========================================== */
.card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0;
    background: transparent;
    border-bottom: none;
    margin-bottom: 0;
}

.tool-icon {
    width: 54px;
    height: 54px;
    min-width: 54px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 800;
    color: #ffffff;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.5), 0 2px 5px rgba(0, 0, 0, 0.03);
    transition: transform .3s ease;
}

.tool-card:hover .tool-icon {
    transform: scale(1.05) rotate(-2deg);
}

.tool-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tool-icon-letter {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
}

.tool-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tool-meta .tool-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.25;
    letter-spacing: -0.01em;
    transition: color .2s;
    display: block;
}

.tool-card:hover .tool-meta .tool-title {
    color: #2563eb;
}

/* ===========================================
   PRICING BADGES
   =========================================== */
.pricing-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    width: fit-content;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.pricing-free {
    color: #059669;
    background: #ecfdf5;
}

.pricing-freemium {
    color: #2563eb;
    background: #eff6ff;
}

.pricing-paid {
    color: #dc2626;
    background: #fef2f2;
}

.pricing-trial {
    color: #d97706;
    background: #fffbeb;
}

.pricing-contact {
    color: #7c3aed;
    background: #f5f3ff;
}

/* ===========================================
   DESCRIPTION SECTION
   =========================================== */
.tool-desc {
    font-size: 0.88rem;
    color: #475569;
    margin: 0;
    line-height: 1.6;
    padding: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    background: transparent;
    flex-grow: 1;
}

/* ===========================================
   CARD FOOTER
   =========================================== */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0 0 0;
    margin-top: 6px;
    background: transparent;
    border-top: 1px dashed #e2e8f0;
    gap: 8px;
}

.tool-category {
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
    font-weight: 500;
    transition: background .2s, color .2s;
}

.tool-card:hover .tool-category {
    background: #e2e8f0;
    color: #334155;
}

.tool-category::before {
    content: none;
}

.tool-rating {
    font-weight: 700;
    color: #b45309;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    background: #fffbeb;
    padding: 4px 10px;
    border-radius: 20px;
    border: none;
    box-shadow: 0 1px 2px rgba(245, 158, 11, 0.1);
    white-space: nowrap;
}

.tool-rating::before {
    content: '★';
    color: #f59e0b;
    font-size: 0.75rem;
}

/* ===========================================
   PAGINATION
   =========================================== */
.archive-pagination {
    margin-top: 56px;
    display: flex;
    justify-content: center;
}

.archive-pagination .page-numbers {
    display: inline-flex;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.archive-pagination a,
.archive-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    text-decoration: none;
    color: #374151;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.archive-pagination a:hover {
    background: #f9fafb;
    border-color: #7c3aed;
    color: #7c3aed;
    transform: translateY(-2px);
}

.archive-pagination .current {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

/* ===========================================
   NO RESULTS
   =========================================== */
.no-tools-found {
    text-align: center;
    padding: 80px 20px;
    color: #9ca3af;
    font-size: 1rem;
    background: #f9fafb;
    border-radius: 16px;
    border: 2px dashed #e5e7eb;
}

/* ===========================================
   RESPONSIVE DESIGN
   =========================================== */
@media (max-width: 1024px) {

    .ai-tools-grid,
    .ai-tools-cards-grid {
        grid-template-columns: repeat(var(--cards-cols-tablet, 2), 1fr) !important;
        gap: 18px;
    }
}

@media (max-width: 768px) {

    /* Full-screen mobile layout */
    .ai-tools-main-container {
        padding: 0 !important;
        margin: 0 !important;
    }

    .ai-tool-container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }

    .content-area {
        padding: 0 12px !important;
    }

    .ai-tools-grid,
    .ai-tools-cards-grid {
        grid-template-columns: repeat(var(--cards-cols-mobile, 1), 1fr) !important;
        gap: 12px;
        margin-top: 16px;
    }

    /* 2-Column Grid for Similar Tools on mobile */
    .similar-tools-section .ai-tools-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    .similar-tools-section .tool-card {
        padding: 14px 10px;
        min-height: auto;
    }
    
    /* Stack header for narrow 2-column layout */
    .similar-tools-section .card-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 0;
        gap: 8px;
    }
    
    .similar-tools-section .tool-icon-wrap {
        margin: 0 auto;
    }
    
    .similar-tools-section .tool-icon {
        width: 54px;
        height: 54px;
        min-width: 54px;
        border-radius: 12px;
        font-size: 1.4rem;
    }
    
    .similar-tools-section .tool-meta {
        align-items: center;
    }
    
    .similar-tools-section .tool-meta .tool-title {
        font-size: 0.95rem;
        line-height: 1.3;
        margin-bottom: 4px;
        display: block;
    }
    
    .similar-tools-section .tool-stars {
        justify-content: center;
        font-size: 0.75rem;
    }
    
    .similar-tools-section .tool-meta-row {
        justify-content: center;
        margin-top: 10px;
        margin-bottom: 0;
        gap: 6px;
    }
    
    .similar-tools-section .pricing-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }
    
    .similar-tools-section .tool-desc {
        display: none; /* Hide description to save space in 2-column grid */
    }
    
    .similar-tools-section .tool-tags {
        display: none; /* Hide tags for cleaner look */
    }
    
    .similar-tools-section .card-footer {
        flex-direction: column;
        align-items: stretch;
        padding-top: 12px;
        margin-top: 12px;
        gap: 8px;
    }
    
    .similar-tools-section .tool-visit-btn {
        width: 100%;
        justify-content: center;
        padding: 8px;
        font-size: 0.85rem;
    }

    /* Compact card design for mobile */
    .tool-card {
        border-radius: 12px;
        box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
        padding: 20px;
        min-height: 0;
    }

    .card-header {
        padding: 18px;
        gap: 12px;
    }

    .tool-icon {
        width: 90px;
        height: 90px;
        min-width: 90px;
        border-radius: 14px;
        font-size: 2.05rem;
    }

    .tool-meta .tool-title {
        font-size: 1.22rem;
        line-height: 1.4;
    }

    .pricing-badge {
        font-size: 0.65rem;
        padding: 4px 10px;
        border-radius: 6px;
    }

    .tool-desc {
        font-size: 1rem;
        padding: 18px;
        line-height: 1.5;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    .card-footer {
        padding: 14px 18px;
        flex-direction: row;
        justify-content: space-between;
    }

    .tool-category {
        font-size: 0.7rem;
    }

    .tool-rating {
        font-size: 0.9rem;
        padding: 4px 10px;
    }

    .tool-rating::before {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {

    /* Extra compact for small screens */
    .content-area {
        padding: 0 10px !important;
    }

    .ai-tools-grid,
    .ai-tools-cards-grid {
        gap: 10px;
        margin-top: 12px;
    }

    .card-header {
        padding: 14px;
        gap: 10px;
    }

    .tool-icon {
        width: 72px;
        height: 72px;
        min-width: 72px;
        border-radius: 14px;
        font-size: 1.7rem;
    }

    .tool-meta .tool-title {
        font-size: 1rem;
    }

    .pricing-badge {
        font-size: 0.6rem;
        padding: 3px 8px;
    }

    .tool-desc {
        padding: 14px;
        font-size: 0.8rem;
    }

    .card-footer {
        padding: 10px 14px;
    }

    .tool-category {
        font-size: 0.65rem;
    }

    .tool-rating {
        font-size: 0.85rem;
        padding: 3px 8px;
    }
}

/* ===========================================
   DARK MODE SUPPORT
   =========================================== */
@media (prefers-color-scheme: dark) {
    .tool-card {
        background: #1f2937;
        border-color: #374151;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    .tool-card:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
        border-color: #4b5563;
    }

    .card-header {
        background: #111827;
        border-bottom-color: #374151;
    }

    .tool-icon {
        background: #111827;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    .tool-meta .tool-title {
        color: #f9fafb;
    }

    .tool-desc {
        color: #9ca3af;
        background: #1f2937;
    }

    .card-footer {
        background: #111827;
        border-top-color: #374151;
    }

    .tool-category {
        color: #6b7280;
    }

    .tool-rating {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }

    .tool-rating::before {
        color: #f9fafb;
    }

    .archive-pagination a,
    .archive-pagination span {
        background: #1f2937;
        border-color: #374151;
        color: #e5e7eb;
    }

    .archive-pagination a:hover {
        background: #111827;
        border-color: #a855f7;
        color: #a855f7;
    }

    .no-tools-found {
        background: #111827;
        color: #6b7280;
        border-color: #374151;
    }
}

/* ===========================================
   LOAD MORE BUTTON
   =========================================== */
.ai-tools-load-more-container {
    margin-top: 56px;
    display: flex;
    justify-content: center;
    width: 100%;
}

#ai-tools-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 40px;
    background: #111827;
    color: #ffffff;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    outline: none;
}

#ai-tools-load-more-btn:hover {
    transform: translateY(-2px);
    background: #1f2937;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    filter: brightness(1.1);
}

#ai-tools-load-more-btn:disabled,
#ai-tools-load-more-btn.loading {
    opacity: 0.8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#ai-tools-load-more-btn .fa-spinner {
    font-size: 1.1em;
}

/* Mobile Load More Button */
@media (max-width: 768px) {
    .ai-tools-load-more-container {
        margin-top: 32px;
        margin-bottom: 24px;
        padding: 0 12px;
    }

    #ai-tools-load-more-btn {
        width: 100%;
        padding: 16px 32px;
        font-size: 1rem;
        border-radius: 12px;
        font-weight: 700;
    }
}

@media (max-width: 480px) {
    .ai-tools-load-more-container {
        margin-top: 24px;
        margin-bottom: 20px;
        padding: 0 10px;
    }

    #ai-tools-load-more-btn {
        padding: 14px 28px;
        font-size: 0.95rem;
    }
}