/**
 * Greetings List & Card Styles
 * Desktop: Table layout
 * Mobile: Card layout
 */

/* Table Styles (Desktop) */
.greetings-table {
    width: 100%;
    border-collapse: collapse;
}

.greetings-table th {
    background: #f5f5f5;
    padding: 12px 15px;
    text-align: right;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
}

.greetings-table td {
    padding: 15px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.greeting-row:hover {
    background-color: #f9f9f9;
}

/* Greeting Title */
.greeting-title {
    font-weight: bold;
    color: #0066cc;
    font-size: 16px;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 8px;
}

.greeting-title:hover {
    color: #0052a3;
    text-decoration: underline;
}

/* Greeting Preview Text */
.greeting-preview {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 6px;
}

/* Greeting Author */
.greeting-author {
    color: #999;
    font-size: 13px;
    font-style: italic;
}

/* Length Badge */
.length-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 4px;
}

.length-badge.success {
    background: #d4edda;
    color: #155724;
}

.length-badge.info {
    background: #d1ecf1;
    color: #0c5460;
}

.length-badge.warning {
    background: #fff3cd;
    color: #856404;
}

.length-chars {
    color: #999;
    font-size: 12px;
}

/* Popularity Icons */
.popularity-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 4px;
    text-align: center;
}

.popularity-count {
    color: #999;
    font-size: 12px;
}

/* Card Layout (Mobile) */
.greetings-cards {
    display: none; /* Hidden on desktop */
}

.greeting-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.greeting-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.greeting-card-title {
    font-weight: bold;
    color: #0066cc;
    font-size: 16px;
    text-decoration: none;
    display: block;
    margin-bottom: 10px;
    line-height: 1.4;
}

.greeting-card-title:hover {
    color: #0052a3;
}

.greeting-card-preview {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
}

.greeting-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    font-size: 13px;
    color: #666;
}

.greeting-card-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.greeting-card-meta-item::before {
    content: '•';
    margin-left: 4px;
}

.greeting-card-meta-item:first-child::before {
    display: none;
}

.greeting-card-author {
    color: #999;
    font-size: 13px;
    font-style: italic;
    margin-top: 8px;
}

