/* Shared Classes */
#main {
    padding-left: 67px !important;
    padding-top: -5px !important;
    padding-right: 10px !important;
}

#Site, #Logo, #Greeting {
    display: none !important;
}

#mobileLogo {
    display: block !important;
}

#DeskHeader {
    display: none !important;
}

#MobileHeader {
    display: block !important;
}

#ProfileDropDown {
    position: absolute;
    top: 25px;
    background-color: white;
}

#NotificationDropDown {
    width: 300px !important;
    min-width: 300px !important;
    right: 0 !important;
    position: absolute !important;
    top: 25px !important;
    background-color: white !important;
}

.table-responsive td {
    white-space: normal !important; /* allow line breaks */
    word-break: break-word; /* break long words */
    overflow-wrap: anywhere; /* modern fallback */
}

.table-responsive.no-wrap td {
    white-space: normal !important;
    word-break: normal;
    overflow-wrap: normal;
}

.auth-links {
    display: flex;
    justify-content: flex-end; /* push to left */
    width: 205px;
}

    .auth-links .nav-item {
        margin-right: 15px; /* spacing between Register & Login */
    }

#actionMenu {
    flex-direction: row;
    list-style: none;
    display: flex;
    justify-content: flex-end; /* pushes everything to the right */
    padding: 0;
    margin: 0;
    gap: 1.3px;
    float: right;
}


/* Narrow screens: the row must span the full header so the logo (margin-right:auto)
   can sit at the LEFT edge while the other icons stay at the RIGHT edge. The
   float shrink-wrapped the row and kept everything bunched on the right. */
@media (max-width: 991px) {
    #actionMenu {
        float: none;
        width: 100%;
    }

    /* Line the logo up with the sidebar's Home (Dashboard) icon below it. */
    #mobileLogo {
        margin-left: 5px;  /* nav padding 7px + 5px = 12px; the 36px logo is then centred on x = 30, the middle of the 60px sidebar column */
        flex: 0 0 auto;    /* never squeezed by the icons: a squeezed logo slid left of the sidebar icons */
    }
}

/* Phones: the top bar must fit a 360px screen. Its 9 items (logo + 8 icons of 40px) were wider than the
   screen, so the logo was squeezed to a 2px sliver and on 320px phones the profile picture (the menu)
   was cut off on the right. Same rules as Chat. */
@media (max-width: 575.98px) {
    /* Every icon is 2rem wide and SHRINKS (all equally) when the phone is narrower
       (320px screens, large display-size settings). */
    #MobileHeader .navbar-brand,
    #MobileHeader #actionMenu {
        min-width: 0;
    }

    #MobileHeader #mobileLogo {
        flex: 0 0 auto;
    }

    #MobileHeader #actionMenu > li {
        flex: 0 1 2rem;
        min-width: 0;
    }

    #MobileHeader #actionMenu .icon-md {
        width: 100%;
        height: auto;
        aspect-ratio: 1 / 1;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #MobileHeader #actionMenu .icon-md > img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    #MobileHeader #actionMenu > li.ms-2 {
        margin-left: 2px !important;
    }

    /* Notification box: pinned inside the screen edges (it hung off the left edge), smaller text and spacing. */
    #MobileHeader .dropdown-menu[aria-labelledby="notifDropdown"] {
        position: fixed !important;
        inset: 56px 8px auto 8px !important;
        transform: none !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        margin: 0 !important;
        font-size: 0.78rem;
    }

    #MobileHeader .dropdown-menu[aria-labelledby="notifDropdown"] .card-header,
    #MobileHeader .dropdown-menu[aria-labelledby="notifDropdown"] .card-footer .btn {
        padding: 0.4rem 0.75rem !important;
    }

    #MobileHeader .dropdown-menu[aria-labelledby="notifDropdown"] h6,
    #MobileHeader .dropdown-menu[aria-labelledby="notifDropdown"] a,
    #MobileHeader .dropdown-menu[aria-labelledby="notifDropdown"] p,
    #MobileHeader .dropdown-menu[aria-labelledby="notifDropdown"] li,
    #MobileHeader .dropdown-menu[aria-labelledby="notifDropdown"] .btn {
        font-size: 0.78rem !important;
    }

    #MobileHeader .dropdown-menu[aria-labelledby="notifDropdown"] h6 {
        font-size: 0.9rem !important;
        margin-bottom: 0;
    }
}

