/**
 * MIW Facebook Feed - Frontend Styles
 *
 * Masonry-Layout für Social Media Feed Cards
 * Inspiriert von Social-Media-Wall-Designs
 */

/* ==========================================================================
   Container / Grid
   ========================================================================== */

.miw-fb-feed {
    width: 100%;
    box-sizing: border-box;
}

/* Masonry Layout (CSS Columns) */
.miw-fb-feed--masonry {
    column-gap: 20px;
}

.miw-fb-feed--masonry.miw-fb-feed--cols-2 {
    column-count: 2;
}

.miw-fb-feed--masonry.miw-fb-feed--cols-3 {
    column-count: 3;
}

.miw-fb-feed--masonry.miw-fb-feed--cols-4 {
    column-count: 4;
}

/* Grid Layout (gleiche Höhe) */
.miw-fb-feed--grid {
    display: grid;
    gap: 20px;
}

.miw-fb-feed--grid.miw-fb-feed--cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.miw-fb-feed--grid.miw-fb-feed--cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.miw-fb-feed--grid.miw-fb-feed--cols-4 {
    grid-template-columns: repeat(4, 1fr);
}


/* ==========================================================================
   Cards
   ========================================================================== */

.miw-fb-feed-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
    margin-bottom: 20px;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
}

.miw-fb-feed-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.miw-fb-feed-card__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.miw-fb-feed-card__link:hover,
.miw-fb-feed-card__link:focus {
    text-decoration: none;
    color: inherit;
}


/* ==========================================================================
   Card Header
   ========================================================================== */

.miw-fb-feed-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
}

.miw-fb-feed-card__author {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.miw-fb-feed-card__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.miw-fb-feed-card__avatar--placeholder {
    background: #e4e6eb;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #65676b;
}

.miw-fb-feed-card__avatar--placeholder svg {
    width: 24px;
    height: 24px;
}

.miw-fb-feed-card__author-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.miw-fb-feed-card__name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.miw-fb-feed-card__date {
    font-size: 12px;
    color: #65676b;
    line-height: 1.3;
}

.miw-fb-feed-card__social-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    color: #1877f2;
    margin-left: 8px;
}

.miw-fb-feed-card__social-icon svg {
    width: 100%;
    height: 100%;
}


/* ==========================================================================
   Card Media
   ========================================================================== */

.miw-fb-feed-card__media {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #f0f2f5;
}

.miw-fb-feed-card__image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.miw-fb-feed-card:hover .miw-fb-feed-card__image {
    transform: scale(1.03);
}

.miw-fb-feed-card__video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.3s ease;
}

.miw-fb-feed-card:hover .miw-fb-feed-card__video-overlay {
    background: rgba(24, 119, 242, 0.9);
}

.miw-fb-feed-card__video-overlay svg {
    width: 28px;
    height: 28px;
    margin-left: 3px;
}


/* ==========================================================================
   Card Content
   ========================================================================== */

.miw-fb-feed-card__content {
    padding: 12px 16px;
}

.miw-fb-feed-card__text {
    font-size: 14px;
    line-height: 1.5;
    color: #1c1e21;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.miw-fb-feed-card__link-text {
    color: #1877f2;
    word-break: break-all;
}

.miw-fb-feed-card__hashtag {
    color: #1877f2;
    font-weight: 500;
}

.miw-fb-feed-card__read-more {
    color: #1877f2;
    font-weight: 500;
}


/* ==========================================================================
   Card Footer
   ========================================================================== */

.miw-fb-feed-card__footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px 14px;
    border-top: 1px solid #f0f2f5;
}

.miw-fb-feed-card__stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    color: #65676b;
}

.miw-fb-feed-card__stat svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.miw-fb-feed-card__likes svg {
    color: #e74c3c;
}

.miw-fb-feed-card__comments svg {
    color: #1877f2;
}

.miw-fb-feed-card__shares svg {
    color: #2ecc71;
}


/* ==========================================================================
   Error / Empty States
   ========================================================================== */

.miw-fb-feed-error {
    text-align: center;
    padding: 40px 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    color: #856404;
    font-size: 14px;
}

