/**
 * CROWNED Community Gallery Styles
 */

/* Community Header */
.community-header {
    background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-bg-elevated) 100%);
    padding: 8rem 2rem 4rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.community-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 50%, rgba(212, 175, 55, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.community-header-content {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
}

.community-title {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 400;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--color-text) 0%, var(--color-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.community-subtitle {
    color: var(--color-text-muted);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.community-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Community Main */
.community-main {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* Posts Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Loading State */
.posts-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--color-text-muted);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Empty State */
.posts-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--color-text-secondary);
    min-height: 300px;
}

.posts-empty svg {
    color: var(--color-gold);
    opacity: 0.5;
    margin-bottom: 1.5rem;
}

.posts-empty h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.posts-empty p {
    margin-bottom: 1.5rem;
}

/* Post Card */
.post-card {
    background: var(--color-bg-elevated);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.post-card-link {
    display: block;
    text-decoration: none;
}

.post-card-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
}

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

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

/* Post Card Content */
.post-card-content {
    padding: 1rem;
}

.post-card-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.post-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--color-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
}

.post-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-card-avatar span {
    color: var(--color-bg);
    font-weight: 600;
    font-size: 0.9rem;
}

.post-card-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.post-card-name {
    color: var(--color-text);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.post-card-name:hover {
    color: var(--color-gold);
}

/* Artist Badge (crown icon for professional artists) */
.artist-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.375rem;
    color: var(--color-gold);
    font-size: 0.75em;
    vertical-align: middle;
}

.post-card-category {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.post-card-time {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    opacity: 0.6;
}

.post-card-caption {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    height: 2.7em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Post Card Actions */
.post-card-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
    margin-top: 0.75rem;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
}

.action-btn.active {
    color: var(--color-gold);
}

.action-btn.like-btn.active svg {
    fill: var(--color-gold);
}

.action-btn.save-btn.active svg {
    fill: var(--color-gold);
}

/* Load More */
.load-more-container {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
    .community-header {
        padding: 6rem 1rem 3rem;
    }

    .community-title {
        font-size: 2rem;
    }

    .community-main {
        padding: 1rem;
    }

    .posts-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .posts-grid {
        grid-template-columns: 1fr;
    }
}

/* Post Modal */
.post-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.post-modal.open {
    opacity: 1;
}

.post-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
}

.post-modal-content {
    position: relative;
    display: flex;
    max-width: 1000px;
    max-height: 90vh;
    width: 95%;
    background: var(--color-bg-elevated);
    border-radius: 12px;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.post-modal.open .post-modal-content {
    transform: scale(1);
}

.post-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s ease;
}

.post-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.post-modal-image {
    flex: 1;
    min-width: 0;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-modal-image img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.post-modal-details {
    width: 350px;
    flex-shrink: 0;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.post-modal-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.post-modal-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--color-gold);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
}

.post-modal-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-modal-avatar span {
    color: var(--color-bg);
    font-weight: 600;
    font-size: 1.1rem;
}

.post-modal-user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.post-modal-name {
    color: var(--color-text);
    font-weight: 500;
    text-decoration: none;
    font-size: 1rem;
}

.post-modal-name:hover {
    color: var(--color-gold);
}

.post-modal-category {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.post-modal-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    opacity: 0.6;
}

.post-modal-caption {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--color-text-secondary);
    margin-bottom: 1rem;
}

.post-modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.post-modal-tag {
    color: var(--color-gold);
    font-size: 0.85rem;
}

.post-modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.post-modal-actions .action-btn {
    flex: 1;
    justify-content: center;
    padding: 0.75rem;
}

.post-modal-actions .action-stat {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.post-modal-actions .action-stat svg {
    opacity: 0.7;
}

/* Owner Menu in Modal */
.post-modal-menu {
    position: relative;
    margin-left: auto;
}

.post-owner-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--color-gold);
    border-radius: 8px;
    color: var(--color-gold);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.post-owner-btn:hover {
    background: rgba(212, 175, 55, 0.25);
}

/* Report Button in Modal Action Bar */
.post-report-btn {
    margin-left: auto;
}

.post-report-btn:hover {
    color: #ef4444 !important;
}

.post-menu-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 160px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 100;
}

.post-menu-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.post-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--color-text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease;
    text-align: left;
}

.post-menu-item:first-child {
    border-radius: 8px 8px 0 0;
}

.post-menu-item:last-child {
    border-radius: 0 0 8px 8px;
}

.post-menu-item:hover {
    background: var(--color-bg-hover);
}

.post-menu-item.delete-post-btn {
    color: #e74c3c;
}

.post-menu-item.delete-post-btn:hover {
    background: rgba(231, 76, 60, 0.15);
}

/* Mobile modal - Full screen takeover */
@media (max-width: 768px) {
    .post-modal-content {
        flex-direction: column;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .post-modal-close {
        top: 0.75rem;
        right: 0.75rem;
        background: rgba(0, 0, 0, 0.7);
    }

    .post-modal-image {
        flex: 0 0 auto;
        max-height: 55vh;
        min-height: 40vh;
    }

    .post-modal-image img {
        width: 100%;
        height: 100%;
        max-height: 55vh;
        object-fit: contain;
    }

    .post-modal-details {
        flex: 1;
        width: 100%;
        max-height: none;
        padding: 1rem;
        overflow-y: auto;
    }

    .post-modal-user {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .post-modal-menu {
        order: 3;
        width: 100%;
        margin-left: 0;
        margin-top: 0.75rem;
    }

    .post-owner-btn {
        width: 100%;
        justify-content: center;
    }

    .post-menu-dropdown {
        left: 0;
        right: 0;
        min-width: auto;
    }

    .post-modal-actions {
        padding-bottom: 1rem;
    }
}

/* Post Edit Modal */
.post-edit-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.post-edit-modal.open {
    opacity: 1;
}

.post-edit-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

.post-edit-content {
    position: relative;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    background: var(--color-bg-elevated);
    border-radius: 12px;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.post-edit-modal.open .post-edit-content {
    transform: scale(1);
}

.post-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.post-edit-header h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}

.post-edit-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.post-edit-close:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.post-edit-form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

.post-edit-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.post-edit-form label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--color-text);
}

.post-edit-form textarea {
    width: 100%;
    padding: 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.post-edit-form textarea:focus {
    outline: none;
    border-color: var(--color-gold);
}

.post-edit-form .char-count {
    align-self: flex-end;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.post-edit-form .category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.post-edit-form .category-chip {
    padding: 0.5rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    background: transparent;
    color: var(--color-text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.post-edit-form .category-chip:hover {
    border-color: var(--color-gold);
    color: var(--color-gold);
}

.post-edit-form .category-chip.active {
    background: var(--color-gold);
    border-color: var(--color-gold);
    color: var(--color-bg);
}

.post-edit-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 0.5rem;
}

@media (max-width: 768px) {
    .post-edit-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .post-edit-form {
        max-height: calc(100vh - 80px);
    }

    .post-edit-actions {
        flex-direction: column;
    }

    .post-edit-actions .btn {
        width: 100%;
    }
}
