/* ==========================================================================
   NIXFOREST TEAMS — RESPONSIVE STYLES (MODULE TEAM & WEB)
   Desktop (> 900px) layout remains unchanged.
   ========================================================================== */

/* Moved from _header.php inline <style> */
.user-menu-item:hover {
    background: #f3f2f1 !important;
    color: var(--teams-brand, #464eb8) !important;
}

.user-menu-divider {
    height: 1px;
    background: #edebe9;
    margin: 4px 0;
}

.user-menu-logout-item {
    color: #a4262c !important;
}

.user-menu-logout-item:hover {
    background: #fdf3f2 !important;
    color: #a4262c !important;
}

/* Desktop defaults: hide mobile/tablet-only navigation elements */
.mobile-menu-btn,
.sidebar-mobile-close-btn,
.rail-item-mobile-only,
.channel-mobile-back-btn,
.channel-mobile-fab,
.teams-mobile-backdrop {
    display: none;
}

/* Mobile hamburger button base styling */
.mobile-menu-btn {
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    margin-right: 4px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}

.mobile-menu-btn:hover,
.mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.16);
}

/* Channel mobile back button base styling */
.channel-mobile-back-btn {
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    margin-right: 4px;
    border: none;
    border-radius: 50%;
    background: #f3f2f1;
    color: #242424;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease;
}

.channel-mobile-back-btn:hover,
.channel-mobile-back-btn:active {
    background: #e1dfdd;
}

/* Mobile Floating Action Button (New Post) base styling */
.channel-mobile-fab {
    position: fixed;
    right: 16px;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #464eb8 0%, #5b5fc7 100%);
    color: #ffffff;
    box-shadow: 0 4px 16px rgba(70, 78, 184, 0.42);
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    z-index: 880;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.channel-mobile-fab:active {
    transform: scale(0.94);
    box-shadow: 0 2px 10px rgba(70, 78, 184, 0.36);
}

/* ==========================================================================
   BREAKPOINT 1: TABLET & SMALL LAPTOP (<= 900px)
   Off-canvas Sidebar Drawer + Full-width Content Area
   ========================================================================== */
@media (max-width: 900px) {
    .mobile-menu-btn {
        display: inline-flex;
    }

    .sidebar-mobile-close-btn {
        display: inline-flex;
    }

    #headerLiveClock {
        display: none;
    }

    .teams-top-header {
        padding: 0 10px;
        gap: 8px;
    }

    .teams-top-header .brand {
        min-width: auto;
        flex-shrink: 0;
        gap: 4px;
    }

    .teams-top-header .search-container {
        flex: 1 1 auto;
        max-width: none;
        min-width: 0;
        margin: 0;
    }

    .teams-top-header .user-actions {
        min-width: auto;
        flex-shrink: 0;
        gap: 6px;
    }

    .header-login-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Off-canvas Communities Sidebar Drawer */
    .teams-sidebar {
        position: fixed;
        top: 48px;
        left: 0;
        bottom: 0;
        width: min(320px, 88vw);
        max-width: 88vw;
        z-index: 960;
        transform: translateX(-100%);
        transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.18);
        will-change: transform;
    }

    .teams-sidebar.is-open {
        transform: translateX(0);
    }

    /* Drawer Backdrop */
    .teams-mobile-backdrop {
        display: block;
        position: fixed;
        top: 48px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 950;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .teams-mobile-backdrop.is-visible {
        opacity: 1;
        pointer-events: auto;
    }

    /* Main Content takes remaining width cleanly */
    .teams-content-area {
        flex: 1 1 auto;
        min-width: 0;
        width: 100%;
    }
}

/* ==========================================================================
   BREAKPOINT 2: MOBILE (<= 768px)
   Bottom Navigation Bar + Card-based Communities + Pill Tabs + FAB
   ========================================================================== */
