/**
 * Homepage Styles - Matches filter-page-style.css design
 * Domain: www.top1to5.com
 * Purpose: Homepage specific styling aligned with filter pages
 */

/* ============================================================================
   Global Reset (matches filter-page-style.css)
   ============================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: clip;
    width: 100%;
    height: 100%;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e1b4b 0%, #2d1b69 25%, #4c1d95 50%, #6b21a8 75%, #ec4899 100%);
    min-height: 100vh;
    padding: 0 !important;
    margin: 0 !important;
    overflow-x: clip;
    width: 100%;
    position: relative;
}

/* ============================================================================
   Title Section
   ============================================================================ */
.title-section {
    background: white;
    color: #1f2937;
    padding: 120px 30px 50px 30px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

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

.title-heading {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: #8b5cf6;
    font-weight: bold;
}

.title-subtitle {
    font-size: 1.2em;
    color: #4b5563;
    line-height: 1.6;
    margin-bottom: 30px;
}

.title-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 30px;
}

/* Add extra spacing when border is enabled */
.title-container--bordered + .title-stats {
    margin-top: 40px;
}

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

.title-stat-number {
    font-size: 1.8em;
    font-weight: 700;
    color: #8b5cf6;
    display: block;
    margin-bottom: 10px;
}

.title-stat-label {
    font-size: 0.9em;
    color: #6b7280;
}

/* Title Container with Border (gradient border like our-take-container) */
.title-container--bordered {
    background: white;
    border: 3px solid transparent;
    background-image:
        linear-gradient(white, white),
        linear-gradient(135deg, #8b5cf6 0%, #a855f7 50%, #ec4899 100%);
    background-origin: border-box;
    background-clip: padding-box, border-box;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.15);
    transition: all 0.3s ease;
}

.title-container--bordered:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.25);
}

/* ============================================================================
   Search Section
   ============================================================================ */
.search-section-home {
    background: white;
    padding: 40px 50px;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
    border-bottom: 1px solid #e5e7eb;
}

.search-container-home {
    max-width: 1200px;
    margin: 0 auto;
}

.search-title {
    font-size: 1.5em;
    font-weight: 600;
    text-align: center;
    color: #1f2937;
    margin-bottom: 10px;
}

.search-subtitle {
    text-align: center;
    margin-bottom: 30px;
    color: #4b5563;
    font-size: 1.1em;
    line-height: 1.8;
}

.search-form-home {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
}

.search-input-home {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    transition: all 0.3s ease;
}

.search-input-home:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.search-input-home::placeholder {
    color: #9ca3af;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    margin-top: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-suggestions.active {
    display: block;
}

.search-suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    text-align: left;
    transition: background 0.2s;
}

.search-suggestion-item:last-child {
    border-bottom: none;
}

.search-suggestion-item:hover {
    background: #f9fafb;
}

.suggestion-title {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.suggestion-category {
    font-size: 0.875rem;
    color: #6b7280;
}

.search-btn-home {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.search-btn-home:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.5);
}

.search-btn-home:active {
    transform: translateY(0);
}

.search-quick-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.quick-links-label {
    font-size: 0.9em;
    color: #6b7280;
    font-weight: 600;
}

.quick-link {
    font-size: 0.9em;
    color: #8b5cf6;
    text-decoration: none;
    padding: 6px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    transition: all 0.2s;
    background: white;
}

.quick-link:hover {
    background: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}

/* ============================================================================
   Category Section (styled like results section)
   ============================================================================ */
.category-section {
    background: white;
    padding: 40px 50px;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

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

.category-section-title {
    font-size: 1.5em;
    font-weight: 600;
    text-align: center;
    color: #1f2937;
    margin-bottom: 30px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.category-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    text-decoration: none;
    display: block;
    padding: 30px;
    text-align: center;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.2);
}

