/* ==========================================================================
   Free Flow Gram — Public Stylesheet
   Mobile-first, Instagram-inspired UI
   ========================================================================== */

:root {
    --ffg-primary: #405de6;
    --ffg-accent: #e1306c;
    --ffg-heart: #ed4956;
    --ffg-bg: #fafafa;
    --ffg-card: #ffffff;
    --ffg-border: #dbdbdb;
    --ffg-text: #262626;
    --ffg-text-light: #8e8e8e;
    --ffg-radius: 8px;
    --ffg-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --ffg-max-width: 614px;
}

/* ---- Layout ---- */

.ffg-container {
    max-width: var(--ffg-max-width);
    margin: 0 auto;
    padding: 0 12px;
}

/* ---- Feed ---- */

.ffg-feed {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 60px;
}

.ffg-post {
    background: var(--ffg-card);
    border: 1px solid var(--ffg-border);
    border-radius: var(--ffg-radius);
    overflow: hidden;
    box-shadow: var(--ffg-shadow);
}

.ffg-post-header {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    gap: 10px;
}

.ffg-post-header img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.ffg-post-header .ffg-author-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ffg-text);
    text-decoration: none;
}

.ffg-post-header .ffg-author-name:hover {
    text-decoration: underline;
}

.ffg-post-image {
    width: 100%;
    display: block;
    aspect-ratio: 1/1;
    object-fit: cover;
    background: #efefef;
    cursor: pointer;
}

.ffg-post-video {
    width: 100%;
    display: block;
    max-height: 600px;
    background: #000;
}

.ffg-post-actions {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    gap: 16px;
}

.ffg-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--ffg-text);
    padding: 4px;
    line-height: 1;
    transition: transform 0.15s ease;
}

.ffg-action-btn:hover {
    transform: scale(1.15);
}

.ffg-action-btn.ffg-liked {
    color: var(--ffg-heart);
}

.ffg-action-btn.ffg-bookmarked {
    color: var(--ffg-primary);
}

.ffg-action-spacer {
    flex: 1;
}

.ffg-like-count {
    font-weight: 600;
    font-size: 14px;
    padding: 0 14px 4px;
}

.ffg-caption {
    padding: 0 14px 8px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--ffg-text);
}

.ffg-caption .ffg-caption-author {
    font-weight: 600;
    margin-right: 4px;
}

.ffg-caption .ffg-hashtag {
    color: var(--ffg-primary);
    text-decoration: none;
}

.ffg-caption .ffg-hashtag:hover {
    text-decoration: underline;
}

.ffg-view-comments {
    padding: 0 14px 4px;
    color: var(--ffg-text-light);
    font-size: 14px;
    cursor: pointer;
    background: none;
    border: none;
}

.ffg-timestamp {
    display: block;
    padding: 0 14px 12px;
    font-size: 10px;
    color: var(--ffg-text-light);
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

/* ---- Comment form inside post ---- */

.ffg-comment-form {
    display: flex;
    border-top: 1px solid var(--ffg-border);
    padding: 8px 14px;
    align-items: center;
    gap: 8px;
}

.ffg-comment-form input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 4px 0;
    background: transparent;
}

