/* Instagram Reels — Gallery page */
body.ig-reels-body {
    overflow: hidden;
    background: #f5f5f5;
}

:root {
    --cg-nav-height: 80px;
    --ig-like: #ff3040;
    --ig-text: #fff;
}

@media (max-width: 768px) {
    :root {
        --cg-nav-height: 60px;
    }
}

/* ── Reels full-screen app ── */
.ig-reels-app {
    position: fixed;
    top: var(--cg-nav-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    background: #000;
    direction: ltr;
    color: var(--ig-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.ig-reels-app.is-hidden {
    display: none;
}

.ig-reels-swiper {
    width: 100%;
    height: 100%;
}

.ig-reels-swiper .swiper-slide {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}

.ig-reel-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    z-index: 1;
}

.ig-reel-media-wrap {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.ig-reel-media-wrap.has-carousel .ig-reel-media-swiper,
.ig-reel-media-wrap.has-carousel .ig-reel-media-slide {
    width: 100%;
    height: 100%;
}

.ig-reel-media-wrap.has-carousel .ig-reel-media-swiper {
    position: absolute;
    inset: 0;
}

.ig-reel-media-wrap.has-carousel .ig-reel-media-slide {
    position: relative;
    overflow: hidden;
    background: #000;
}

.ig-reel-media-nav {
    position: absolute;
    top: 50%;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    transform: translateY(-50%);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.ig-reel-media-nav svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.ig-reel-media-nav--prev {
    left: 12px;
}

.ig-reel-media-nav--next {
    right: 12px;
}

.ig-reel-media-nav:hover,
.ig-reel-media-nav:focus {
    background: rgba(0, 0, 0, 0.62);
    outline: none;
}

.ig-reel-media-nav.swiper-button-disabled {
    opacity: 0.28;
    pointer-events: none;
}

.ig-reel-media-dots {
    position: absolute;
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    max-width: calc(100% - 104px);
    transform: translateX(-50%);
    pointer-events: auto;
}

.ig-reel-media-dot {
    flex: 0 0 auto;
    width: 28px;
    height: 5px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.ig-reel-media-dot.is-active {
    background: #fff;
    opacity: 1;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.55);
}

.ig-reel-media-dot:focus {
    outline: none;
}

.ig-reel-media-dot:focus-visible {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.ig-reel-gradient {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 18%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
    z-index: 2;
}

/* Header */
.ig-reel-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    min-height: 44px;
}

.ig-reel-back,
.ig-reel-camera {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    padding: 0;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.ig-reel-back svg,
.ig-reel-camera svg {
    width: 24px;
    height: 24px;
}

.ig-reel-author-link {
    flex: 1;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    padding: 0 6px;
    direction: rtl;
}

.ig-reel-author-link:active {
    opacity: 0.88;
}

.ig-reel-author-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
}

.ig-reel-author-avatar-wrap .ig-reel-author-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.88);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.ig-reel-author-avatar--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 14px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ig-reel-author-link .ig-reel-title {
    max-width: 100%;
    flex: 1;
    min-width: 0;
}

.ig-reel-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: rtl;
}

/* Right action rail */
.ig-reel-actions {
    position: absolute;
    right: 8px;
    bottom: 108px;
    z-index: 11;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.ig-reel-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    border: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
    padding: 0;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.ig-reel-action svg {
    width: 22px;
    height: 22px;
}

.ig-reel-action.is-liked svg {
    fill: var(--ig-like);
    stroke: var(--ig-like);
}

.ig-reel-action-count {
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    min-width: 22px;
    text-align: center;
}

/* Bottom-left meta (Instagram Reels style) */
.ig-reel-footer {
    position: absolute;
    left: 12px;
    right: 56px;
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 10;
    direction: rtl;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    pointer-events: none;
}

.ig-reel-footer > * {
    pointer-events: auto;
}

.ig-reel-gallery-name {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.35;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ig-reel-description {
    width: 100%;
    margin: 0 0 6px;
    direction: rtl;
}

.ig-reel-description__line {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
    direction: rtl;
}

.ig-reel-description.is-expanded .ig-reel-description__line {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}

.ig-reel-description__text {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ig-reel-description.is-expanded .ig-reel-description__text {
    flex: none;
    width: 100%;
    white-space: pre-wrap;
    overflow: visible;
    text-overflow: unset;
}

.ig-reel-description__controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    direction: rtl;
}

.ig-reel-description.is-expanded .ig-reel-description__controls {
    align-self: flex-end;
    margin-top: 2px;
}

.ig-reel-description__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-top: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.82);
    cursor: pointer;
    flex: 0 0 auto;
}

.ig-reel-description__toggle svg {
    width: 15px;
    height: 15px;
    pointer-events: none;
    transition: transform 0.2s ease;
}

.ig-reel-description.is-expanded .ig-reel-description__toggle svg {
    transform: rotate(180deg);
}

.ig-reel-datetime {
    display: inline-block;
    flex: 0 0 auto;
    margin: 0;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.72);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.ig-reel-datetime--solo {
    display: block;
    margin: 0 0 8px;
}

.ig-reel-caption {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.35;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ig-reel-book-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    padding: 9px 18px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(234, 88, 12, 0.42);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    max-width: 100%;
    white-space: nowrap;
}

.ig-reel-book-btn:hover,
.ig-reel-book-btn:focus {
    background: linear-gradient(135deg, #fb923c 0%, #c2410c 100%);
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(234, 88, 12, 0.5);
}

.ig-reel-audio {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    overflow: hidden;
}

.ig-reel-audio svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.ig-reel-audio-track {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* Comments sheet */
.ig-comments-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1300;
    display: none;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.ig-comments-backdrop.is-open {
    display: flex;
}

.ig-comments-sheet {
    width: 100%;
    max-width: 500px;
    max-height: 78vh;
    background: #fff;
    border-radius: 22px 22px 0 0;
    display: flex;
    flex-direction: column;
    direction: rtl;
    color: #1f2937;
    box-shadow: 0 -12px 48px rgba(15, 23, 42, 0.2);
    animation: ig-sheet-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
}

@keyframes ig-sheet-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.ig-comments-handle {
    width: 42px;
    height: 4px;
    margin: 10px auto 2px;
    border-radius: 999px;
    background: #d1d5db;
    flex-shrink: 0;
}

.ig-comments-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 52px 14px;
}

.ig-comments-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
}

.ig-comments-close {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    cursor: pointer;
    color: #374151;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.ig-comments-close:hover,
.ig-comments-close:focus {
    background: #e5e7eb;
    color: #111827;
}

.ig-comments-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px 12px;
    min-height: 140px;
    max-height: calc(78vh - 168px);
}

.ig-comments-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 140px;
    padding: 28px 20px;
    text-align: center;
    color: #9ca3af;
}

.ig-comments-empty.is-hidden {
    display: none;
}

.ig-comments-empty__icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #f3f4f6;
    color: #9ca3af;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 4px;
}

