/* TikTok Grid Layout */

.tiktok-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px 0;
}

@media (min-width: 768px) {
    .tiktok-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
}

@media (min-width: 1024px) {
    .tiktok-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

/* TikTok Card */
.tiktok-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    cursor: pointer;
    aspect-ratio: 2 / 3;
    transition: transform 0.2s ease;
}

.tiktok-card:hover {
    transform: translateY(-4px);
}

.tiktok-card-media {
    width: 100%;
    height: 100%;
}

.tiktok-card-media img,
.tiktok-card-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #fff;
    font-size: 14px;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

.tiktok-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 10px 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.tiktok-card-info {
    width: 100%;
}

.tiktok-card-caption {
    font-size: 13px;
    margin-bottom: 8px;
    line-height: 1.2;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tiktok-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tiktok-card-user {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 70%;
}

.tiktok-card-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #fff;
    object-fit: cover;
}

.tiktok-card-user span {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
}

.tiktok-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tiktok-card-action-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 8px;
    border-radius: 12px;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    transition: transform 0.1s ease;
}

.tiktok-card-action-item:active {
    transform: scale(0.9);
}

.tiktok-card-action-item i {
    font-size: 12px;
}

.text-danger {
    color: #ff2d55 !important;
}

/* Fullscreen Overlay Styles */
.post-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 10000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#post-overlay-content {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

.fullscreen-post {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #000;
}

.fullscreen-media {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    background: #000;
}

.fullscreen-video,
.fullscreen-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.fullscreen-back {
    position: absolute;
    top: env(safe-area-inset-top, 20px);
    left: 15px;
    color: #fff;
    font-size: 22px;
    z-index: 100;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    padding: 10px;
}

.fullscreen-actions {
    position: absolute;
    right: 12px;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    z-index: 99;
}

.fullscreen-actions .action-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
    cursor: pointer;
    text-align: center;
}