/* Tablets: viewport.css spreads the icons with a fixed 70px gap, which is wider than a 768px screen
   (the profile picture ended at x = 900 and the logo was squeezed to nothing). The gap now grows
   with the screen and reaches the same 70px at 960px and up. */
@media (min-width: 768px) and (max-width: 991.98px) {
    #MobileHeader #actionMenu {
        gap: clamp(8px, calc((100vw - 400px) / 8), 70px);
    }
}

/* ===== Feed on phones: every pop-up menu is narrower (they were all forced to 350px, wider than the space next
   to the side bar) and opens above the side bar and the top bar. The notification box keeps its own rule above. ===== */
@media (max-width: 767.98px) {
    .dropdown-menu {
        min-width: 0 !important;
        width: max-content !important;
        max-width: min(240px, calc(100vw - 84px)) !important;
        z-index: 1060 !important;
    }

    .dropdown-menu .dropdown-item,
    .dropdown-menu > li > a,
    .dropdown-menu > li > label {
        white-space: normal;
    }

    #ProfileMenu,
    .profileLink {
        min-width: 0 !important;
        width: min(220px, calc(100vw - 84px)) !important;
    }
}

/* ===== Feed on phones: the page uses the whole screen. Something wider than the phone made the browser lay the
   page out wider than the screen (373px on a 360px phone), so the content sat to the left with a dead strip on
   the right; and the content started 22px after the side bar. ===== */
@media (max-width: 767.98px) {
    html,
    body {
        overflow-x: clip;
        max-width: 100%;
    }

    main {
        padding-left: 62px !important;
    }

    main .container,
    main .container-fluid {
        max-width: 100%;
        padding-left: 6px;
        padding-right: 6px;
    }

    main .row {
        --bs-gutter-x: 0.5rem;
    }

    main .card,
    main img,
    main video,
    main iframe {
        max-width: 100%;
    }

    #leaderboard {
        margin-right: 0 !important;
    }
}

/* ===== Feed on phones: a video is as tall as the video itself (its box was a fixed 500px, so a wide video sat
   between two grey bands); like / dislike are finger-sized (the dislike sat in a 5px wide slot) and taps are
   not held back waiting for a double-tap. ===== */
@media (max-width: 767.98px) {
    div[id^="Video_"] video,
    .player-wrapper video {
        width: 100% !important;
        height: auto !important;
        max-height: 80vh !important;
    }

    html {
        touch-action: manipulation;
    }

    li:has(> button[id^="likePost_"]),
    li:has(> button[id^="dislikePost_"]),
    li:has(> button[id^="like_"]),
    li:has(> button[id^="dislike_"]) {
        width: auto !important;
    }

    button[id^="likePost_"],
    button[id^="dislikePost_"],
    button[id^="like_"],
    button[id^="dislike_"] {
        min-width: 42px;
        min-height: 40px;
        padding: 8px 10px !important;
        touch-action: manipulation;
    }
}

/* ===== Like / dislike colour (all screens, matters on phones): the thumb turns green / red at once. A tapped
   button keeps its "pressed / hover" state on a phone and that colour used to win over .green / .red, so the
   thumb looked unchanged until something else was tapped. ===== */
.btn.green,
.btn.green:hover,
.btn.green:active,
.btn.green:focus,
.btn.green:focus-visible {
    color: #348556 !important;
}

.btn.red,
.btn.red:hover,
.btn.red:active,
.btn.red:focus,
.btn.red:focus-visible {
    color: #b90000 !important;
}

button[id^="likePost_"]:not(.green):hover,
button[id^="likePost_"]:not(.green):focus,
button[id^="dislikePost_"]:not(.red):hover,
button[id^="dislikePost_"]:not(.red):focus,
button[id^="like_"]:not(.green):hover,
button[id^="like_"]:not(.green):focus,
button[id^="dislike_"]:not(.red):hover,
button[id^="dislike_"]:not(.red):focus {
    color: var(--bs-btn-color, inherit);
    border-color: transparent;
    box-shadow: none;
}

