/* ============================================
   NEXUS — Mobile Responsiveness v2
   Fixes Android touch/interaction issues
   ============================================ */

/* ── Hamburger button ── */
.mobile-menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 8px;
    padding: 0.45rem 0.65rem;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 0;
}
.mobile-menu-btn:hover,
.mobile-menu-btn:active {
    color: var(--text);
    border-color: var(--primary);
    background: rgba(212,160,23,0.1);
}

/* ── Overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

/* ══════════════════════════════════════════
   MOBILE (max-width: 768px)
══════════════════════════════════════════ */
@media (max-width: 768px) {

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%) !important;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 200 !important;
        width: 270px !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100% !important;
        overflow-y: auto;
    }
    .sidebar.open {
        transform: translateX(0) !important;
    }

    .main {
        margin-left: 0 !important;
        width: 100% !important;
        min-height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chat-wrap {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .topbar,
    .chat-topbar {
        padding: 0.7rem 0.875rem !important;
        gap: 0.6rem;
        position: sticky;
        top: 0;
        z-index: 10;
    }
    .topbar h2 {
        font-size: 0.95rem !important;
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .content {
        padding: 0.875rem !important;
    }

    /* Better tap targets for all interactive elements */
    .nav-link,
    .btn-primary,
    .btn-outline,
    .btn-logout,
    .filter-btn,
    .channel-item,
    .notif-btn,
    a[href],
    button {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .btn-primary,
    .btn-outline,
    .btn-logout {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .row.g-3 .col-6    { flex: 0 0 50%; max-width: 50%; }
    .row.g-3 .col-md-3 { flex: 0 0 50%; max-width: 50%; }
    .stat-card  { padding: 0.875rem !important; }
    .stat-value { font-size: 1.4rem !important; }

    .col-md-6, .col-lg-4 { flex: 0 0 100%; max-width: 100%; }

    .task-row { flex-wrap: wrap; gap: 0.5rem !important; }
    .task-sub { flex-wrap: wrap; }

    .filter-bar {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .filter-bar::-webkit-scrollbar { display: none; }
    .filter-btn { white-space: nowrap; flex-shrink: 0; }

    .stat-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem !important;
    }

    .notif-item    { padding: 0.875rem 1rem !important; }
    .notif-actions { flex-direction: column; }

    .login-card { margin: 1rem; padding: 1.75rem !important; }

    .modal-dialog { margin: 0.5rem !important; }
    .modal-body   { padding: 1.25rem !important; }

    .topbar .d-flex.gap-2 { gap: 0.4rem !important; }

    /* Board */
    .board-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1rem;
    }
    .board { flex-wrap: nowrap !important; min-width: max-content; }
    .kanban-col { min-width: 285px !important; max-width: 285px !important; }
    .breadcrumb-nav  { display: none !important; }
    .board-actions   { flex-wrap: wrap; gap: 0.4rem !important; }

    /* Calendar */
    .calendar-grid { font-size: 0.75rem; }
    .calendar-day  { min-height: 60px !important; padding: 0.25rem !important; }
    .cal-event     { font-size: 0.65rem !important; padding: 0.1rem 0.25rem !important; }

    /* Admin */
    .admin-grid { grid-template-columns: 1fr !important; }

    /* Chat: channel list → horizontal pill strip */
    .channel-list {
        width: 100% !important;
        height: auto !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border) !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0.5rem 0.75rem !important;
        gap: 0.4rem;
        flex-shrink: 0;
        align-items: center;
    }
    .channel-list::-webkit-scrollbar { display: none; }
    .channel-list-header { display: none !important; }
    .channel-item {
        border-left: none !important;
        border-radius: 20px !important;
        padding: 0.35rem 0.875rem !important;
        font-size: 0.8rem !important;
        white-space: nowrap;
        flex-shrink: 0;
        border: 1px solid var(--border) !important;
        background: var(--bg) !important;
        min-height: 36px;
        display: flex !important;
        align-items: center;
    }
    .channel-item.active {
        background: rgba(212,160,23,0.15) !important;
        border-color: var(--primary) !important;
        color: var(--primary) !important;
    }

    /* Chat layout */
    .chat-wrap {
        flex-direction: column !important;
        height: 100dvh !important;
        overflow: hidden;
    }
    .chat-main {
        flex: 1 !important;
        min-height: 0 !important;
        display: flex !important;
        flex-direction: column;
        overflow: hidden;
    }
    .messages-wrap {
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        padding: 0.875rem !important;
    }
    .chat-input-wrap {
        padding: 0.6rem 0.75rem !important;
        flex-shrink: 0 !important;
    }
    .chat-input-hint { display: none !important; }
    .send-btn {
        width: 42px !important;
        height: 42px !important;
        font-size: 1.1rem !important;
        min-width: 42px;
    }

    /* Utilities */
    .table-responsive-mobile { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .mobile-stack { flex-direction: column !important; }
    .mobile-full  { width: 100% !important; }
    .mobile-hide  { display: none !important; }
    .mobile-only  { display: block !important; }
}

/* ── Tablet ── */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar { width: 200px !important; }
    .main    { margin-left: 200px !important; }
    .content { padding: 1.5rem !important; }
    .topbar  { padding: 0.875rem 1.5rem !important; }
    .col-lg-4 { flex: 0 0 50%; max-width: 50%; }
}

/* ── Desktop: never show mobile elements ── */
@media (min-width: 769px) {
    .sidebar-overlay { display: none !important; }
    .mobile-menu-btn { display: none !important; }
}

.mobile-only { display: none; }