/* Inline Ad in Cards */
.card-ad-wrapper {
    background: #f9f9f9;
    border: 1px dashed #ddd;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}

/* Base Greeting Box Styles */
.greetingBox {
    list-style: none;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.greetingBox:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Remove list padding for better layout */
ul.row {
    padding-right: 0;
    padding-left: 0;
}

/* Ensure proper spacing */
.greetingBox.twelve.columns {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
}

/* Mobile Card Styles for .greetingBox */
@media (max-width: 767px) {
    .greetingBox {
        margin-bottom: 16px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    }

    .greetingBox:active,
    .greetingBox:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

/* Desktop Styles */
@media (min-width: 768px) {
    .greetingBox {
        margin-bottom: 20px;
    }
}

/* Responsive: Switch to cards on mobile */
@media (max-width: 768px) {
    .greetings-table {
        display: none;
    }

    .greetings-cards {
        display: block;
    }
}

/* Sorting Buttons - Moved to responsive.css for consistency */
/* See responsive.css for .sort-btn and .sorting-container styles */

/* Tags Section - Enhanced Design */
.popular_tags {
    display: inline-block;
    font-weight: 600;
    margin-left: 8px;
    margin-bottom: 8px;
}

.responsive_tags {
    display: inline-block;
    margin: 4px;
}

.responsive_tags a {
    display: inline-block;
    padding: 6px 14px;
    background: #f0f0f0;
    color: #333;
    text-decoration: none;
    border-radius: 16px;
    font-size: 13px;
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0;
    min-height: 32px;
    line-height: 1.5;
}

.responsive_tags a:hover {
    background: #0066cc;
    color: #ffffff;
    border-color: #0066cc;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 102, 204, 0.3);
}

/* Mobile tags - wrapped (no horizontal scroll) */
@media (max-width: 767px) {
    .tags-section {
        padding: 12px 0;
        margin: 0;
        background: transparent;
    }

    .tags-section ul {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .tags-section li {
        flex-shrink: 0;
    }

    .popular_tags {
        margin-left: 0;
        margin-right: 0;
        font-size: 14px;
        width: 100%;
        margin-bottom: 4px;
    }

    .responsive_tags a {
        white-space: nowrap;
        padding: 8px 16px;
        font-size: 13px;
        min-height: 36px; /* Touch-friendly */
        background: #f5f5f5;
        border: 1px solid #e0e0e0;
    }

    /* Collapsed: heading row + two rows of chips (max-height set by the inline script),
       the rest behind "כל הנושאים" */
    .tags-section.is-collapsed ul {
        overflow: hidden;
    }

    .tags-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin-top: 10px;
        min-height: 36px;
        padding: 0 4px;
        background: none;
        border: none;
        color: #0b5cad;
        font: inherit;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
    }

    .tags-toggle[hidden] {
        display: none;
    }
}

/* Desktop tags - keep as is */
@media (min-width: 768px) {
    .tags-section ul {
        display: block;
        list-style: none;
        padding: 0;
    }

    .tags-section li {
        display: inline-block;
    }

    .responsive_tags a {
        padding: 6px 14px;
        font-size: 13px;
    }
}

/* Skeleton Loading States */
@keyframes skeleton-shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: skeleton-shimmer 2s infinite linear;
    border-radius: 4px;
    display: inline-block;
}

/* Skeleton Greeting Card */
.greetingBox.skeleton-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    pointer-events: none;
}

.skeleton-card .skeleton-title {
    height: 20px;
    width: 70%;
    margin-bottom: 12px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: skeleton-shimmer 2s infinite linear;
    border-radius: 4px;
}

.skeleton-card .skeleton-text {
    height: 16px;
    width: 100%;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: skeleton-shimmer 2s infinite linear;
    border-radius: 4px;
}

.skeleton-card .skeleton-text:last-of-type {
    width: 85%;
}

.skeleton-card .skeleton-meta {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.skeleton-card .skeleton-meta-item {
    height: 14px;
    width: 80px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: skeleton-shimmer 2s infinite linear;
    border-radius: 4px;
}

/* Skeleton Sorting Buttons */
.skeleton-sort-btn {
    display: inline-block;
    height: 40px;
    width: 80px;
    margin: 5px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: skeleton-shimmer 2s infinite linear;
    border-radius: 8px;
}

/* Skeleton Tags */
.skeleton-tag {
    display: inline-block;
    height: 32px;
    width: 100px;
    margin: 4px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: skeleton-shimmer 2s infinite linear;
    border-radius: 16px;
}

/* Mobile skeleton adjustments */
@media (max-width: 767px) {
    .greetingBox.skeleton-card {
        border-radius: 12px;
        padding: 16px 20px;
    }

    .skeleton-sort-btn {
        height: 36px;
        width: 70px;
    }

    .skeleton-tag {
        height: 40px;
        width: 90px;
    }
}

/* Hide skeleton content after load */
.content-loaded .skeleton-card,
.content-loaded .skeleton-sort-btn,
.content-loaded .skeleton-tag {
    display: none;
}

/* Performance Optimizations */

/* Lazy Loading Images - fade in when loaded */
img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.3s ease;
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* Use GPU acceleration for animations */
.greetingBox {
    will-change: transform, box-shadow;
    transform: translateZ(0); /* Force GPU acceleration */
    backface-visibility: hidden;
}

.greetingBox:hover,
.greetingBox:active {
    will-change: transform, box-shadow;
}

.sort-btn {
    will-change: transform, box-shadow;
    transform: translateZ(0);
}

.responsive_tags a {
    will-change: transform, background-color;
    transform: translateZ(0);
}

/* CSS Containment for better rendering performance */
.greetingBox {
    contain: layout style paint;
}

.sorting-container {
    contain: layout style;
}

.tags-section {
    contain: layout style;
}

/* Reduce motion for users who prefer it (accessibility) */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .greetingBox:hover,
    .greetingBox:active {
        transform: none !important;
    }

    .sort-btn:hover {
        transform: none !important;
    }

    .responsive_tags a:hover {
        transform: none !important;
    }
}

/* Content visibility optimization for off-screen content */
.greetingBox {
    content-visibility: auto;
    contain-intrinsic-size: auto 190px; /* Estimated height */
}

/* Optimize font rendering */
.greetingText,
.greetingMeta,
.sort-btn,
.responsive_tags a {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ==========================================================================
   Tag Page Header - Warm Design
   ========================================================================== */

.tag-header {
    background: linear-gradient(135deg, #fdfcfa 0%, #faf6f0 100%);
    padding: 20px 24px;
    margin: 0 0 20px 0;
    border-radius: 12px;
    border-right: 4px solid;
    border-image: linear-gradient(to bottom, #c9956b, #8b6f4e) 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.tag-header h1 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.6em;
    font-weight: 700;
}

.tag-header h1 i {
    color: #c9956b;
    margin-left: 8px;
}

.tag-header .tag-meta {
    color: #666;
    font-size: 0.95em;
    line-height: 1.6;
}

.tag-header .tag-meta strong {
    color: #4c6a8a;
}

/* ==========================================================================
   Category Page Header
   ========================================================================== */

.category-page-header h1 {
    color: #2c3e50;
    font-size: 1.6em;
    font-weight: 700;
    margin: 0 0 8px 0;
}

.category-page-description {
    color: #666;
    font-size: 0.95em;
    line-height: 1.6;
    margin-bottom: 12px;
}

.category-page-description strong {
    color: #4c6a8a;
}

/* ==========================================================================
   FAQ Section
   ========================================================================== */

.category-faq {
    background: linear-gradient(135deg, #fdfcfa 0%, #faf6f0 100%);
    border-radius: 10px;
    padding: 16px 20px;
    border-right: 3px solid #c9956b;
    margin: 16px 0;
}

.category-faq summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05em;
    color: #2c3e50;
    padding: 2px 0;
}

.category-faq summary:hover {
    color: #4c6a8a;
}

.category-faq-content {
    margin-top: 14px;
}

.category-faq-item {
    margin-bottom: 14px;
}

.category-faq-item:last-child {
    margin-bottom: 0;
}

.category-faq-item strong {
    color: #333;
    display: block;
    margin-bottom: 4px;
}

.category-faq-item p {
    margin: 0;
    color: #555;
    line-height: 1.6;
    font-size: 0.95em;
}

/* ==========================================================================
   Sorting Buttons - Warm Style
   ========================================================================== */

.sorting-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

.sorting-container .sort-btn:not(.active):hover {
    background: #f5f2ed !important;
    color: #333 !important;
    border-color: #c9c0b4 !important;
}

@media (max-width: 600px) {
    .sorting-container .sort-btn {
        font-size: 12px !important;
        padding: 6px 12px !important;
    }
}

/* ==========================================================================
   Related Categories Section
   ========================================================================== */

.related-categories-section {
    padding: 16px 0;
    border-top: 1px solid #eae6df;
    margin-top: 16px;
}

.related-categories-section h3 {
    color: #4c6a8a;
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 10px;
}

.related-categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.related-category-pill {
    display: inline-block;
    background: linear-gradient(135deg, #f5f0e8, #faf6f0);
    color: #4c6a8a;
    padding: 6px 14px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9em;
    border: 1px solid #e0d8cc;
    transition: all 0.2s ease;
    font-weight: 500;
}

.related-category-pill:hover {
    background: #4c6a8a;
    color: white;
    border-color: #4c6a8a;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(76, 106, 138, 0.25);
}

/* ==========================================================================
   Ad Responsive Sizes (shared across tag/category pages)
   ========================================================================== */

.ads_inside_main_zone {
    margin: 0 auto;
    width: 300px;
    height: 250px !important;
}

@media(min-width: 340px) {
    .ads_inside_main_zone {
        margin: 0 auto;
        width: 336px;
        height: 280px !important;
    }
}

@media(min-width: 670px) {
    .ads_inside_main_zone {
        margin: 0 auto;
        width: 650px;
        height: 250px !important;
    }
}

@media(min-width: 760px) {
    .ads_inside_main_zone {
        margin: 0 auto;
        width: 728px;
        height: 250px !important;
    }
}

/* ==========================================================================
   Mobile Responsive - Page Headers
   ========================================================================== */

@media (max-width: 767px) {
    .tag-header {
        padding: 16px 18px;
        margin: 0 0 16px 0;
    }

    .tag-header h1 {
        font-size: 1.3em;
    }

    .category-faq {
        padding: 14px 16px;
    }

    .related-category-pill {
        font-size: 0.85em;
        padding: 5px 12px;
    }
}

/* Empty State */
.greetings-empty {
    text-align: center;
    padding: 60px 20px;
}

.greetings-empty-icon {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 16px;
}

.greetings-empty-text {
    font-size: 18px;
    color: #666;
    margin-bottom: 20px;
}

.greetings-empty-link {
    display: inline-block;
    padding: 10px 20px;
    background: #007bff;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
}

.greetings-empty-link:hover {
    background: #0056b3;
}

/* Enhanced Greeting Card Layout */
.greetingLink {
    text-decoration: none;
    color: inherit;
    display: block;
}

.greetingCard {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-right: 4px solid #0066cc;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    direction: rtl;
}

.greetingCard:hover {
    border-right-color: #02AFF3;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    box-shadow: inset 0 0 0 1px rgba(0, 102, 204, 0.1);
}

.greetingIcon {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #0066cc, #02AFF3);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 4px 8px rgba(0, 102, 204, 0.2);
    transition: all 0.3s ease;
}

.greetingCard:hover .greetingIcon {
    transform: scale(1.08) rotate(5deg);
    box-shadow: 0 6px 12px rgba(0, 102, 204, 0.3);
}

.greetingContent {
    flex: 1;
    min-width: 0;
}

.greetingTitle {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 10px 0;
    line-height: 1.4;
    text-align: right;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.popularBadge,
.hotBadge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.popularBadge {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
}

.hotBadge {
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(255, 107, 107, 0.3);
}

.greetingPreview {
    font-size: 15px;
    color: #555;
    line-height: 1.6;
    margin: 0 0 15px 0;
    text-align: right;
}

.greetingFooter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.greetingMeta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.metaItem {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
}

.metaItem i {
    color: #0066cc;
    font-size: 14px;
}

.greetingActions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-inline-start: auto;
    flex-shrink: 0;
}

.listWhatsAppBtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    background: #0E7C3A; /* WhatsApp-family green dark enough for white text (5.3:1) */
    color: #fff;
    border: none;
    border-radius: 18px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
}

.listWhatsAppBtn i {
    font-size: 18px;
}

.listWhatsAppBtn:hover,
.listWhatsAppBtn:focus-visible {
    background: #0a6a31;
}

.readMore {
    font-size: 14px;
    font-weight: 500;
    color: #0066cc;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: gap 0.2s ease;
}

.greetingCard:hover .readMore {
    gap: 8px;
}

.readMore i {
    transition: transform 0.2s ease;
}

.greetingCard:hover .readMore i {
    transform: translateX(-3px);
}

/* Mobile Greeting Card Styles */
@media (max-width: 767px) {
    .greetingCard {
        display: block;
        padding: 14px 16px 12px;
    }

    /* Decorative (aria-hidden) and duplicated by the פופולרי/חם badges — on mobile it cost a full row per card */
    .greetingIcon {
        display: none;
    }

    .greetingTitle {
        font-size: 16px;
        margin-bottom: 6px;
    }

    .greetingPreview {
        font-size: 14px;
        margin-bottom: 10px;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .greetingFooter {
        gap: 10px;
        padding-top: 10px;
    }

    .greetingMeta {
        gap: 12px;
        min-width: 0;
    }

    .greetingActions {
        gap: 12px;
    }

    .readMore {
        font-size: 13px;
    }
}

/* Desktop Greeting Card Styles */
@media (min-width: 768px) {
    .greetingBox {
        margin-bottom: 20px;
    }

    .greetingCard {
        padding: 24px;
    }

    .greetingIcon {
        margin-top: 4px;
    }
}
