/* =========================================
   Arquivo: filex/css/postagem.css
   XONA — POSTAGEM (componente partilhado)
   Usado por index.php (feed) e perfil.php
   Requer main.css carregado antes.
   ========================================= */

/* =========================================
   CARD DA PUBLICAÇÃO
   ========================================= */
.post-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s, background-color 0.3s;
}
.post-card:hover { border-color: var(--accent-pink); }

/* Cabeçalho */
.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}
.post-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.post-user-name {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.verified-badge {
    color: var(--accent-pink);
    font-size: 14px;
}
.post-time {
    font-size: 12px;
    color: var(--text-muted);
}
.post-menu {
    margin-left: auto;
    background: none;
    color: var(--text-secondary);
    font-size: 18px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
}
.post-menu:hover {
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

/* Texto */
.post-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 16px;
    white-space: pre-line;
}

/* Avatar usado nos posts */
.avatar-medium {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

/* =========================================
   MEDIA — GALERIA DINÂMICA
   ========================================= */
.post-media,
.profile-post-media {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: var(--bg-dark);
}

.post-media-item {
    position: relative;
    overflow: hidden;
    background-color: var(--bg-dark);
    cursor: pointer;
}
.post-media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
    display: block;
}
.post-media-item:hover img { transform: scale(1.03); }

/* =========================================
   1 IMAGEM
   ========================================= */
.post-media.count-1 {
    display: block;
    width: 100%;
}
.post-media.count-1 .post-media-item {
    width: 100%;
    height: auto;
    max-height: 680px;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.post-media.count-1 img {
    width: 100%;
    height: auto;
    max-height: 680px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* =========================================
   2 IMAGENS
   ========================================= */
.post-media.count-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    aspect-ratio: 16 / 9;
}

/* =========================================
   3 IMAGENS
   ========================================= */
.post-media.count-3 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px;
    aspect-ratio: 16 / 9;
}
.post-media.count-3 .post-media-item:first-child {
    grid-row: 1 / 3;
    grid-column: 1;
}
.post-media.count-3 .post-media-item:nth-child(2),
.post-media.count-3 .post-media-item:nth-child(3) {
    grid-column: 2;
}

/* =========================================
   4 IMAGENS — altura reduzida em ~35%
   ========================================= */
.post-media.count-4 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px;
    aspect-ratio: 1 / 0.65;
}
.post-media.count-4 .post-media-item {
    min-width: 0;
    min-height: 0;
}
.post-media.count-4 .post-media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =========================================
   5+ IMAGENS — grelha 2×2 + +N na quarta
   Altura reduzida em ~35%
   ========================================= */
.post-media.count-many {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px;
    aspect-ratio: 1 / 0.65;
}
.post-media.count-many .post-media-item {
    min-width: 0;
    min-height: 0;
}
.post-media.count-many .post-media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =========================================
   OVERLAY +N — só na quarta imagem
   ========================================= */
.post-media-item.has-more .gallery-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.52);
    color: #fff;
    font-size: 25px;
    font-weight: 700;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

/* =========================================
   BOTÃO DE PLAY (vídeo)
   ========================================= */
.play-button-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

/* =========================================
   LIGHTBOX
   ========================================= */
.media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.94);
    display: none;
    align-items: center;
    justify-content: center;
}
.media-lightbox.open { display: flex; }

.lightbox-content {
    position: relative;
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-content img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

.lightbox-counter {
    position: absolute;
    top: -36px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 12px;
    border-radius: 12px;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    z-index: 2;
}
.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.25);
}
.lightbox-close { top: 20px; right: 20px; }
.lightbox-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 20px; top: 50%; transform: translateY(-50%); }

body.lightbox-open { overflow: hidden; }

/* =========================================
   AÇÕES DO POST
   ========================================= */
.post-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.action-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    font-family: inherit;
}
.action-item:hover {
    background-color: var(--bg-dark);
    color: var(--text-primary);
}
.action-item.liked,
.action-item.liked i,
.action-item.saved,
.action-item.saved i {
    color: var(--accent-pink);
}

.action-item.tip-btn {
    margin-left: 0;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
}
.action-item.tip-btn:hover {
    border-color: var(--accent-pink);
    color: var(--accent-pink);
}