/* ===== Feed on phones (3): photos and videos run edge to edge in their post and keep their own shape (they were
   a fixed 300px / 500px tall box with space around); the Liked / Disliked list is centred and readable (it was
   20% of the screen wide); no dot in front of the post's time. ===== */
@media (max-width: 767.98px) {
    main .card > .card-body,
    main .card > .card-header,
    main .card > .card-footer {
        padding-left: 10px;
        padding-right: 10px;
    }

    div[id^="Photo_"],
    div[id^="Video_"] {
        margin-left: -10px;
        margin-right: -10px;
    }

    div[id^="Photo_"] > div,
    div[id^="Video_"] > div,
    div[id^="Video_"] .player-wrapper {
        padding: 0 !important;
        margin: 0 0 4px 0;
    }

    div[id^="Photo_"] img {
        width: 100% !important;
        height: auto !important;
        max-height: 85vh;
        object-fit: cover;
        border-radius: 0 !important;
    }

    div[id^="Video_"] video {
        border-radius: 0 !important;
        box-shadow: none !important;
        max-height: 85vh !important;
    }

    #socialreactionLike .modal-dialog,
    #socialreactionDisLike .modal-dialog {
        width: min(280px, 86vw) !important;
        max-width: none;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    main .card-header .nav.nav-divider .nav-item + .nav-item::before {
        content: none !important;
        display: none !important;
    }

    main .card-header .nav.nav-divider .nav-item + .nav-item {
        margin-left: 0 !important;
        padding-left: 0 !important;
    }
}

/* ===== Feed on phones (4) ===== */
@media (max-width: 767.98px) {
    /* The emoji picker is hidden: the phone keyboard has emojis. */
    a:has(+ ul.dropdown-menu.emojiRow),
    ul.dropdown-menu.emojiRow {
        display: none !important;
    }

    /* Every pop-up box is centred and no wider than the phone needs (several were set to 20% of the screen). */
    .modal .modal-dialog {
        width: auto !important;
        max-width: min(340px, 94vw) !important;
        min-height: calc(100% - 1rem);
        margin: 0.5rem auto !important;
        display: flex;
        align-items: center;
    }

    .modal .modal-dialog > .modal-content {
        width: 100%;
    }

    /* Yes / no boxes (follow, delete, hide, report, share, join...) are smaller still. */
    #actionComment .modal-dialog,
    #deletePost .modal-dialog,
    #deleteComment .modal-dialog,
    #hideComment .modal-dialog,
    #reportComment .modal-dialog,
    #joinLeaveCircle .modal-dialog,
    #deleteCircle .modal-dialog,
    #shareLink .modal-dialog,
    #shareWallLink .modal-dialog,
    #shareToCircle .modal-dialog,
    #inviteToCircle .modal-dialog,
    #socialreactionLike .modal-dialog,
    #socialreactionDisLike .modal-dialog,
    #loadingProcessingModal .modal-dialog {
        max-width: min(280px, 86vw) !important;
    }

    #actionComment .modal-content,
    #deletePost .modal-content,
    #deleteComment .modal-content,
    #hideComment .modal-content,
    #reportComment .modal-content,
    #joinLeaveCircle .modal-content,
    #deleteCircle .modal-content,
    #shareLink .modal-content,
    #shareWallLink .modal-content,
    #shareToCircle .modal-content,
    #inviteToCircle .modal-content {
        font-size: 0.9rem;
    }

    .modal .modal-header,
    .modal .modal-footer {
        padding: 0.6rem 0.8rem;
    }

    .modal .modal-body {
        padding: 0.7rem 0.8rem;
    }

    .modal .modal-title {
        font-size: 1rem;
    }

    .modal .modal-footer .btn {
        font-size: 0.85rem;
        padding: 0.35rem 0.8rem;
    }

    #loadingProcessingModal .modal-content {
        padding: 1.1rem 1rem !important;
    }

    #loadingProcessingModal h4 {
        font-size: 1rem;
        margin-bottom: 0;
    }

    /* The video just picked for a new post is shown in its own shape, as wide as the box (it was squeezed into a
       fixed 400 x 200 frame, so an upright phone video looked tiny). */
    #VideoFilelist ul {
        list-style: none;
        padding-left: 0;
    }

    #VideoFilelist video {
        display: block;
        width: 100% !important;
        height: auto !important;
        max-height: 65vh;
    }

    /* Comment like / dislike: the thumb and its count sit on one line with the same space for both. */
    li:has(> button[id^="like_"]),
    li:has(> button[id^="dislike_"]) {
        display: flex !important;
        align-items: center;
        gap: 4px;
        padding-left: 0.5rem !important;
    }

    li:has(> button[id^="like_"]) > a.nav-link,
    li:has(> button[id^="dislike_"]) > a.nav-link {
        padding: 0 !important;
        min-width: 1.2em;
        line-height: 1;
    }

    button[id^="like_"],
    button[id^="dislike_"] {
        min-width: 34px;
        min-height: 36px;
        padding: 6px !important;
    }
}