@media (max-width: 768px) {
    body.teams-app {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .teams-main-layout {
        position: relative;
        height: calc(100vh - 48px);
        height: calc(100dvh - 48px);
        width: 100%;
    }

    /* Bottom Navigation Bar (MS Teams Mobile Pattern) */
    .teams-rail {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding: 4px 6px env(safe-area-inset-bottom, 0px) 6px;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        gap: 2px;
        z-index: 900;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.14);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.14);
    }

    .teams-rail .rail-item {
        flex: 1 1 0;
        width: auto;
        height: 48px;
        min-width: 0;
        padding: 4px 2px;
        border: none;
        background: transparent;
        border-radius: 8px;
        cursor: pointer;
    }

    .teams-rail .rail-item svg {
        width: 22px;
        height: 22px;
        margin-bottom: 2px;
    }

    .teams-rail .rail-item span {
        font-size: 10px;
        line-height: 1.1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .teams-rail .rail-item.active::before {
        top: 0;
        bottom: auto;
        left: 24%;
        right: 24%;
        width: auto;
        height: 3px;
        border-radius: 0 0 3px 3px;
    }

    .teams-rail .rail-badge {
        top: 2px;
        right: calc(50% - 18px);
    }

    .rail-item-mobile-only {
        display: flex;
    }

    /* Main Content Area: single scroll container on mobile so channel header scrolls with feed */
    .teams-content-area {
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }

    /* Drawer overlays Bottom Navigation Bar cleanly */
    .teams-sidebar {
        background: #f3f2f1;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .teams-sidebar .sidebar-header {
        background: #ffffff;
        border-bottom: 1px solid var(--teams-border, #e1dfdd);
        padding: 12px 14px;
    }

    .teams-sidebar .sidebar-header h2 {
        font-size: 18px;
    }

    .teams-sidebar .sidebar-groups-list {
        padding: 12px;
    }

    /* Card-based Communities inside Mobile Drawer (Reference Image 1) */
    .teams-sidebar .community-section {
        background: #ffffff;
        border: 1px solid #e1dfdd;
        border-radius: 12px;
        padding: 10px 10px 6px 10px;
        margin-bottom: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    }

    .teams-sidebar .community-header {
        padding: 6px 6px 10px 6px;
        border-bottom: 1px solid #f3f2f1;
        margin-bottom: 4px;
        border-radius: 8px;
    }

    .teams-sidebar .community-avatar {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        font-size: 18px;
    }

    .teams-sidebar .community-name {
        font-size: 15px;
        font-weight: 600;
    }

    .teams-sidebar .community-channels {
        padding-left: 0;
        margin-top: 2px;
    }

    .teams-sidebar .channel-row a {
        min-height: 42px;
        padding: 8px 10px;
        border-radius: 8px;
        font-size: 14px;
    }

    .teams-sidebar .add-channel-row .sidebar-add-channel-btn {
        color: #464eb8;
        font-weight: 600;
    }

    /* Top Header compact on mobile */
    .teams-top-header {
        padding: 0 8px;
        gap: 6px;
    }

    .teams-top-header .search-input {
        font-size: 13px;
        padding-left: 30px;
        padding-right: 26px;
    }

    .header-login-btn {
        padding: 5px 10px;
        font-size: 12px;
        line-height: 1.2;
    }

    /* Global Search Dropdown spans full viewport width on mobile */
    .teams-search-dropdown {
        position: fixed;
        top: 52px;
        left: 8px;
        right: 8px;
        width: auto;
        max-width: none;
        max-height: calc(100dvh - 68px);
        overflow-y: auto;
    }

    /* User Menu Dropdown stays inside viewport */
    .user-menu-dropdown {
        right: 0;
        max-width: calc(100vw - 16px);
    }

    /* ----------------------------------------------------------------------
       CHANNEL VIEW (Reference Image 2)
       ---------------------------------------------------------------------- */
    .channel-main-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
        height: auto;
        min-height: auto;
    }

    .channel-mobile-back-btn {
        display: inline-flex;
    }

    .channel-main-header .channel-info {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        min-width: 0;
        width: 100%;
    }

    .channel-main-header .channel-title {
        font-size: 16px;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 6px;
        min-width: 0;
        width: 100%;
    }

    .channel-main-header .channel-title-name {
        white-space: normal;
        word-break: break-word;
        overflow: visible;
        text-overflow: clip;
        min-width: 0;
    }

    .channel-main-header .tc-s-045 {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .channel-main-header .channel-desc {
        font-size: 12px;
        line-height: 1.4;
        padding-left: 36px;
        border-left: none;
        margin-left: 0;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        width: 100%;
        box-sizing: border-box;
    }

    .channel-header-controls,
    .channel-main-header > .tc-s-015 {
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
        min-width: 0;
    }

    /* Pill-style horizontally scrollable channel tabs */
    .channel-tabs {
        display: flex;
        align-items: center;
        gap: 6px;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 2px 0;
        flex: 0 0 auto;
        min-width: 0;
        height: auto;
    }

    .channel-main-header .channel-tabs {
        flex: 1 1 auto;
    }

    /* Standalone tabs bar (e.g. /profile) must not stretch vertically */
    .teams-content-area > .channel-tabs,
    .channel-tabs.tc-s-005 {
        flex: 0 0 auto;
        width: 100%;
        padding: 10px 12px;
        box-sizing: border-box;
        height: auto;
        min-height: 0;
    }

    .channel-tabs::-webkit-scrollbar {
        display: none;
    }

    .channel-tab-item {
        display: inline-flex;
        align-items: center;
        padding: 6px 14px;
        border-radius: 20px;
        background: #f3f2f1;
        color: #424242;
        font-size: 13px;
        font-weight: 600;
        border: 1px solid transparent;
        flex-shrink: 0;
        height: auto;
        line-height: 1.2;
    }

    .channel-tab-item.active {
        background: #e8ebfa;
        color: #464eb8;
        border-color: #c7d1f5;
    }

    .channel-tab-item.active::after {
        display: none;
    }

    /* Hide header New Post text button on mobile in favor of FAB */
    .channel-header-new-post-btn {
        display: none;
    }

    .channel-mobile-fab {
        display: inline-flex;
    }

    .channel-header-actions {
        flex-shrink: 0;
    }

    /* Feed & Thread Cards: flow naturally inside .teams-content-area so header scrolls out of view */
    .teams-feed-scroll,
    .tc-s-029 {
        flex: 0 0 auto;
        overflow-y: visible;
        height: auto;
        padding: 12px !important;
        padding-bottom: 84px !important;
    }

    .team-thread-card {
        border-radius: 12px;
        padding: 14px;
        margin-bottom: 12px;
    }

    .thread-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .thread-title {
        font-size: 15px;
        line-height: 1.35;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .thread-body,
    .comment-body,
    .markdown-content {
        font-size: 14px;
        line-height: 1.55;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .thread-body a,
    .comment-body a,
    .markdown-content a {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .thread-body img,
    .comment-body img,
    .markdown-content img {
        max-width: 100%;
        height: auto;
    }

    .thread-body pre,
    .comment-body pre,
    .markdown-content pre {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .thread-body table,
    .comment-body table,
    .markdown-content table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .reaction-bar,
    .thread-reactions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .thread-comments-wrapper {
        padding-left: 10px;
    }

    .comment-item {
        padding: 10px 8px;
    }

    .reply-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* ----------------------------------------------------------------------
       MODALS & DIALOGS (TEAM & WEB)
       ---------------------------------------------------------------------- */
    .teams-file-modal-dialog,
    .teams-modal-dialog,
    .modal-dialog {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 32px) !important;
        margin: 16px auto !important;
    }

    /* ----------------------------------------------------------------------
       TEAM MANAGEMENT & CONTENT PAGES
       ---------------------------------------------------------------------- */
    .tc-s-004 {
        padding: 14px 12px;
        padding-bottom: 84px;
    }

    .tc-s-005 {
        padding: 0 12px;
    }

    .tc-s-008 {
        padding: 12px;
    }

    .tc-s-012 {
        padding: 20px 12px;
        align-items: flex-start;
    }

    .tc-s-017 {
        grid-template-columns: 1fr;
    }

    .tc-s-030 {
        padding: 16px;
    }

    /* Activity Page (/team/activity) */
    .activity-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 14px;
        height: auto;
    }

    .activity-header > .tc-s-015 {
        gap: 10px;
    }

    .activity-header > .t-flex-center-12 {
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 8px;
    }

    .activity-filter-tabs {
        display: inline-flex;
        align-items: center;
        flex-shrink: 0;
    }

    .tm-activity-filter-pill {
        white-space: nowrap;
        padding: 6px 12px;
        font-size: 12px;
    }

    .btn-mark-all-read {
        white-space: nowrap;
        height: auto;
        min-height: 32px;
        padding: 6px 12px;
        font-size: 12px;
        line-height: 1.2;
    }

    .activity-feed-scroll {
        padding: 12px;
        padding-bottom: 84px;
    }

    .tm-activity-card {
        padding: 12px;
        gap: 12px;
    }

    .tm-activity-title-row {
        flex-wrap: wrap;
    }

    /* Channel Files Page (/team/channel/files) */
    .channel-files-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .channel-files-toolbar .tm-s-065,
    .channel-files-toolbar .tm-s-068 {
        flex-wrap: wrap;
        width: 100%;
        gap: 8px;
    }

    .channel-files-toolbar .channel-quota-box,
    .channel-files-toolbar .tm-s-206,
    .channel-files-toolbar .channel-file-search-input {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .channel-files-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .channel-files-table {
        min-width: 620px;
        width: 100%;
    }

    .channel-files-table th,
    .channel-files-table td {
        white-space: nowrap;
    }

    .channel-files-table .channel-file-name-btn {
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
        min-width: 180px;
        text-align: left;
    }

    /* Channel Settings Page (/team/channel/settings) */
    .channel-main-header.tm-s-049 .tc-s-036 {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .channel-main-header.tm-s-049 .t-flex-center-8 {
        flex-wrap: wrap;
    }

    .channel-main-header.tm-s-049 .tm-s-129,
    .channel-main-header.tm-s-049 .tm-s-131,
    .channel-main-header.tm-s-049 .tm-s-258 {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .channel-main-header.tm-s-049 .tm-s-087 {
        display: flex;
        justify-content: flex-start;
    }

    .settings-tab-panel .tm-s-026,
    .settings-tab-panel .tm-s-027 {
        padding: 14px;
    }

    .settings-tab-panel .tm-s-094 {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .settings-tab-panel .tc-s-065 {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .settings-tab-panel .tc-s-070 {
        min-width: 560px;
        width: 100%;
    }

    /* Add Member & Block User forms stack cleanly to 1 column */
    .settings-tab-panel .tm-s-098,
    .settings-tab-panel .tm-s-099 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .settings-tab-panel .tm-s-188,
    .settings-tab-panel .tm-s-007 {
        width: 100%;
    }

    /* Share Link, Regenerate Token, Email Invite, Privacy Radios */
    .settings-tab-panel .tm-s-080,
    .settings-tab-panel .tm-s-079,
    .settings-tab-panel .tm-s-197,
    .settings-tab-panel .tm-s-076 {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .settings-tab-panel .tm-s-190,
    .settings-tab-panel .tm-s-191,
    .settings-tab-panel .tm-s-192,
    .settings-tab-panel .tm-s-286,
    .settings-tab-panel .tm-s-058 {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        height: 38px;
        min-height: 38px;
        box-sizing: border-box;
    }

    .settings-tab-panel .tm-s-190,
    .settings-tab-panel .tm-s-191 {
        padding: 0 12px;
        font-size: 13px;
    }

    /* ----------------------------------------------------------------------
       WEB MODULE PAGES (Home, Profile, Contact, Policy, ChangeLog, Auth)
       ---------------------------------------------------------------------- */
    .wp-s-056,
    .wp-s-057 {
        padding: 20px 14px;
        align-items: flex-start;
    }

    .wp-s-011,
    .wp-s-012,
    .wp-s-013,
    .wp-s-014,
    .wp-s-015,
    .wp-s-016,
    .wp-s-017,
    .wp-changelog-card {
        padding: 16px;
    }

    .wp-s-043,
    .wp-s-044,
    .wp-s-045 {
        grid-template-columns: 1fr;
    }

    /* Cloudflare Turnstile container: prevent horizontal overflow */
    .cf-turnstile {
        max-width: 100%;
        overflow-x: auto;
    }

    /* Realtime Toast sits above Mobile Bottom Navigation Bar */
    .realtime-toast-container {
        right: 12px;
        left: 12px;
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        max-width: none;
        width: auto;
    }
}

/* ==========================================================================
   BREAKPOINT 3: SMALL MOBILE (<= 640px & <= 576px)
   ========================================================================== */
@media (max-width: 640px) {
    .teams-top-header .brand-text {
        display: none;
    }

    .teams-top-header .brand a {
        gap: 0;
    }
}

@media (max-width: 576px) {
    /* Profile Page avatar + meta header stacks cleanly */
    .wp-s-030 {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        padding: 14px;
    }

    /* Auth & form action rows */
    .wp-s-033 {
        flex-direction: column;
        align-items: stretch;
    }

    .wp-s-041 {
        margin-bottom: 28px;
    }

    .wp-s-082 {
        font-size: 14px;
        margin-bottom: 20px;
    }
}