.category-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.category-name {
    font-size: 1.8em;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.category-name-th {
    font-size: 1.2em;
    color: #6b7280;
    margin: 0;
}

.category-count {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 16px;
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

/* Mobile Devices (< 768px) */
@media (max-width: 767px) {
    html, body {
        font-size: 14px;
    }

    /* Title Section */
    .title-section {
        padding: 110px 20px 30px 20px;
    }

    .title-heading {
        font-size: 1.8em;
    }

    .title-subtitle {
        font-size: 1em;
    }

    .title-stats {
        flex-direction: column;
        gap: 20px;
    }

    .title-stat-number {
        font-size: 1.5em;
    }

    .title-container--bordered {
        padding: 20px;
    }

    /* Search Section */
    .search-section-home {
        padding: 30px 20px;
    }

    .search-title {
        font-size: 1.3em;
    }

    .search-subtitle {
        font-size: 1em;
    }

    .search-form-home {
        flex-direction: column;
        gap: 12px;
    }

    .search-btn-home {
        width: 100%;
        justify-content: center;
    }

    .search-quick-links {
        gap: 8px;
    }

    .quick-links-label {
        width: 100%;
        text-align: center;
        margin-bottom: 4px;
    }

    /* Category Section */
    .category-section {
        padding: 30px 20px;
    }

    .category-section-title {
        font-size: 1.3em;
    }

    .category-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .category-card {
        padding: 25px;
    }

    .category-name {
        font-size: 1.5em;
    }

    .category-name-th {
        font-size: 1em;
    }
}

/* Tablet (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .search-section-home,
    .category-section {
        padding: 40px 30px;
    }

    .title-section {
        padding: 110px 30px 40px 30px;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Small Mobile (< 480px) */
@media (max-width: 479px) {
    .title-heading {
        font-size: 1.5em;
    }

    .search-title,
    .category-section-title {
        font-size: 1.2em;
    }

    .search-input-home {
        font-size: 0.9em;
    }

    .category-name {
        font-size: 1.3em;
    }
}

/* ============================================================================
   Search Results Section
   ============================================================================ */

.search-results-section {
    background: white;
    padding: 40px 50px;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

.search-results-container {
    max-width: 1200px;
    margin: 0 auto;
}

.results-count {
    text-align: center;
    font-size: 1.1em;
    color: #4b5563;
    margin-bottom: 30px;
}

.results-count strong {
    color: #8b5cf6;
}

.loading-state {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid #e5e7eb;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-state p {
    color: #6b7280;
    font-size: 1em;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
}

.no-results-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.no-results h3 {
    font-size: 1.5em;
    color: #1f2937;
    margin-bottom: 10px;
}

.no-results > p {
    color: #6b7280;
    font-size: 1em;
    margin-bottom: 30px;
}

.no-results-suggestions {
    text-align: left;
    max-width: 400px;
    margin: 30px auto;
    padding: 20px;
    background: #f9fafb;
    border-radius: 12px;
}

.no-results-suggestions p {
    font-weight: 600;
    color: #374151;
    margin-bottom: 10px;
}

.no-results-suggestions ul {
    list-style: none;
    padding: 0;
}

.no-results-suggestions li {
    padding: 5px 0;
    color: #6b7280;
}

.no-results-suggestions li:before {
    content: "→ ";
    color: #8b5cf6;
    font-weight: bold;
}

.popular-searches {
    margin-top: 30px;
}

.popular-searches p {
    font-weight: 600;
    color: #374151;
    margin-bottom: 15px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

/* ============================================================================
   Category Card Modifiers (for search results)
   ============================================================================ */

/* Modifier: Subcategory variant (used for both category and subcategory cards) */
.category-card--subcategory {
    border: 2px solid #e5e7eb;
    min-height: 140px;
}

.category-card--subcategory .category-card-content {
    justify-content: center;
}

.category-card--subcategory:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.02);
}

.category-card--subcategory .category-name {
    font-size: 1.3em;
    margin-bottom: 4px;
}

.subcategory-parent {
    font-size: 0.85em;
    color: #9ca3af;
    margin-bottom: 8px;
}

/* Modifier: Post variant (with image) */
.category-card--post {
    flex-direction: column;
    padding: 0;
    border: 2px solid #e5e7eb;
}

.category-card--post:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.02);
    transform: translateY(-5px);
}

.category-card--post .category-card-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.card-image {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: linear-gradient(135deg, #f5f7fa 0%, #e5e7eb 100%);
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.category-card--post:hover .card-image img {
    transform: scale(1.05);
}

.card-category-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.post-title {
    font-size: 1.1em;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.post-subtitle {
    font-size: 0.9em;
    color: #8b5cf6;
    font-weight: 500;
    margin: 0 0 8px 0;
}

.post-description {
    font-size: 0.9em;
    color: #6b7280;
    line-height: 1.6;
    margin: 0 0 12px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
    font-size: 0.85em;
}

.post-subcategory {
    color: #6b7280;
    font-weight: 500;
}

.post-relevance {
    color: #10b981;
    font-weight: 600;
}

/* ============================================================================
   Responsive for Search Results
   ============================================================================ */

@media (min-width: 768px) and (max-width: 1024px) {
    .search-results-section {
        padding: 40px 30px;
    }

    .results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 767px) {
    .search-results-section {
        padding: 30px 20px;
    }

    .results-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .category-card--subcategory {
        min-height: auto;
    }

    .category-icon {
        font-size: 2.5em;
    }

    .card-image {
        height: 180px;
    }

    .post-title {
        font-size: 1em;
    }
}

@media (max-width: 479px) {
    .card-image {
        height: 160px;
    }
}