.miw-fb-feed-empty {
    text-align: center;
    padding: 40px 20px;
    color: #65676b;
    font-size: 14px;
}


/* ==========================================================================
   Animations
   ========================================================================== */

.miw-fb-feed-card {
    opacity: 0;
    animation: miwFbFadeIn 0.4s ease forwards;
}

.miw-fb-feed-card:nth-child(1)  { animation-delay: 0.05s; }
.miw-fb-feed-card:nth-child(2)  { animation-delay: 0.10s; }
.miw-fb-feed-card:nth-child(3)  { animation-delay: 0.15s; }
.miw-fb-feed-card:nth-child(4)  { animation-delay: 0.20s; }
.miw-fb-feed-card:nth-child(5)  { animation-delay: 0.25s; }
.miw-fb-feed-card:nth-child(6)  { animation-delay: 0.30s; }
.miw-fb-feed-card:nth-child(7)  { animation-delay: 0.35s; }
.miw-fb-feed-card:nth-child(8)  { animation-delay: 0.40s; }
.miw-fb-feed-card:nth-child(9)  { animation-delay: 0.45s; }
.miw-fb-feed-card:nth-child(10) { animation-delay: 0.50s; }
.miw-fb-feed-card:nth-child(11) { animation-delay: 0.55s; }
.miw-fb-feed-card:nth-child(12) { animation-delay: 0.60s; }

@keyframes miwFbFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


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

@media (max-width: 1024px) {
    .miw-fb-feed--masonry.miw-fb-feed--cols-4 {
        column-count: 3;
    }

    .miw-fb-feed--grid.miw-fb-feed--cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .miw-fb-feed--masonry.miw-fb-feed--cols-3,
    .miw-fb-feed--masonry.miw-fb-feed--cols-4 {
        column-count: 2;
    }

    .miw-fb-feed--grid.miw-fb-feed--cols-3,
    .miw-fb-feed--grid.miw-fb-feed--cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .miw-fb-feed-card__header {
        padding: 12px 12px 10px;
    }

    .miw-fb-feed-card__content {
        padding: 10px 12px;
    }

    .miw-fb-feed-card__footer {
        padding: 8px 12px 12px;
    }
}

@media (max-width: 480px) {
    .miw-fb-feed--masonry.miw-fb-feed--cols-2,
    .miw-fb-feed--masonry.miw-fb-feed--cols-3,
    .miw-fb-feed--masonry.miw-fb-feed--cols-4 {
        column-count: 1;
    }

    .miw-fb-feed--grid.miw-fb-feed--cols-2,
    .miw-fb-feed--grid.miw-fb-feed--cols-3,
    .miw-fb-feed--grid.miw-fb-feed--cols-4 {
        grid-template-columns: 1fr;
    }

    .miw-fb-feed-card {
        border-radius: 8px;
    }

    .miw-fb-feed-card__avatar {
        width: 36px;
        height: 36px;
    }

    .miw-fb-feed-card__name {
        font-size: 13px;
    }

    .miw-fb-feed-card__text {
        font-size: 13px;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .miw-fb-feed-card {
        animation: none;
        opacity: 1;
    }

    .miw-fb-feed-card:hover {
        transform: none;
    }

    .miw-fb-feed-card:hover .miw-fb-feed-card__image {
        transform: none;
    }
}

/* ==========================================================================
   Divi Visual Builder (Bearbeitungsansicht)
   ========================================================================== */

/* Nur im Divi-Builder: Vorschau kompakter darstellen */
.et-fb .miw-fb-feed {
    max-width: 1200px;
}

/* In der Bearbeitungsansicht vermeiden wir riesige Einzelkarten */
.et-fb .miw-fb-feed-card__media {
    max-height: 280px;
}

.et-fb .miw-fb-feed-card__image {
    width: 100%;
    height: 100%;
    max-height: 280px;
    object-fit: cover;
}

/* Falls Divi in der Vorschau auf 1 Spalte springt, Karten nicht zu dominant machen */
.et-fb .miw-fb-feed--masonry,
.et-fb .miw-fb-feed--grid {
    gap: 14px;
    column-gap: 14px;
}