.ffg-comment-form button {
    background: none;
    border: none;
    color: var(--ffg-primary);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.ffg-comment-form button:not(:disabled) {
    opacity: 1;
}

/* ---- Comments overlay ---- */

.ffg-comments-panel {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.ffg-comments-panel.hidden { display: none; }

.ffg-comments-sheet {
    background: var(--ffg-card);
    width: 100%;
    max-width: 500px;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ffg-comments-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 16px;
    border-bottom: 1px solid var(--ffg-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ffg-comments-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--ffg-text-light);
}

.ffg-comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.ffg-comment-item {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.ffg-comment-item img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.ffg-comment-item .ffg-comment-body {
    font-size: 14px;
    line-height: 1.4;
}

.ffg-comment-item .ffg-comment-author {
    font-weight: 600;
    margin-right: 4px;
}

.ffg-comment-item .ffg-comment-time {
    font-size: 11px;
    color: var(--ffg-text-light);
    margin-top: 2px;
}

.ffg-comment-item .ffg-reply-btn {
    font-size: 11px;
    color: var(--ffg-text-light);
    cursor: pointer;
    background: none;
    border: none;
    font-weight: 600;
    margin-left: 8px;
}

/* ---- Profile Grid ---- */

.ffg-profile-header {
    display: flex;
    gap: 24px;
    padding: 20px 0;
    align-items: center;
}

.ffg-profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--ffg-border);
}

.ffg-profile-info h2 {
    font-size: 20px;
    font-weight: 400;
    margin: 0 0 4px;
}

.ffg-profile-stats {
    display: flex;
    gap: 24px;
    font-size: 14px;
}

.ffg-profile-stats span {
    color: var(--ffg-text-light);
}

.ffg-profile-stats strong {
    color: var(--ffg-text);
}

.ffg-profile-bio {
    font-size: 14px;
    margin-top: 6px;
    color: var(--ffg-text);
}

.ffg-follow-btn {
    padding: 6px 20px;
    border-radius: 6px;
    border: 1px solid var(--ffg-primary);
    background: var(--ffg-primary);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.ffg-follow-btn.ffg-following {
    background: transparent;
    color: var(--ffg-text);
    border-color: var(--ffg-border);
}

.ffg-media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
}

.ffg-media-grid-item {
    aspect-ratio: 1/1;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.ffg-media-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.2s;
}

.ffg-media-grid-item:hover img {
    opacity: 0.8;
}

.ffg-media-grid-item .ffg-grid-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(0,0,0,0.3);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.ffg-media-grid-item:hover .ffg-grid-overlay {
    opacity: 1;
}

/* ---- Upload form ---- */

.ffg-upload-area {
    border: 2px dashed var(--ffg-border);
    border-radius: var(--ffg-radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}

.ffg-upload-area:hover,
.ffg-upload-area.ffg-drag-over {
    border-color: var(--ffg-primary);
    background: rgba(64, 93, 230, 0.04);
}

.ffg-upload-area .ffg-upload-icon {
    font-size: 48px;
    color: var(--ffg-text-light);
    margin-bottom: 8px;
}

.ffg-upload-preview {
    max-width: 300px;
    margin: 12px auto;
    border-radius: var(--ffg-radius);
    overflow: hidden;
}

.ffg-upload-preview img,
.ffg-upload-preview video {
    width: 100%;
    display: block;
}

.ffg-upload-form textarea {
    width: 100%;
    border: 1px solid var(--ffg-border);
    border-radius: var(--ffg-radius);
    padding: 10px;
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
    margin-bottom: 12px;
}

.ffg-upload-form select,
.ffg-upload-form button[type="submit"] {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.ffg-upload-form select {
    border: 1px solid var(--ffg-border);
    margin-right: 8px;
}

.ffg-upload-form button[type="submit"] {
    background: var(--ffg-primary);
    color: #fff;
    border: none;
    font-weight: 600;
}

.ffg-upload-form button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: default;
}

.ffg-upload-progress {
    width: 100%;
    height: 4px;
    background: var(--ffg-border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
    display: none;
}

.ffg-upload-progress .ffg-progress-bar {
    height: 100%;
    background: var(--ffg-primary);
    width: 0;
    transition: width 0.3s;
}

/* ---- Lightbox ---- */

.ffg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ffg-lightbox.hidden { display: none; }

.ffg-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
}

.ffg-lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    background: var(--ffg-card);
    border-radius: var(--ffg-radius);
    overflow: hidden;
}

.ffg-lightbox-content img {
    max-width: 60vw;
    max-height: 90vh;
    object-fit: contain;
}

.ffg-lightbox-sidebar {
    width: 340px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--ffg-border);
}

/* ---- Notifications badge ---- */

.ffg-notif-badge {
    background: var(--ffg-heart);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    position: relative;
    top: -8px;
    left: -6px;
}

/* ---- Bottom nav (mobile) ---- */

.ffg-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--ffg-card);
    border-top: 1px solid var(--ffg-border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 9999;
}

.ffg-bottom-nav a {
    color: var(--ffg-text);
    font-size: 22px;
    text-decoration: none;
    position: relative;
}

.ffg-bottom-nav a.active {
    color: var(--ffg-primary);
}

/* ---- Skeleton loading ---- */

.ffg-skeleton {
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
    background-size: 200% 100%;
    animation: ffg-shimmer 1.5s infinite;
    border-radius: var(--ffg-radius);
}

@keyframes ffg-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ffg-skeleton-post {
    height: 400px;
    margin-bottom: 20px;
}

.ffg-skeleton-grid-item {
    aspect-ratio: 1/1;
}

/* ---- Infinite scroll sentinel ---- */

.ffg-load-more {
    text-align: center;
    padding: 20px;
    color: var(--ffg-text-light);
    font-size: 14px;
}

.ffg-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--ffg-border);
    border-top-color: var(--ffg-primary);
    border-radius: 50%;
    animation: ffg-spin 0.8s linear infinite;
}

@keyframes ffg-spin {
    to { transform: rotate(360deg); }
}

/* ---- Login notice ---- */

.ffg-login-notice {
    text-align: center;
    padding: 40px 20px;
    color: var(--ffg-text-light);
    font-size: 16px;
}

/* ---- Responsive ---- */

@media (min-width: 768px) {
    .ffg-bottom-nav {
        display: none;
    }
    .ffg-profile-avatar {
        width: 120px;
        height: 120px;
    }
    .ffg-profile-header {
        gap: 40px;
    }
}

@media (max-width: 767px) {
    .ffg-lightbox-content {
        flex-direction: column;
    }
    .ffg-lightbox-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--ffg-border);
        max-height: 40vh;
    }
    .ffg-lightbox-content img {
        max-width: 100vw;
        max-height: 50vh;
    }
}