.action-item.save-btn { margin-left: auto; }

/* =========================================
   COMENTÁRIOS
   ========================================= */
.comments-section {
    display: none;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}
.comments-section.open { display: block; }

.comment-item {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.comment-content { flex: 1; }
.comment-author {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.comment-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.comment-input-wrapper {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}
.comment-input-wrapper input {
    flex: 1;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}
.comment-input-wrapper input:focus { border-color: var(--accent-pink); }

/* =========================================
   VARIANTE — POST DO PERFIL
   ========================================= */
.profile-post {
    width: 100%;
    margin: 0;
}
.profile-post .tip-btn { margin-left: 0 !important; }
.profile-post .save-btn { margin-left: auto; }

/* Media bloqueada (paga ou assinantes) */
.locked-content {
    position: relative;
    width: 100%;
    max-height: 680px;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: var(--bg-dark);
}
.locked-content img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 680px;
    min-height: 0;
    object-fit: cover;
    filter: blur(12px);
    transform: scale(1.03);
}

.locked-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px;
    background: linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.68));
    color: #ffffff;
    z-index: 3;
}

.locked-icon {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    margin-bottom: 14px;
    font-size: 22px;
}

.locked-overlay strong { font-size: 18px; margin-bottom: 6px; }

.locked-overlay span {
    max-width: 320px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 18px;
}

.unlock-btn,
.subscribe-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 10px;
    background: var(--accent-pink);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}
.unlock-btn:hover,
.subscribe-btn:hover {
    background: var(--accent-pink-hover);
    transform: translateY(-1px);
}

/* =========================================
   MOBILE
   ========================================= */
@media (max-width: 768px) {

    .post-card {
        width: 100%;
        padding: 16px;
        border-radius: var(--radius-lg);
    }
    .post-card:hover { border-color: var(--border-color); }

    .post-header { gap: 10px; margin-bottom: 12px; }
    .post-header .avatar-medium { width: 42px; height: 42px; }
    .post-user-name { font-size: 15px; }
    .post-time { font-size: 12px; }
    .post-text { font-size: 15px; line-height: 1.5; margin-bottom: 12px; }

    .post-media.count-1 img { max-height: 560px; object-fit: contain; }

    .post-media.count-2 { aspect-ratio: 1 / 1; }

    .post-media.count-3 {
        aspect-ratio: 1 / 1;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
    }
    .post-media.count-3 .post-media-item:first-child {
        grid-column: 1 / 3;
        grid-row: 1;
    }
    .post-media.count-3 .post-media-item:nth-child(2),
    .post-media.count-3 .post-media-item:nth-child(3) {
        grid-row: 2;
        grid-column: auto;
    }

    .post-media.count-4,
    .post-media.count-many { aspect-ratio: 1 / 0.75; }

    .post-media-item.has-more .gallery-more { font-size: 20px; }

    .lightbox-prev,
    .lightbox-next {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    .lightbox-close {
        width: 38px;
        height: 38px;
        font-size: 16px;
        top: 12px;
        right: 12px;
    }
    .lightbox-prev { left: 10px; }
    .lightbox-next { right: 10px; }

    .play-button-overlay { width: 48px; height: 48px; font-size: 16px; }

    .post-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        padding-top: 12px;
    }
    .action-item {
        font-size: 13px;
        padding: 6px 6px;
        gap: 6px;
        min-height: 40px;
    }
    .action-item i { font-size: 20px; }
    .action-item.tip-btn {
        margin-left: 0;
        margin-right: 0;
        min-height: 38px;
        padding: 6px 10px;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        white-space: nowrap;
    }
    .action-item.save-btn { margin-left: auto; }

    .profile-post { border-radius: var(--radius-md); }
    .profile-post-media { border-radius: 10px; }

    .locked-content { max-height: 560px; }
    .locked-content img {
        display: block;
        width: 100%;
        height: auto;
        min-height: 0;
        max-height: 560px;
        object-fit: cover;
    }
    .locked-overlay { padding: 20px; }
    .locked-overlay strong { font-size: 16px; }
    .locked-overlay span { font-size: 12px; }
    .unlock-btn,
    .subscribe-btn {
        padding: 10px 15px;
        font-size: 13px;
    }
}