.fullscreen-actions .action-item i {
    font-size: 30px;
    margin-bottom: 2px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.fullscreen-actions .action-item span {
    font-size: 11px;
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.fullscreen-actions .profile-item {
    margin-bottom: 5px;
}

.fullscreen-actions .profile-item img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.fullscreen-actions .plus-icon {
    position: absolute;
    bottom: -6px;
    background: #ff2d55;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    color: #fff;
    left: 50%;
    transform: translateX(-50%);
}

.fullscreen-info {
    position: absolute;
    left: 15px;
    bottom: env(safe-area-inset-bottom, 30px);
    right: 80px;
    color: #fff;
    z-index: 98;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.fullscreen-info h4 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
}

.fullscreen-info .caption {
    font-size: 15px;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
}

.comments-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%;
    background: #fff;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.15, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    color: #333;
}

.comments-drawer.open {
    transform: translateY(0);
}

.drawer-header {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: center;
    position: relative;
    font-weight: 700;
    font-size: 14px;
}

.drawer-header button {
    position: absolute;
    right: 15px;
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.drawer-footer {
    padding: 12px 15px;
    padding-bottom: env(safe-area-inset-bottom, 12px);
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 10px;
    align-items: center;
    background: #fff;
}

.drawer-footer input {
    flex: 1;
    border: 1px solid #eee;
    border-radius: 20px;
    padding: 10px 18px;
    background: #f5f5f5;
    font-size: 14px;
    outline: none;
}

.drawer-footer button {
    color: #ff2d55;
    font-weight: 700;
    background: none;
    border: none;
    font-size: 15px;
}

.modal-open {
    overflow: hidden !important;
}

.hidden {
    display: none !important;
}

/* Mobile View Adjustments */
@media (max-width: 767px) {
    .feed-main-container {
        padding-top: 10px !important;
        padding-bottom: 120px !important;
        /* Space for fixed bottom menu */
    }

    .feed-header-section {
        margin-bottom: 15px !important;
    }

    .tiktok-grid {
        gap: 8px;
    }
}

/* Share Modal Styles (kept for compatibility) */
.share-modal-content {
    border-radius: 15px;
    border: none;
}

.share-option {
    display: flex;
    align-items: center;
    padding: 12px;
    text-decoration: none;
    color: #262626;
    border-radius: 8px;
    transition: background 0.2s;
}

.share-option:hover {
    background: #f8f9fa;
    text-decoration: none;
    color: #262626;
}

.share-option i {
    font-size: 20px;
    width: 30px;
    margin-right: 12px;
}

.copy-link-container {
    display: flex;
    align-items: center;
    background: #f1f1f1;
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 15px;
}

.copy-link-input {
    border: none;
    background: transparent;
    flex-grow: 1;
    font-size: 14px;
    color: #8e8e8e;
    outline: none;
}

.copy-link-btn {
    background: none;
    border: none;
    color: #0095f6;
    font-weight: 600;
    cursor: pointer;
}

/* Category Slider */
.category-slider-container {
    overflow-x: auto;
    white-space: nowrap;
    padding: 10px 0 20px;
    -ms-overflow-style: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 5px;
}

.category-slider-container::-webkit-scrollbar {
    display: none;
}

.category-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin-right: 18px;
    cursor: pointer;
    transition: opacity 0.2s;
    text-decoration: none !important;
    width: 75px;
    vertical-align: top;
}

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

.category-icon-wrapper {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 8px;
    border: 0px solid #f0f0f0;
    transition: all 0.2s;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.category-icon-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-name-label {
    font-size: 11px;
    font-weight: 700;
    color: white;
   text-shadow: 1px 1px 2px black;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.2;
}

.category-item.active .category-icon-wrapper {
    border-color: #58d0d5;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(88, 208, 213, 0.3);
}

.category-item.active .category-name-label {
    color: white;
    text-shadow: 1px 1px 2px black;
}

.all-category-icon {
    font-size: 24px;
    color: #58d0d5;
}

.category-item:hover .category-icon-wrapper {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Create Post Circle Button */
.create-post-circle {
    position: fixed;
    bottom: 180px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #FD5B22;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white !important;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none !important;
}

.create-post-circle:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 20px rgba(88, 208, 213, 0.6);
}

.create-post-circle:active {
    transform: scale(0.95);
}

@media (max-width: 767px) {
    .create-post-circle {
        bottom: 180px;
        /* Above bottom nav */
        right: 20px;
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
}

/* Double Click Heart Animation */
.heart-pop {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    color: #ff2d55;
    font-size: 100px;
    z-index: 10001;
    pointer-events: none;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    animation: heart-pop-anim 0.8s ease-out forwards;
}

@keyframes heart-pop-anim {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    40% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    80% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* ===== Grid card: brand intro overlay (hover) ===== */
.tiktok-card-media {
    position: relative;
}
.tiktok-card-intro {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    width: 75%;
    max-width: 180px;
    min-height: 120px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 14px;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 1;
    pointer-events: auto;
    transition: transform 0.35s ease;
    z-index: 3;
    cursor: pointer;
}
/* Wrapper acts as the circular frame (border + shadow stay constant).
   Inner <img> is scaled up to compensate for logos uploaded with built-in
   whitespace padding — tight logos get a slight edge crop in exchange. */
.tiktok-card-intro-logo {
    width: 56px;
    height: 56px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid #fff;
    background: #fff;
    box-sizing: border-box;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: block;
    position: relative;
}
.tiktok-card-intro-logo > img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transform: scale(1.25);
    transform-origin: center;
    display: block;
}
/* Back-compat: if .tiktok-card-intro-logo is used directly on <img> (legacy markup),
   keep object-fit: cover but skip the scale — wrapping is preferred going forward. */
img.tiktok-card-intro-logo {
    object-fit: cover;
    object-position: center;
}
.tiktok-card-intro-name {
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    width: 100%;
    text-align: center;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* Bump persistent logo size in grid footer */
.tiktok-card-avatar {
    width: 28px !important;
    height: 28px !important;
}
.tiktok-card-user span {
    font-size: 12px !important;
}

/* ===== Fullscreen: bigger pulsating brand logo ===== */
/* --cat-color / --cat-rgb come from the .pulsate element's inline style,
   driven by the linked business's category main_color. */
.fullscreen-actions .profile-item.pulsate img {
    width: 64px;
    height: 64px;
    border: 3px solid var(--cat-color, #58d0d5);
    box-shadow: 0 0 0 0 rgba(var(--cat-rgb, 88, 208, 213), 0.85);
    animation: pulse-logo 2s ease-out infinite;
}
.fullscreen-actions .profile-item .profile-cta {
    display: block;
    margin-top: 6px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: var(--cat-color, #58d0d5);
    padding: 2px 8px;
    border-radius: 10px;
    text-shadow: none;
    white-space: nowrap;
}
@keyframes pulse-logo {
    0%   { box-shadow: 0 0 0 0 rgba(var(--cat-rgb, 88, 208, 213), 0.85); transform: scale(1); }
    70%  { box-shadow: 0 0 0 18px rgba(var(--cat-rgb, 88, 208, 213), 0); transform: scale(1.08); }
    100% { box-shadow: 0 0 0 0 rgba(var(--cat-rgb, 88, 208, 213), 0); transform: scale(1); }
}