/**
 * Tools Directory V2 - Modern Design
 * Inspired by modern AI tool directories
 */

/* ==============================================
   TOOLS SECTION - Navy Base + Tech Blue Accents
   Unified brand approach: Navy hero, Tech Blue for buttons/stats/badges
   ============================================== */

/* Section accent color */
.tools-archive,
.archive-tools,
body.post-type-archive-tool {
    --section-accent: var(--accent-tools, var(--tech-blue, #22A8E0));
    --section-accent-hover: #1a8fc2;
    --section-accent-glow: rgba(34, 168, 224, 0.3);
}

/* ============================================
   HERO SECTION - Navy Base
   ============================================ */

.tools-hero {
    background: var(--hero-tools, var(--navy, #1B3A5F));
    padding: 2rem 0;
    border-bottom: none;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
}

/* Subtle corner accent glow */
.tools-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    background: radial-gradient(circle at 0% 100%, rgba(21, 56, 95, 0.2) 0%, transparent 50%);
    pointer-events: none;
}

.tools-hero__container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    text-align: center;
}

/* Breadcrumb - REMOVED for cleaner design */
.breadcrumb-nav {
    display: none !important; /* Hidden to align with blog design */
    /* Original styles preserved below if needed later:
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    font-size: 0.875rem;
    */
}

.breadcrumb-nav a {
    color: #6c757d;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.2s;
}

.breadcrumb-nav a:hover {
    color: #22ace5;
}

.breadcrumb-separator {
    color: #adb5bd;
}

/* Hero Title */
.tools-hero__title {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 0.5rem;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}

.tools-hero__subtitle {
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 1;
}

/* Search Form */
.tools-search-form {
    max-width: 600px;
    margin: 0 auto 2rem;
}

.tools-search-wrapper {
    display: flex;
    background: white;
    border-radius: 8px; /* Standardized to 8px across all pages */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: box-shadow 0.3s;
}

.tools-search-wrapper:focus-within {
    box-shadow: 0 4px 20px rgba(34, 172, 229, 0.2);
}

.tools-search-input {
    flex: 1;
    border: none;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    outline: none;
    background: transparent;
}

.tools-search-button {
    background: var(--section-accent, var(--tech-blue, #22A8E0));
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.tools-search-button:hover {
    background: var(--section-accent-hover, #1a8fc2);
}

/* Stats */
.tools-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--section-accent, var(--tech-blue, #22A8E0));
    line-height: 1;
    position: relative;
    z-index: 1;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    z-index: 1;
}

/* ============================================
   MAIN LAYOUT
   ============================================ */

.tools-main {
    background: #f8f9fa;
    min-height: 600px;
    padding-bottom: 4rem;
}

.tools-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.tools-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    align-items: start;
}

/* ============================================
   SIDEBAR
   ============================================ */

/* CSS Variables for dynamic positioning */
:root {
    --tools-sidebar-top: 2rem; /* Default fallback */
    --tools-sidebar-height: calc(100vh - 4rem);
}

.tools-sidebar {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    position: sticky;
    top: var(--tools-sidebar-top) !important;
    height: var(--tools-sidebar-height) !important;
    overflow-y: auto;
    overflow-x: hidden;
}

.filter-section {
    /* Styles handled by child elements */
}

.filter-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #15385f;
    margin: 0 0 1.5rem;
}

/* Active Filters: label + chips + Clear-all on one wrapping row */
.active-filters {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.625rem;
}

.active-filters-header {
    display: contents;
}

.active-filters-header > span {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6c757d;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.clear-filters {
    margin-left: auto;
    color: #22ace5;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.8125rem;
}

.clear-filters:hover {
    text-decoration: underline;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #e9ecef;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    margin: 0;
}

.remove-filter {
    color: #6c757d;
    text-decoration: none;
    font-weight: bold;
    line-height: 1;
}

.remove-filter:hover {
    color: #dc3545;
}

/* Filter Groups */
.filter-group {
    margin-bottom: 2rem;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: #15385f;
    margin: 0 0 1rem;
}

.filter-group-title svg {
    color: #22ace5;
    flex-shrink: 0;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Filter Search */
.filter-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.filter-search:focus {
    outline: none;
    border-color: #22ace5;
}

/* Scrollable filter options */
.filter-options--scrollable {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
    margin-right: -0.5rem;
}

.filter-options--scrollable::-webkit-scrollbar {
    width: 6px;
}

.filter-options--scrollable::-webkit-scrollbar-track {
    background: #f1f3f5;
    border-radius: 3px;
}

.filter-options--scrollable::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 3px;
}

.filter-options--scrollable::-webkit-scrollbar-thumb:hover {
    background: #868e96;
}

/* Hidden filter options */
.filter-option--hidden {
    display: none;
}

/* Show more button */
.filter-show-more {
    background: none;
    border: none;
    color: #22ace5;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    text-align: left;
}

.filter-show-more:hover {
    text-decoration: underline;
}

.filter-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    position: relative;
    padding-left: 24px;
}

.filter-option input[type="radio"],
.filter-option input[type="checkbox"] {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
    cursor: pointer;
}

.filter-option-label {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: #495057;
    line-height: 1.4;
}

.filter-count {
    color: #adb5bd;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

/* ============================================
   CONTENT AREA
   ============================================ */

.tools-content {
    /* Container for grid and pagination */
}

/* Results Header */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-count {
    font-size: 0.875rem;
    color: #6c757d;
    margin: 0;
}

.sort-select {
    padding: 0.5rem 2rem 0.5rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
    font-size: 0.875rem;
    color: #495057;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236c757d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    appearance: none;
}

/* ============================================
   TOOLS GRID
   ============================================ */

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-bottom: 3rem;
}

/* ============================================
   TOOL CARD V2
   ============================================ */

.tool-card-v2 {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
    border: 1px solid #e9ecef;
    position: relative;
}

.tool-card-v2:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    border-color: #22ace5;
}

.tool-card-v2--sponsored {
    border-color: #f59e0b;
    background: linear-gradient(to bottom, #fffbf0 0%, white 100%);
}

.tool-card-v2__link {
    display: block;
    text-decoration: none !important;
    color: inherit;
    height: 100%;
}

.tool-card-v2__link:hover {
    text-decoration: none !important;
}

/* Ensure all text elements inside card don't get underlined */
.tool-card-v2__link * {
    text-decoration: none !important;
}

.tool-card-v2__title,
.tool-card-v2__excerpt,
.tool-card-v2__meta,
.tool-card-v2__category {
    text-decoration: none !important;
}

/* Card Header */
.tool-card-v2__header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-bottom: 1px solid #f1f3f5;
}

.tool-card-v2__logo {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-card-v2__logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.tool-card-v2__logo--placeholder {
    background: linear-gradient(135deg, #22ace5 0%, #1a8ab8 100%);
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
}

.tool-card-v2__info {
    flex: 1;
    min-width: 0;
}

.tool-card-v2__title {
    font-size: 1rem;
    font-weight: 600;
    color: #15385f;
    margin: 0 0 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-card-v2__meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
}

.tool-card-v2__rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: #f59e0b;
    font-weight: 600;
}

.tool-card-v2__pricing {
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.tool-card-v2__pricing--free {
    background: #d1fae5;
    color: #065f46;
}

.tool-card-v2__pricing--freemium {
    background: #dbeafe;
    color: var(--cpt-primary);
}

.tool-card-v2__pricing--subscription {
    background: #e0e7ff;
    color: #3730a3;
}

.tool-card-v2__trial {
    color: #059669;
    font-weight: 500;
}

.tool-card-v2__sponsored {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: #f59e0b;
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.025em;
}

/* Card Body */
.tool-card-v2__body {
    padding: 1rem 1.25rem 1.25rem;
}

.tool-card-v2__excerpt {
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.5;
    margin: 0 0 0.75rem;
}

.tool-card-v2__categories {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tool-card-v2__category {
    font-size: 0.75rem;
    color: #6c757d;
    background: #f8f9fa;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
}

/* ============================================
   PAGINATION
   ============================================ */

.tools-pagination {
    display: flex;
    justify-content: center;
    margin-top: 3rem;
}

.tools-pagination ul {
    display: flex;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.tools-pagination li {
    margin: 0;
}

.tools-pagination a,
.tools-pagination .current {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 1rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.tools-pagination a {
    background: white;
    color: #495057;
    border: 1px solid #dee2e6;
}

.tools-pagination a:hover {
    background: #f8f9fa;
    color: #22ace5;
    border-color: #22ace5;
}

.tools-pagination .current {
    background: #22ace5;
    color: white;
    border: 1px solid #22ace5;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.tools-empty {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.tools-empty__icon {
    color: #dee2e6;
    margin-bottom: 1.5rem;
}

.tools-empty h2 {
    font-size: 1.5rem;
    color: #15385f;
    margin: 0 0 0.5rem;
}

.tools-empty p {
    color: #6c757d;
    margin: 0 0 2rem;
}

.btn-primary {
    display: inline-block;
    background: #22ace5;
    color: white;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #1a8ab8;
    transform: translateY(-1px);
}

/* ============================================
   LOAD MORE & PAGINATION
   ============================================ */

.tools-load-more-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-light);
}

.load-more-wrapper {
    text-align: center;
    margin-bottom: 2rem;
}

.load-more-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.btn-load-more {
    background: #22ace5;
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-width: 150px;
}

.btn-load-more:hover {
    background: #1a8ab8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 172, 229, 0.25);
}

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

.btn-load-more.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-load-more.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s ease infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.tools-pagination {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.tools-pagination ul,
.tools-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.tools-pagination li {
    display: inline-block;
}

.tools-pagination .page-numbers a,
.tools-pagination .page-numbers span,
.tools-pagination a,
.tools-pagination span.current,
.tools-pagination .prev,
.tools-pagination .next {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    color: #495057;
    text-decoration: none;
    transition: all 0.2s ease;
    min-width: 42px;
    height: 42px;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 500;
    box-sizing: border-box;
}

.tools-pagination .page-numbers a:hover,
.tools-pagination a:hover {
    background: #f5f5f5;
    border-color: #22ace5;
    color: #22ace5;
}

.tools-pagination .page-numbers .current,
.tools-pagination span.current {
    background: #22ace5;
    color: white;
    border-color: #22ace5;
}

/* ============================================
   SEARCH ANIMATION
   ============================================ */

.search-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 3rem;
    background: rgba(248, 249, 250, 0.9);
    border-radius: 12px;
    margin: 2rem 0;
}

.loader-wrapper {
    text-align: center;
}

.loader-logo {
    width: 100px;
    height: 100px;
    animation: rotate-pulse 2s ease-in-out infinite;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

@keyframes rotate-pulse {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 0.8;
    }
    25% {
        transform: rotate(90deg) scale(1.1);
        opacity: 1;
    }
    50% {
        transform: rotate(180deg) scale(1);
        opacity: 0.8;
    }
    75% {
        transform: rotate(270deg) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: rotate(360deg) scale(1);
        opacity: 0.8;
    }
}

.loader-text {
    color: #6c757d;
    font-size: 1.125rem;
    margin: 0;
}

/* Search button animation */
.tools-search-button.searching {
    position: relative;
    color: transparent;
}

.tools-search-button.searching::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Search error state */
.search-error {
    text-align: center;
    padding: 3rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
}

/* Real-time search indicator */
.tools-search-input.searching {
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='10' cy='10' r='8' stroke='%2322ace5' stroke-width='2' fill='none' stroke-dasharray='25' stroke-dashoffset='0'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 10 10' to='360 10 10' dur='1s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 3rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
    .tools-layout {
        grid-template-columns: 240px 1fr;
    }
}

@media (max-width: 768px) {
    .tools-hero__title {
        font-size: 2rem;
    }
    
    .tools-stats {
        gap: 2rem;
    }
    
    .tools-layout {
        grid-template-columns: 1fr;
    }
    
    .tools-sidebar {
        position: static;
        margin-bottom: 2rem;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .sort-select {
        width: 100%;
    }
}