/* ===== Feed on phones (5): the message boxes with an icon ("Post Saved", errors, confirmations) are smaller.
   The icon is shrunk by its font size only, so its mark stays inside its circle. ===== */
@media (max-width: 767.98px) {
    .swal2-container .swal2-popup {
        width: min(250px, 80vw) !important;
        padding: 0.6rem 0.7rem 0.9rem 0.7rem !important;
        font-size: 0.8rem !important;
    }

    .swal2-container .swal2-icon {
        font-size: 0.55em !important;
        margin: 1.1em auto 0.5em auto !important;
    }

    .swal2-container .swal2-title {
        font-size: 1.05rem !important;
        padding: 0.3em 0.5em 0 0.5em !important;
    }

    .swal2-container .swal2-html-container {
        font-size: 0.85rem !important;
        margin: 0.4em 0.5em 0 0.5em !important;
        padding: 0 !important;
    }

    .swal2-container .swal2-actions {
        margin-top: 0.7em !important;
    }

    .swal2-container .swal2-styled {
        font-size: 0.85rem !important;
        padding: 0.35em 1.1em !important;
    }

    .swal2-container .swal2-input,
    .swal2-container .swal2-textarea,
    .swal2-container .swal2-file {
        font-size: 0.85rem !important;
        margin: 0.6em auto 0 auto !important;
        max-width: 100%;
    }
}

/* ===== Feed on computers: a video is as wide as its post and as tall as the video itself (it was a fixed 500px
   tall, so an upright video left white space beside it and a wide one sat between two coloured bands). An
   upright video stops at 640px tall and is centred on black. ===== */
@media (min-width: 768px) {
    div[id^="Video_"] video,
    .player-wrapper video {
        width: 100% !important;
        height: auto !important;
        max-height: min(640px, 80vh) !important;
        object-fit: contain;
        background-color: #000 !important;
    }
}

/* ===== Feed (6): in dark mode the names in the Liked / Disliked list are white (they were black on the dark
   box); on phones the thumbs of a comment or reply sit closer together. ===== */
[data-bs-theme="dark"] #LikedPostMemberList,
[data-bs-theme="dark"] #DisLikedPostMemberList,
[data-bs-theme="dark"] #LikedPostMemberList a,
[data-bs-theme="dark"] #DisLikedPostMemberList a,
[data-bs-theme="dark"] #LikedPostMemberList span,
[data-bs-theme="dark"] #DisLikedPostMemberList span,
[data-bs-theme="dark"] #LikedPostMemberList b,
[data-bs-theme="dark"] #DisLikedPostMemberList b {
    color: #fff !important;
}

@media (max-width: 767.98px) {
    li:has(> button[id^="like_"]),
    li:has(> button[id^="dislike_"]) {
        gap: 2px;
        padding-left: 0 !important;
    }

    button[id^="like_"],
    button[id^="dislike_"] {
        min-width: 28px;
        padding: 6px 3px !important;
    }
}