.ig-comments-empty p {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #6b7280;
}

.ig-comments-empty span {
    font-size: 13px;
    line-height: 1.5;
    color: #9ca3af;
}

.ig-comment-row {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f3f4f6;
}

.ig-comment-row:last-child {
    border-bottom: none;
}

.ig-comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.ig-comment-text {
    flex: 1;
    min-width: 0;
}

.ig-comment-text b {
    font-weight: 700;
    margin-left: 6px;
    color: #111827;
}

.ig-comment-text span {
    font-size: 12px;
    color: #9ca3af;
    margin-right: 8px;
}

.ig-comment-text p {
    margin: 4px 0 0;
    font-size: 14px;
    line-height: 1.55;
    color: #374151;
    word-break: break-word;
}

.ig-comments-footer {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #f0f0f0;
    background: #fff;
}

.ig-comments-compose {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 14px;
    border-radius: 999px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ig-comments-compose:focus-within {
    background: #fff;
    border-color: #93b4f0;
    box-shadow: 0 0 0 3px rgba(70, 112, 206, 0.12);
}

.ig-comments-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    padding: 10px 0;
    font-family: inherit;
    color: #111827;
    min-width: 0;
}

.ig-comments-input::placeholder {
    color: #9ca3af;
}

.ig-comments-input:focus {
    outline: none;
}

.ig-comments-post {
    flex-shrink: 0;
    border: none;
    border-radius: 999px;
    background: #4670CE;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    padding: 9px 16px;
    font-family: inherit;
    opacity: 0.45;
    transition: opacity 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.ig-comments-post.is-active {
    opacity: 1;
    box-shadow: 0 4px 12px rgba(70, 112, 206, 0.32);
}

.ig-comments-post.is-active:active {
    transform: scale(0.97);
}

/* Hide legacy gallery UI */
.cg-wrap:not(.ig-legacy-hidden),
.cg-breadcrumb,
.cg-feed,
.cg-modal-backdrop {
    display: none !important;
}

/* گالری کلینیک: منوی بالای کلینیک + بدون هدر/منوی پایین طب۲۰ */
body.clinic-gallery-shell.tebgram-reels-body .header-style3 {
    display: none !important;
}

body.clinic-gallery-shell.tebgram-reels-body .menuzord-container.header-nav-container {
    z-index: 1060;
}

body.clinic-gallery-shell.tebgram-reels-body {
    padding-top: 80px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.clinic-gallery-shell.tebgram-reels-body .teb20-bottom-nav {
    display: none !important;
}

body.clinic-gallery-shell .ig-reel-header {
    display: none !important;
}

body.clinic-gallery-shell .ig-reel-book-btn {
    display: none !important;
}

body.clinic-gallery-shell.tebgram-reels-body .tebgram-reels-app {
    top: 80px;
    bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 767.98px) {
    body.clinic-gallery-shell.tebgram-reels-body {
        padding-top: 60px;
    }

    body.clinic-gallery-shell.tebgram-reels-body .tebgram-reels-app {
        top: 60px;
    }
}

/* گالری کلینیک: حالت موبایل در دسکتاپ (مثل طب‌گرام) */
body.clinic-gallery-shell.tebgram-reels-body .ig-reel-media {
    object-fit: contain;
}

@media (min-width: 768px) {
    body.clinic-gallery-shell.tebgram-reels-body .ig-comments-sheet {
        max-width: var(--tebgram-shell-width, 430px);
        margin-left: auto;
        margin-right: auto;
    }
}

@media (min-width: 769px) {
    body:not(.tebgram-reels-body) .ig-reel-actions {
        right: 16px;
    }

    body:not(.tebgram-reels-body) .ig-reels-swiper .swiper-slide {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    body:not(.tebgram-reels-body) .ig-reel-media {
        position: relative;
        width: auto;
        max-width: 420px;
        height: 100%;
        max-height: 100vh;
        margin: 0 auto;
    }

    body:not(.tebgram-reels-body) .ig-reel-gradient {
        left: 50%;
        transform: translateX(-50%);
        width: 420px;
        max-width: 100%;
    }
}