/* ===== Feed on phones (7): Share to Circle - each circle is one line: picture, name centred beside it, and
   the Share button at the right (they were stacked on the left). ===== */
@media (max-width: 767.98px) {
    #circleList > .d-md-flex {
        display: flex !important;
        align-items: center;
        gap: 10px;
        margin-bottom: 0.9rem !important;
    }

    #circleList > .d-md-flex > .avatar {
        margin: 0 !important;
        flex: 0 0 auto;
    }

    #circleList > .d-md-flex > .w-100 {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    #circleList > .d-md-flex > .ms-md-auto {
        margin-left: auto !important;
        flex: 0 0 auto;
    }
}

/* ===== Feed (8): Circles page. Dark mode: the sort box keeps its white background, so its text is black (it was
   light on white). Phones: all the tabs (Friends' groups, Suggested for you, Popular near you, More suggestions,
   My Circles) are shown, small and centred, two to a line (they were one per line and pushed to the right);
   the same for the tabs of a single circle (Feed, About, Connections, Photos, Videos). ===== */
[data-bs-theme="dark"] #OrderSelector,
[data-bs-theme="dark"] #OrderSelector option {
    color: #000 !important;
}

@media (max-width: 767.98px) {
    ul.nav.nav-tabs.nav-bottom-line {
        display: flex;
        flex-wrap: wrap !important;
        justify-content: center !important;
        margin: 0 0 0.5rem 0;
        padding: 0 !important;
        gap: 0 2px;
    }

    ul.nav.nav-tabs.nav-bottom-line > .nav-item {
        flex: 0 0 auto;
        margin: 0 !important;
    }

    ul.nav.nav-tabs.nav-bottom-line > .nav-item > .nav-link {
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 0.4rem 0.5rem;
    }
}

/* ===== Feed on phones (9): Invite to Circle - each follower is one line like Share to Circle: picture, name,
   and the Invite button (or Member / Invitation Sent) at the right. ===== */
@media (max-width: 767.98px) {
    #circleInviteList > .d-md-flex {
        display: flex !important;
        align-items: center;
        gap: 10px;
        margin-bottom: 0.9rem !important;
    }

    #circleInviteList > .d-md-flex > .avatar {
        margin: 0 !important;
        flex: 0 0 auto;
    }

    #circleInviteList > .d-md-flex > .w-100 {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    #circleInviteList > .d-md-flex > .w-100 p {
        margin-left: 0 !important;
    }

    #circleInviteList > .d-md-flex > .ms-md-auto {
        margin-left: auto !important;
        flex: 0 0 auto;
    }

    #circleInviteList .btn {
        white-space: nowrap;
    }
}

/* ===== Feed on phones (10): a video opened from a circle's Videos tab (the black full-screen viewer) uses the
   whole width and its own shape. The player was a fixed wide (16:9) box, 203px tall on a phone, so an upright
   video played as a thin strip in the middle of it. ===== */
@media (max-width: 767.98px) {
    .glightbox-container .gslide-media,
    .glightbox-container .gslide-video,
    .glightbox-container .gvideo-wrapper {
        width: 100% !important;
        max-width: 100vw !important;
    }

    .glightbox-container .plyr,
    .glightbox-container .plyr__video-wrapper {
        height: auto !important;
        padding-bottom: 0 !important;
        aspect-ratio: auto !important;
    }

    .glightbox-container .plyr__video-wrapper video {
        position: static !important;
        display: block;
        width: 100% !important;
        height: auto !important;
        max-height: 72vh !important;
        object-fit: contain;
    }
}

/* ===== Feed on phones (11): a page that asks for one ad on phones (data-phone-max="1", the Circles page) shows
   only the first ad of its column; the loader fetches no more. ===== */
@media (max-width: 767.98px) {
    .lazy-ads[data-phone-max="1"] > *:not(:first-child),
    .lazy-ads[data-phone-max="1"] .ad-item ~ .ad-item,
    .lazy-ads[data-phone-max="1"] ~ .lazy-ads-loading {
        display: none !important;
    }
}
